Fix --publish scan token authentication#42
Merged
thebenignhacker merged 2 commits intomainfrom Mar 12, 2026
Merged
Conversation
The publishScanResults() function was posting to the community scan-result endpoint without first requesting a scan token. The registry requires an X-Scan-Token header on all community submissions, causing every --publish attempt to fail with AUTH_TOKEN_MISSING. Now calls requestScanToken() before reportPublishResult() and passes the token through to the request headers.
Tests now mock the scan token request (first fetch call) separately from the publish request (second call), matching the new two-step flow in publishScanResults().
There was a problem hiding this comment.
Claude Code Review
VERDICT: APPROVE
SUMMARY: This PR fixes the --publish flag authentication by implementing a two-step flow: requesting a scan token via requestScanToken(), then submitting the scan with the token in the X-Scan-Token header. The changes are security-positive — they add proper authentication to the publish flow. All modifications are to the publish flow and test code, with no introduction of command injection, path traversal, prototype pollution, or other security vulnerabilities. The scanToken parameter is safely passed through method signatures and set as an HTTP header without shell interpolation or eval.
FINDINGS:
(none)
Verification notes:
- Command injection: No use of
child_processor shell commands in changed code. - Prototype pollution:
scanTokenparameter is a simple string passed through typed interfaces; no object merge/spread on untrusted input. - Path traversal: No file system operations in the diff.
- SSRF: The
registryUrlis configured at initialization time (line 302, 277 in publish.ts), not derived from user input in this PR. The token request endpoint is a static path appended to the configured base URL (line 143 in client.ts). - Unsafe header injection: The
scanTokenvalue is set directly asheaders['X-Scan-Token'] = scanToken(lines 200, 284). While this could theoretically allow header injection ifscanTokencontained CRLF sequences, the value comes fromtokenResponse?.scanToken(line 309), which is parsed from the registry's JSON response (line 175). The registry is the trusted source, and JSON parsing does not introduce newlines into string values. Additionally, modernfetchimplementations sanitize headers to prevent CRLF injection. - Test coverage: Tests verify both the token request step and the presence of the
X-Scan-Tokenheader in the publish request (publish.test.ts lines 460-477, 493).
Reviewed 3 files changed (4827 bytes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--publishflag onsecure/attackcommands failing withAUTH_TOKEN_MISSINGpublishScanResults()now callsrequestScanToken()before submitting to the registryX-Scan-Tokenheader on all community scan submissionsTest plan
--no-registry --publishstill correctly skips both token request and publish