Replace os.system() with subprocess.Popen() for safer URL handling#56
Open
assisted-by-ai wants to merge 3 commits intoKicksecure:masterfrom
Open
Replace os.system() with subprocess.Popen() for safer URL handling#56assisted-by-ai wants to merge 3 commits intoKicksecure:masterfrom
assisted-by-ai wants to merge 3 commits intoKicksecure:masterfrom
Conversation
Replace os.system() with subprocess.Popen() using a list of arguments in exec_curl() to prevent shell injection via crafted URLs from config files. The old code concatenated URLs directly into a shell command string, allowing arbitrary command execution. https://claude.ai/code/session_01JtRcMr5tVpDPo7be3GzaYU
/etc/sdwdate.d/*.conf is root-owned and trusted. Document this and the subprocess safety approach for reviewers. https://claude.ai/code/session_01JtRcMr5tVpDPo7be3GzaYU
Contributor
|
Accepted with minor tweaks in ArrayBolt3@732889d. Note however that the onion-tester script is broken and so the function that has been polished never gets called. Added a TODO in ArrayBolt3@5731137. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Refactored the
exec_curl()function to usesubprocess.Popen()instead ofos.system()for improved security and reliability when executing curl commands with URLs.Key Changes
os.system()withsubprocess.Popen()using a list of arguments (no shell invocation) to safely pass URLs without risk of shell interpretationresult.returncode == 0instead of string matching on the return codeosmodule import and addedsubprocessimport__pycache__/to ignore Python cache filesImplementation Details
The refactored code uses
subprocess.Popen()with:['curl', '--head', c_url]) to prevent shell interpretationstdout=subprocess.DEVNULLandstderr=subprocess.DEVNULLto suppress outputresult.returncode == 0) for clearer intenthttps://claude.ai/code/session_01JtRcMr5tVpDPo7be3GzaYU