FIX: Arbitrary Code Injection in the saved places #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Pardus MyComputer application executes directory paths that the user has added to the “Places Saved” list directly in a
shellcommand (xdg-open). A user-controlled JSON input (e.g. a record added to theplaces-savedfile) can be used to inject malicious shellcode and execute an arbitrary command on the operating system when clicked.Effect
Technical Details
subprocess.Popen("xdg-open '{}' &".format(path), shell=True)call.shell=Trueand concatenated string leads to the execution of payloads like'; ...; #in path.places-savedand executes this code directly on click.Attack Steps (Example)
~/.config/pardus-mycomputer/places-saved:{"path":"/tmp/fake'; touch /tmp/pwned; #", "name": "Exploit Test", "icon": "folder-symbolic"}/tmp/pwnedis created - the command injection is successful.CVSS Guess
7.0-8.0 (AV:L/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H)
Proposed Solution
shell=Trueand concatenated strings.shlex.quote()or similar safe escape functions.eval/reprlike transformations.These fixes will prevent user-controlled input from combining with a shell command to execute malicious code.
I also leave 2 sample codes for those who want to try:
1. test
run: