Skip to content
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

chore: remove shell usage in shutdown subprocess #43

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

jusiskin
Copy link
Contributor

What was the problem/requirement? (What/Why)

When the worker is instructed in a UpdateWorkerSchedule API response to shut down the worker host, it launches a subprocess using the shell=True argument to subprocess.Popen. While the command is hard-coded and does not use user-supplied input, the worker agent code does not require the use of a shell and we should demonstrate best-practices and prevent any future possibility of unquoted shell command exploit.

What was the solution? (How)

Switch from using a shell command string and shell=True to instead provide a list of strings for the command and shell=False.

What is the impact of this change?

The Worker Agent no longer uses a shell command-string when creating a subprocess for shutting down the host. This helps protect against a future potential regression where untrusted input is used to form the command. It also removes the unnecessary overhead for spawning a shell to run the desired command.

How was this change tested?

Updated the unit tests which now pass.

Was this change documented?

No

Is this a breaking change?

No

@jusiskin jusiskin requested a review from a team as a code owner September 27, 2023 21:15
@jericht
Copy link
Contributor

jericht commented Sep 27, 2023

Looks like DCO is failing, just needs a sign off on commit

@jusiskin jusiskin force-pushed the jusiskin/remove_shell_subprocess branch from e2dc3bb to f40eb9a Compare September 27, 2023 21:56
@jusiskin jusiskin merged commit 1af6acb into mainline Sep 27, 2023
8 checks passed
@ddneilson ddneilson deleted the jusiskin/remove_shell_subprocess branch September 27, 2023 23:13
gmchale79 pushed a commit that referenced this pull request Oct 31, 2023
Signed-off-by: Josh Usiskin <[email protected]>
Signed-off-by: Graeme McHale <[email protected]>
gmchale79 pushed a commit that referenced this pull request Nov 2, 2023
Signed-off-by: Josh Usiskin <[email protected]>
Signed-off-by: Graeme McHale <[email protected]>
gahyusuh pushed a commit that referenced this pull request Nov 6, 2023
Signed-off-by: Josh Usiskin <[email protected]>
Signed-off-by: Graeme McHale <[email protected]>
Signed-off-by: Gahyun Suh <[email protected]>
gmchale79 pushed a commit that referenced this pull request Feb 12, 2024
Signed-off-by: Josh Usiskin <[email protected]>
Signed-off-by: Graeme McHale <[email protected]>
gmchale79 pushed a commit that referenced this pull request Mar 11, 2024
Signed-off-by: Josh Usiskin <[email protected]>
Signed-off-by: Graeme McHale <[email protected]>
jusiskin pushed a commit to jusiskin/deadline-cloud-worker-agent that referenced this pull request Sep 4, 2024
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.

3 participants