Skip to content

Validate uv package names against PEP 508 before uv pip show - #51016

Merged
pelikhan merged 7 commits into
mainfrom
copilot/sighthound-security-findings-again
Aug 7, 2026
Merged

Validate uv package names against PEP 508 before uv pip show#51016
pelikhan merged 7 commits into
mainfrom
copilot/sighthound-security-findings-again

Conversation

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Sighthound flagged five Critical command-injection findings around exec.Command calls built from dynamic data. Four of the five are already mitigated in the current code; the exception is the uv validation path, which only rejected --prefixed names.

Audit of reported findings

# Location Status
2 pip_validation.gopip index versions <pkg> --pre Already guarded by validatePipPackageName (PEP 508 allowlist)
3 dependabot.gonpm install --package-lock-only Fixed argument slice; npmPath resolved via fileutil.ResolveExecutablePath
4/5 poutine.godocker run -v <volumeMount> buildDockerVolumeMount canonicalizes and validates host path (absolute, no :) and container path
1 pip_validation.gouv pip show <pkg> --no-cache Gap — addressed here

Changes

  • pkg/workflow/pip_validation.go: validateUvPackages now applies validatePipPackageName to each extracted package name before the exec.Command call, matching the pip path. Invalid names are collected into the existing errors slice and surfaced as a validation error rather than reaching uv. Added a #nosec G204 justification consistent with the pip call site.
  • pkg/workflow/argument_injection_test.go: regression test asserting a malformed name is rejected.

Package extraction is permissive enough to yield names like pkg;whoami from uvx pkg;whoami in workflow custom steps, which previously flowed straight into the argv:

// before: only a '-' prefix check upstream
cmd := exec.Command(uvPath, "pip", "show", pkgName, "--no-cache")

// after
if err := validatePipPackageName(pkgName); err != nil {
    errors = append(errors, fmt.Sprintf("uv package '%s' is invalid: %v", pkg, err))
    continue
}
cmd := exec.Command(uvPath, "pip", "show", pkgName, "--no-cache")

Note on the test guard: it skips when uv is absent, because validateUvPackages then falls back to the pip path where invalid names are warnings rather than errors. Worth a second opinion on whether that fallback should also hard-fail.


Run context: https://github.com/github/gh-aw/actions/runs/31185909757> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.44 AIC · ⊞ 8.3K ·

Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 22 AIC · ⊞ 8.3K ·
Comment /souschef to run again

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sighthound] Security findings in github/gh-aw

4 participants