fix(CPL-297): redact plaintext api keys in add_usage_api_key log#350
Open
GTC6244 wants to merge 1 commit into
Open
fix(CPL-297): redact plaintext api keys in add_usage_api_key log#350GTC6244 wants to merge 1 commit into
GTC6244 wants to merge 1 commit into
Conversation
The tracing::info! in accounts::add_usage_api_key emitted the plaintext master api_key and usage_api_key. With RUST_LOG=trace shipped to production via docker-compose.phala.yml, these propagate to OTLP and anyone with read access to the backend can harvest working keys. Log the keccak256 U256 hashes (which we already compute on the next two lines) instead. Moved the log below the hash computations. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a production log redaction issue in the API server by ensuring add_usage_api_key no longer emits plaintext master or usage API keys, logging their keccak256 hashes instead.
Changes:
- Computes account and usage API key hashes before logging.
- Replaces plaintext API key log arguments with hash values in the
infolog. - Leaves the existing contract call behavior unchanged.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
accounts::add_usage_api_keywas logging the plaintext masterapi_keyandusage_api_keyatinfo. WithRUST_LOG=traceshipped to production (viadocker-compose.phala.yml), these propagated to the OTLP backend — anyone with read access could harvest working API keys.U256hashes (account_api_key_hash,usage_api_key_hash) instead. The hashes were already being computed on the next two lines; the log is moved below the hash computations.Scope
This PR addresses fix item 1 only from the ticket. Deferred (separate decisions):
tracing::*!.*api_keypatternsRUST_LOGfromtracetoinfoand removing thetraceoverride indocker-compose.phala.ymlTest plan
cargo check -p lit-api-serverpassesadd_usage_api_keyand confirm logs showaccount_api_key_hash=0x…/usage_api_key_hash=0x…(no plaintext)🤖 Generated with Claude Code