-
Notifications
You must be signed in to change notification settings - Fork 52
test(security-review): smoke-test inline comment posting (delete after verify) #1294
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,36 @@ | ||||||||||||||||||||||||||||
| // Deliberately vulnerable file used to smoke-test the Claude Security Review | ||||||||||||||||||||||||||||
| // workflow's inline-comment posting path. Will be reverted once we confirm | ||||||||||||||||||||||||||||
| // the bot files inline review comments correctly. | ||||||||||||||||||||||||||||
| import { exec } from 'node:child_process'; | ||||||||||||||||||||||||||||
| import http from 'node:http'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // FINDING 1 (hardcoded credential): AWS-shaped access key checked into source. | ||||||||||||||||||||||||||||
| 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. Severity: HIGH AWS-shaped access key ID and secret access key are hardcoded as module-level constants and consumed by Exploit scenario: A developer copies this pattern and substitutes a real Recommendation: Remove the hardcoded values. Load AWS credentials from the standard credential chain (env vars, |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 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): builds a shell command from an HTTP query | ||||||||||||||||||||||||||||
| // string parameter and passes it to exec(). Concrete OS-command injection. | ||||||||||||||||||||||||||||
| 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. OS command injection via
If this code were ever intended to ship, the fix would be one of:
But per the PR description this file is a smoke-test artifact and should be removed before merge. |
||||||||||||||||||||||||||||
| if (err) { | ||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+26
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. Severity: HIGH The HTTP handler reads the Exploit scenario: An attacker sends Recommendation: Do not build shell strings from untrusted input. Use
Suggested change
|
||||||||||||||||||||||||||||
| 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.
Hardcoded AWS credentials (intended finding 1).
Lines 8–9 commit AWS-shaped access key material directly into source. Even though these are the well-known
AKIAIOSFODNN7EXAMPLE/wJalrXUtnFEMI...EXAMPLEKEYdocumentation values (so no real account is exposed), the pattern is exactly what secret scanners andgit-secretsflag, and merging it would create noise for downstream tooling and a bad template for copy/paste. Confirming the file is reverted/closed before merge.(Confirming Claude Security Review's inline-comment path is functioning by posting this comment on a PR-context event.)