Repository navigation
aws-access-key-id misses a key followed by "; in minified JS and in source maps #11526
Closed
venkatesh-cstk
started this conversation in
False Detection
Replies: 1 comment
|
Hello @venkatesh-cstk Thank you for your report, and apologies for the delayed response. I've created an issue for this task: #11629. Regards, Dmitriy |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
IDs
aws-access-key-id
Description
The built-in
aws-access-key-idrule requires whitespace or the end of the input after the key. Between the key and that whitespace it allows only an optional quote and an optional.or,:So a key is missed whenever any other character follows its closing quote. That covers a lot of real code:
const value = "AKIA…";VITE_…orNEXT_PUBLIC_…:{accessKeyId:"AKIA…"},"AKIA…",x,e="AKIA…";sourcesContentJSON-escapes the quote:\"AKIA…\"The same key is found when a newline follows it:
AWS_ACCESS_KEY_ID=AKIA…oraccessKeyId: "AKIA…",. Other rules don't have this problem.github-patandjwt-tokenare found in the same minified placements, because their regexes don't need trailing whitespace.Suggested fix: bound the key on both sides with
\binstead ofquote + endSecret:The 4-character prefix and the 16 upper-case letters and digits are what make the match specific; the whitespace adds nothing.
\bis better thanMustCompileWithBoundaries. ItsendWordgroup consumes the character after the key, so with two keys one character apart ("K1,K2") only the first is found.\bconsumes nothing. Wherever the current rule matches,\breturns the samesecretspan.Side effect to consider: a broader rule also matches the signer's key ID inside SigV4 presigned URLs, POST policies and
Authorizationheaders. Examples:X-Amz-Credential=AKIA…%2F20261102%2Fus-east-1%2Fs3%2Faws4_requestandCredential=AKIA…/20261102/…. Pages that link private S3 objects publish these on purpose. A narrow allow/exclude on a key followed by its credential scope's date avoids that false positive:AKIA…(%2F|/)[0-9]{8}(%2F|/). Only a signer writes that literal date; code that signs a request computes it at run time.Workaround in the meantime: a custom rule in
trivy-secret.yamlwith the same ID, the regex above, and the built-in's title, category, severity and keywords.deduplicateFindingscollapses a key both rules match into one finding, because they share rule ID, line and offset. You can't override a built-in rule in place:disable-rulesis applied after custom rules are appended, so it would remove the custom rule too.Related:
aws-secret-access-keyalso ends inendSecret, so it likely has the same gap. An example is{AWS_SECRET_ACCESS_KEY:"…"}in minified code.Reproduction Steps
Target
Filesystem
Scanner
Secret
Target OS
No response
Debug Output
Version
The same result appears on 0.75.0.
Checklist
-f jsonthat shows data sources and confirmed that the security advisory in data sources was correct. The secret scanner has no advisory data source, so this only confirmed the rule ID in the JSON.All reactions