Why scanners flag the published examples#
AWS documentation reuses one access key pair across many examples. Its access key ID is 20 characters, starts with AKIA and ends in EXAMPLE (shortened here to AKIA...EXAMPLE); its secret access key is 40 characters ending in EXAMPLEKEY (wJal...EXAMPLEKEY). The AWS CLI example for configure mfa-login at 2.42.3 shows the pair typed at the credential prompts, under the sentence "The following mfa-login example prompts you for your AWS credentials first if you don't have a default profile configured." The same ID appears 49 times across 35 files under awscli/examples at that tag.
A format rule cannot tell the example from a real key. The prefix is the one the IAM unique-ID table lists for "Access key" (AKIA), and the length and alphabet match. detect-secrets 1.5.0's AWSKeyDetector matches (?:A3T[A-Z0-9]|ABIA|ACCA|AKIA|ASIA)[0-9A-Z]{16} with no exception (aws.py at v1.5.0). gitleaks' default aws-access-token rule carries an allowlist entry for .+EXAMPLE$ (gitleaks.toml at v8.21.2), so the two tools disagree about the same line.
A scan with two findings#
This constructed repository has a setup page that reproduces the aws configure prompts with the published pair, and a test environment file. The test file's ID was replaced with the example ID in its second commit; its secret was generated locally for the fixture and never issued by AWS. With detect-secrets 1.5.0 and gitleaks built from v8.21.2:
$ detect-secrets scan --all-files . > baseline.json
docs/setup.md:5 AWS Access Key 25910f981e85...
tests/integration.env:2 AWS Access Key 03cc5aba183b...
tests/integration.env:2 Base64 High Entropy String 03cc5aba183b...
tests/integration.env:2 Secret Keyword 03cc5aba183b...
$ gitleaks dir --no-banner .
INF no leaks found
(The detect-secrets lines are printed from baseline.json by a short script; the last column is the start of each result's hashed_secret.) gitleaks reports nothing. detect-secrets reports the ID line in the docs and the secret line in the test file, and three plugins agree on the secret.
Match the finding against the published value#
The baseline does not store the flagged value, but hashed_secret is its SHA-1, so you can check a finding against the published example without copying any value into the ticket:
$ printf '%s' 'AKIA...EXAMPLE' | sha1sum | cut -c1-12
25910f981e85
$ printf '%s' 'wJal...EXAMPLEKEY' | sha1sum | cut -c1-12
d70eab08607a
$ sed -n 6p docs/setup.md | awk '{print $NF}' | tr -d '\n' | sha1sum | cut -c1-12
d70eab08607a
(The first two commands ran with the full published strings, shortened here.) The docs/setup.md:5 finding has hash 25910f981e85..., the published ID. detect-secrets did not report the secret on line 6, but its hash is the published secret's, so the docs hold the example pair exactly. Both halves are the example, so dismiss the finding and record the file that publishes them, awscli/examples/configure/mfa-login.rst at tag 2.42.3.
Match the exact string, not its shape. The CLI examples at 2.42.3 spell the published secret two ways:
$ grep -rhoE 'wJalrX.{24,25}EXAMPLEKEY' awscli/examples | awk '{print length($0)}' | sort | uniq -c
11 40
3 41
The 41-character spelling, with one extra character before EXAMPLEKEY, is the one in create-access-key.rst, get-session-token.rst and assume-role-with-web-identity.rst. An allowlist built from memory, or from one page, misses the other spelling. One built on "ends in EXAMPLE" also passes any value someone edited to end that way.
When the example ID hides a real secret#
The tests/integration.env:2 finding is the disconfirmation. Its line 1 holds the example ID, which detect-secrets did not report there and which gitleaks' allowlist accepts. A reviewer who sees AKIA...EXAMPLE at the top of the file would dismiss the whole file. But the secret's hash is 03cc5aba183b..., not d70eab08607a..., so the secret is not the published one, and the example ID beside it says nothing about the secret. History shows what happened:
$ git log -p --format='%h %s' -- tests/integration.env
727bf94 Use example key in integration env
-AWS_ACCESS_KEY_ID=AKIA...(generated)
+AWS_ACCESS_KEY_ID=AKIA...EXAMPLE
AWS_SECRET_ACCESS_KEY=3Hua...fhva
beb7c0f Add setup docs and integration env
+AWS_ACCESS_KEY_ID=AKIA...(generated)
+AWS_SECRET_ACCESS_KEY=3Hua...fhva
(Values shortened; diff headers trimmed.) Someone replaced the ID with the example and left the secret. The original pair is still in commit beb7c0f, and a history scan finds it even though the file scan found nothing:
$ gitleaks git --no-banner --no-color -v --redact=80 .
Finding: AKIA...
RuleID: aws-access-token
File: tests/integration.env
Line: 1
Commit: beb7c0f815dcc77b6d90eeffb5e78d5dd617a4e2
INF 2 commits scanned.
WRN leaks found: 1
In a real repository that pair is a leaked access key: deactivate it in IAM, replace it, and only then clean the file. Editing the ID to the example makes a file look like documentation, but it leaves the secret and the history behind.
The same check applies to the other half. A published example ID next to a published example secret is documentation. A published ID next to an unpublished secret, an unpublished AKIA ID next to the published secret, or a session token beside an ASIA ID (which the IAM table says "use this prefix, but are unique only in combination with the secret access key and the session token") each need the evidence for a real credential: who issued it, whether it is active, and what it did.
Decide from the published file#
| What the finding says | Evidence to collect | Decision |
|---|---|---|
| ID matches the vendor's example | hashed_secret or the value equals the ID in a published file at a tag | Dismiss the ID; record the file and tag |
| Secret beside an example ID | Whether the secret equals a published spelling, character for character | Dismiss only if it does; otherwise treat it as a real secret |
| Example ID, unpublished secret | git log -p for the file, history scan for the replaced ID | Deactivate the original key, then clean the file and history |
Value ends in EXAMPLE but is in no published file | Search the vendor's published examples for the exact string | Treat as real until a published source is found |
| Tool allowlists the example and reports nothing | A second tool or a history scan | Confirm the secret line was checked before closing |
For a flagged value that matches no published example and no provider format, the high-entropy string guide covers how to tell a credential from a hash or an identifier. When an automated reviewer rather than a scanner raised the comment, the guide to hardcoded-secret review comments covers the evidence that reply needs.