-
Notifications
You must be signed in to change notification settings - Fork 88
[RAPTOR-14353] Gavrenkov/poc drum watchdog v2 #1632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
pids = [int(line.split()[0]) for line in lines] | ||
for pid in pids: | ||
print("Killing pid:", pid) | ||
subprocess.run(f"kill {pid}", shell=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semgrep identified an issue in your code:
Found 'subprocess' function 'run' with 'shell=True'. This is dangerous because this call will spawn the command using a shell process. Doing so propagates current shell settings and variables, which makes it much easier for a malicious actor to execute commands. Use 'shell=False' instead.
To resolve this comment:
✨ Commit Assistant fix suggestion
subprocess.run(f"kill {pid}", shell=True) | |
subprocess.run(f"kill {pid}", shell=False) |
View step-by-step instructions
- Change the
subprocess.run(f"kill {pid}", shell=True)
call to avoid using the shell. - Update the line to pass the command and arguments as a list, like this:
subprocess.run(["kill", str(pid)])
.
This prevents shell injection vulnerabilities and makes the command execution safer, especially when working with dynamic input.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>
for false positive/ar <comment>
for acceptable risk/other <comment>
for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by subprocess-shell-true.
You can view more details about this finding in the Semgrep AppSec Platform.
This repository is public. Do not put here any private DataRobot or customer's data: code, datasets, model artifacts, .etc.
Results:

Summary
Rationale