Clarify Bedrock credential change detection#3522
Closed
jbeckwith-oai wants to merge 1 commit into
Closed
Conversation
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
Why
GitHub code-scanning alert #1 reports
py/weak-sensitive-data-hashingbecause CodeQL classifies the Bedrockapi_keyas password-like data flowing into BLAKE2s.This is a false positive rather than weak password storage: the digest is never used to enroll or verify a password, and it is not persisted, transmitted, logged, or exposed. It is compared only inside
_refresh_legacy_provider_runtimeto detect whether a legacy client's credential changed and its provider must be rebuilt. The previous keyed BLAKE2s construction was already protected by a fresh 32-byte process key.The change expresses the same security intent as a MAC instead of disabling a useful CodeQL query. The bearer credential is the HMAC key and the process-random nonce is the message, which keeps the credential out of CodeQL's password-hash input while retaining an opaque, deterministic identity for the lifetime of the process.
Why this does not change Bedrock access
The raw bearer credential still passes unchanged to
bedrock(api_key=credential)and ultimately to the request Authorization header. The HMAC is used only by_LegacyRuntimeSignaturefor internal equality checks. AWS credential mode and token-provider mode do not take this string-HMAC path.Within one process, the same bearer credential and nonce produce the same identity; changing the bearer credential produces a different identity and triggers the existing provider refresh path. This preserves credential mutation, request authentication, and client-copy behavior.
Tests
No test source needed to change because the externally observable behavior and security invariants already have focused coverage:
test_legacy_api_key_mutation_updates_requests_and_copiesverifies that credential changes rebuild the provider, copies retain the correct credential, and requests carry the expected raw bearer token.test_legacy_state_repr_does_not_expose_credentialsverifies that the internal runtime signature does not reveal the bearer credential.The regression itself is CodeQL's static source-to-sink classification, which is best validated by the PR's CodeQL run rather than by an implementation-coupled runtime unit test.
Validation performed locally:
No live AWS Bedrock request was made; the PR's CodeQL job provides the final scanner confirmation.