-
Notifications
You must be signed in to change notification settings - Fork 47
test(security-review): fork PR path smoke test #1320
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Deliberately vulnerable file used to smoke-test the Claude Security Review | ||
| // workflow's safe-to-review label path on fork PRs. Two HIGH-severity findings | ||
| // the bundled /security-review skill should flag. Will be deleted after verify. | ||
| import { exec } from 'node:child_process'; | ||
| import http from 'node:http'; | ||
|
|
||
| // FINDING 1 — Hardcoded credential pattern. | ||
| const HARDCODED_AWS_ACCESS_KEY_ID = 'AKIAIOSFODNN7EXAMPLE'; | ||
| const HARDCODED_AWS_SECRET_ACCESS_KEY = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'; | ||
|
Comment on lines
+8
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIGH: Hardcoded AWS credentials in source code. Embedding an AWS access key ID and secret access key as string literals is a credential-leak vulnerability. Even though these specific values are AWS's well-known documentation example (
Resolve credentials at runtime from the AWS SDK's default credential provider chain (env vars, shared config, IMDS, container role, SSO, etc.) instead of hardcoding them. If a fixture genuinely needs a placeholder, read it from |
||
|
|
||
| function buildSignedRequest(payload) { | ||
| return { | ||
| payload, | ||
| auth: `AWS4-HMAC-SHA256 Credential=${HARDCODED_AWS_ACCESS_KEY_ID}`, | ||
| secret: HARDCODED_AWS_SECRET_ACCESS_KEY, | ||
| }; | ||
| } | ||
|
|
||
| // FINDING 2 — Command injection via exec() with unvalidated query parameter. | ||
| const server = http.createServer((req, res) => { | ||
| const url = new URL(req.url, 'http://localhost'); | ||
| const target = url.searchParams.get('host') ?? 'localhost'; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIGH — Command injection via
If this code is ever actually executed — e.g. someone runs Options to resolve:
|
||
| exec(`ping -c 1 ${target}`, (err, stdout, stderr) => { | ||
Check failureCode scanning / CodeQL Uncontrolled command line Critical
This command line depends on a
user-provided value Error loading related location Loading |
||
|
|
||
| if (err) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIGH: Command injection via unvalidated
Each of these breaks out of the intended Fix by either:
Never interpolate untrusted input into a shell command string. |
||
| res.writeHead(500); | ||
| res.end(String(err)); | ||
| return; | ||
| } | ||
| res.writeHead(200, { 'Content-Type': 'text/plain' }); | ||
| res.end(stdout || stderr); | ||
| }); | ||
| }); | ||
|
|
||
| export { buildSignedRequest, server }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HIGH — Hardcoded AWS credentials.
Lines 8–9 hardcode an AWS access key ID and secret access key as string literals. Even though these are the well-known AWS documentation example values (
AKIAIOSFODNN7EXAMPLE/wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY) and not real credentials, committing strings that match the AWS credential format will:Options to resolve:
process.env(e.g.process.env.TEST_AWS_ACCESS_KEY_ID) rather than hardcoding string literals, or split the literal so it doesn't match theAKIA[0-9A-Z]{16}regex (e.g.'AKIA' + 'IOSFODNN7EXAMPLE') and add a comment explaining why..gitleaksignore/ secret-scanning allowlist with a clear justification.