fix: address top-5 high-severity Sighthound security findings - #48824
Conversation
…e positives) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Hardens workflow tooling against path traversal and URL injection while documenting two security false positives.
Changes:
- Adds path normalization for Go and JavaScript filesystem operations.
- Validates repository and ref URL components.
- Documents safe template and plain-text writer usage.
Show a summary per file
| File | Description |
|---|---|
pkg/cli/download_workflow.go |
Validates sparse-checkout paths. |
scripts/generate-agent-factory.js |
Constrains generated paths to filenames. |
scripts/ensure-docs-slide-pdf.js |
Adds outbound URL component validation. |
pkg/cli/bootstrap_profile_helpers.go |
Documents static template safety. |
pkg/cli/logs_format_compact.go |
Clarifies the writer contract. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 3
- Review effort level: Medium
| if filepath.IsAbs(cleanedPath) || strings.HasPrefix(cleanedPath, ".."+string(filepath.Separator)) || cleanedPath == ".." { | ||
| return nil, fmt.Errorf("unsafe path in workflow reference: %q", path) | ||
| } | ||
| path = cleanedPath |
| // A SHA is 40 hex characters; branch/tag names may contain alphanumerics, | ||
| // hyphens, underscores, dots, and forward-slashes (for namespaced refs). | ||
| const safeRefPattern = /^[a-zA-Z0-9_.\-/]+$/; | ||
| if (!safeRefPattern.test(ref)) { |
| const safeRepoPattern = /^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/; | ||
| if (!safeRepoPattern.test(repositoryPath)) { |
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed all three review points in commit
|
|
Thanks
|
|
🎉 This pull request is included in a new release. Release: |
Sighthound flagged path traversal, SSRF, and two false positives (XSS, SSTI) across Go and JS sources. This PR applies targeted remediations and documents the false positives.
Path traversal —
pkg/cli/download_workflow.goValidate and clean the
pathparameter at the top ofdownloadWorkflowContentViaGitClonebefore it is written into the git sparse-checkout config or joined with the temp directory:Path traversal —
scripts/generate-agent-factory.jsAdd
path.basename()guards when constructing paths from filenames to strip any unexpected directory components:SSRF —
scripts/ensure-docs-slide-pdf.jsValidate
repositoryPathandrefagainst allowlist patterns before interpolating into the outbound fetch URL. The target domain is already hardcoded tomedia.githubusercontent.com; this blocks path-injection via crafted env vars or git remote URLs:False positives —
bootstrap_profile_helpers.go+logs_format_compact.gobootstrap_profile_helpers.go:258): template source is a package-levelconst;html/templateauto-escapes all data values. Added// #nosec G203with explanatory comment.logs_format_compact.go:193):wis alwaysos.Stdoutor a test buffer, never an HTTP response. Added a doc comment clarifying the writer contract.