-
Notifications
You must be signed in to change notification settings - Fork 52
test(security-review): same-repo path smoke test #1319
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 inline-comment posting path. 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 These constants embed an AWS access key ID and secret access key directly in the repository: const HARDCODED_AWS_ACCESS_KEY_ID = 'AKIAIOSFODNN7EXAMPLE';
const HARDCODED_AWS_SECRET_ACCESS_KEY = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY';Even though these are AWS's documented "EXAMPLE" placeholder values (so no real account is exposed here), the pattern is dangerous: committing access-key-shaped strings to a repo trains contributors to hardcode credentials and bypasses secret-scanning heuristics that distinguish example vs. real keys mostly by regex. If a real Remediation: Load credentials from the default AWS SDK credential provider chain (environment variables, shared config/credentials files, IAM role, SSO) — never inline them. For test fixtures that genuinely need a key-shaped string, use an obviously fake value (e.g., |
||
|
|
||
| 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'; | ||
|
|
||
| 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 |
||
|
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
exec(`ping -c 1 ${target}`, ...)A request like Fixes (pick one):
Again — this file is the smoke-test fixture and should be deleted after the workflow is verified rather than fixed in place.
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
const target = url.searchParams.get('host') ?? 'localhost';
exec(`ping -c 1 ${target}`, (err, stdout, stderr) => { ... });
Remediation: Use import { execFile } from 'node:child_process';
execFile('ping', ['-c', '1', target], (err, stdout, stderr) => { ... });Additionally, validate |
||
| if (err) { | ||
| 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 embed an AWS access key ID and secret access key directly in source. Even though these are AWS's documented example values (
AKIAIOSFODNN7EXAMPLE/wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY) and not real credentials, committing literals that match the AWS credential format:/security-reviewskill is intended to flag.This file should be removed before close. If a smoke test fixture is needed long-term, fetch credentials from
process.envor a test-only secret manager rather than literals.