Skip to content

Conversation

@rgfegegeegege
Copy link

This PR mitigates a potential command injection risk in DhcpClient.py

Current code:

  • Extends os.environ['PATH'] dynamically
  • Uses have(command[0]) to locate dhclient/dhcpcd/udhcpc in the modified PATH
  • Constructs command list and passes to subprocess.Popen

While exploitation is difficult/impossible in standard Linux Mint setups (due to polkit authentication, user privileges, and context of execution), the pattern remains risky:

  • Environment variables like PATH are user-controlled
  • Dynamic lookup + Popen can lead to execution of arbitrary binaries if PATH is manipulated (theoretical in custom/future setups)

This is not best practice and could become exploitable in edge cases or forks

Changes:

  • Replace dynamic PATH extension and have() lookup with fixed/safe full paths for common DHCP clients
  • Fallback to shutil.which() if available (safer than env lookup)
  • Keep the same logic for finding the first available client

No functional change for normal users only improves security posture (defense-in-depth).

I was not able to create a working PoC, but the code pattern is potentially risky and should be avoided.

Thanks for reviewing

…id dynamic PATH lookup with fixed/safe paths

This PR mitigates a potential command injection risk in DhcpClient.py 

Current code:
- Extends os.environ['PATH'] dynamically
- Uses have(command[0]) to locate dhclient/dhcpcd/udhcpc in the modified PATH
- Constructs command list and passes to subprocess.Popen

While exploitation is difficult/impossible in standard Linux Mint setups (due to polkit authentication, user privileges, and context of execution), the pattern remains risky:
- Environment variables like PATH are user-controlled
- Dynamic lookup + Popen can lead to execution of arbitrary binaries if PATH is manipulated (theoretical in custom/future setups)

This is not best practice and could become exploitable in edge cases or forks.

Changes:
- Replace dynamic PATH extension and have() lookup with fixed/safe full paths for common DHCP clients
- Fallback to shutil.which() if available (safer than env lookup)
- Keep the same logic for finding the first available client

No functional change for normal users only improves security posture (defense-in-depth).

I was not able to create a working PoC, but the code pattern is potentially risky and should be avoided.

Thanks for reviewing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant