Skip to content

feat: add Amazon Bedrock API key detection#1935

Merged
zricethezav merged 1 commit into
gitleaks:masterfrom
dboyd13:master
Sep 25, 2025
Merged

feat: add Amazon Bedrock API key detection#1935
zricethezav merged 1 commit into
gitleaks:masterfrom
dboyd13:master

Conversation

@dboyd13
Copy link
Copy Markdown
Contributor

@dboyd13 dboyd13 commented Aug 25, 2025

Description:

Add secret detection of Amazon Bedrock API Keys

  • Long-lived via ABSK[A-Za-z0-9+/]{109,269}={0,2}
  • Short-lived via bedrock-api-key-YmVkcm9jay5hbWF6b25hd3MuY29t

Checklist:

  • Does your PR pass tests?
  • Have you written new tests for your changes?
  • Have you lint your code locally prior to submission?

@dboyd13
Copy link
Copy Markdown
Contributor Author

dboyd13 commented Sep 18, 2025

Checking in on this PR. Any input needed?

FYI the equivalent PR has now been merged in git-secrets awslabs/git-secrets#264

r := config.Rule{
RuleID: "aws-amazon-bedrock-api-key-short-lived",
Description: "Identified a pattern that may indicate short-lived Amazon Bedrock API keys, risking unauthorized Amazon Bedrock usage",
Regex: regexp.MustCompile(`bedrock-api-key-YmVkcm9jay5hbWF6b25hd3MuY29t`),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dboyd13 sorry for the radio silence and thank you for opening this PR! Quick question: is this (YmVkcm9jay5hbWF6b25hd3MuY29t) meant to be hardcoded?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the keys seem to have bedrock.amazonaws.com/ base64-encoded, in addition to the bedrock-api-key- prefix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the constant prefix is plaintext bedrock-api-key- and YmVkcm9jay5hbWF6b25hd3MuY29t Base64 value which decodes to bedrock.amazonaws.com. This is included in the proposed RegEx to reduce false positives.

@zricethezav
Copy link
Copy Markdown
Collaborator

Great addition, thanks @dboyd13!

@zricethezav zricethezav merged commit 87d9629 into gitleaks:master Sep 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants