codeant-ai-for-open-source[bot] commented on code in PR #40557:
URL: https://github.com/apache/superset/pull/40557#discussion_r3328499683


##########
scripts/uv-pip-compile.sh:
##########
@@ -31,7 +31,7 @@ if [ -z "$RUNNING_IN_DOCKER" ]; then
     -w /app \
     -e RUNNING_IN_DOCKER=1 \
     python:${PYTHON_VERSION}-slim \
-    bash -c "pip install uv && ./scripts/uv-pip-compile.sh $*"
+    bash -c "pip install uv==0.11.17 && ./scripts/uv-pip-compile.sh $*"

Review Comment:
   **Suggestion:** The Docker re-invocation interpolates `$*` into a `bash -c` 
string, which re-parses user-supplied arguments in a new shell. This can 
corrupt arguments (loss of quoting) and allows shell metacharacters in an 
argument to be executed as commands inside the container. Pass arguments 
without shell re-parsing (preserve original argument boundaries) instead of 
embedding `$*` in the command string. [security]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Developer dependency pinning script mis-handles arguments with 
metacharacters.
   - ⚠️ Shell metacharacters in args executed as commands in Docker.
   - ⚠️ check-python-deps workflow depends on this script for CI checks.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. From the Superset repo root on a host where `RUNNING_IN_DOCKER` is unset 
(the normal
   case described in `scripts/uv-pip-compile.sh:22-23`), invoke the helper 
script with an
   argument containing shell metacharacters, e.g.:
   
      `./scripts/uv-pip-compile.sh '; touch /tmp/pwned #'`. This entrypoint is 
the same
      script referenced for normal usage in `requirements/README.md:5-12`.
   
   2. The script at `scripts/uv-pip-compile.sh:22-37` detects that it is not 
running in
   Docker and executes the Docker wrapper branch, building the command:
   
      `docker run ... bash -c "pip install uv==0.11.17 && 
./scripts/uv-pip-compile.sh $*"`
      (line 34). The outer shell expands `$*` inside the double-quoted string, 
so the literal
      text `; touch /tmp/pwned #` becomes part of the single program string 
passed to `bash
      -c` inside the container.
   
   3. Inside the container, `/bin/bash -c` receives a program string equivalent 
to:
   
      `pip install uv==0.11.17 && ./scripts/uv-pip-compile.sh ; touch 
/tmp/pwned #`.
   
      Because the argument content is now part of the shell program text 
(unquoted in that
      inner shell), the `;` is parsed as a command separator rather than as 
data, and the
      original argument is not forwarded as an argument to 
`./scripts/uv-pip-compile.sh` in
      the container.
   
   4. Observe that the injected command `touch /tmp/pwned` is executed inside 
the Docker
   container (you can confirm by adding a visible effect such as `'; echo PWNED
   >/app/injected.txt #'` instead). This demonstrates both: (a) loss/corruption 
of the
   original argument semantics, and (b) that shell metacharacters in arguments 
to
   `scripts/uv-pip-compile.sh` are re-parsed and executed as commands via the 
`bash -c "...
   $*"` construct at `scripts/uv-pip-compile.sh:34`.
   ```
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6e776f747338416ea4a2bc70122f003c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6e776f747338416ea4a2bc70122f003c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** scripts/uv-pip-compile.sh
   **Line:** 34:34
   **Comment:**
        *Security: The Docker re-invocation interpolates `$*` into a `bash -c` 
string, which re-parses user-supplied arguments in a new shell. This can 
corrupt arguments (loss of quoting) and allows shell metacharacters in an 
argument to be executed as commands inside the container. Pass arguments 
without shell re-parsing (preserve original argument boundaries) instead of 
embedding `$*` in the command string.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40557&comment_hash=cdf75e635924e2d7ebcb51cf67f13cfd9402037e3ca5421c02497921c9f4d0d1&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40557&comment_hash=cdf75e635924e2d7ebcb51cf67f13cfd9402037e3ca5421c02497921c9f4d0d1&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to