Skip to content

fix: prevent shell command injection in verification endpoint#5

Open
haosenwang1018 wants to merge 1 commit into
HKUDS:mainfrom
haosenwang1018:fix/shell-injection-verify-cmd
Open

fix: prevent shell command injection in verification endpoint#5
haosenwang1018 wants to merge 1 commit into
HKUDS:mainfrom
haosenwang1018:fix/shell-injection-verify-cmd

Conversation

@haosenwang1018
Copy link
Copy Markdown

Problem

The verification command in the execute endpoint uses shell=True with user-controlled input (verification['command_success']), which allows arbitrary command injection via shell metacharacters.

For example, a malicious payload like "ls; rm -rf /" would be interpreted by the shell.

Fix

Replace shell=True with shell=False and use shlex.split() to safely tokenize the command string into a list. This prevents shell interpretation of metacharacters while preserving normal command execution.

shlex was already imported in the file.

Fixes #4

Use shlex.split() with shell=False instead of shell=True when
executing the verification command from API payload. This prevents
shell metacharacter injection (e.g. `; rm -rf /`) via the
command_success field.

Fixes HKUDS#4
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.

[Security] shell=True in verification command allows command injection in API endpoint

1 participant