Skip to content

fix(CPL-297): redact plaintext api keys in add_usage_api_key log#350

Open
GTC6244 wants to merge 1 commit into
nextfrom
feature/cpl-297-high-add_usage_api_key-logs-plaintext-master-usage-api_keys
Open

fix(CPL-297): redact plaintext api keys in add_usage_api_key log#350
GTC6244 wants to merge 1 commit into
nextfrom
feature/cpl-297-high-add_usage_api_key-logs-plaintext-master-usage-api_keys

Conversation

@GTC6244
Copy link
Copy Markdown
Contributor

@GTC6244 GTC6244 commented May 18, 2026

Summary

  • accounts::add_usage_api_key was logging the plaintext master api_key and usage_api_key at info. With RUST_LOG=trace shipped to production (via docker-compose.phala.yml), these propagated to the OTLP backend — anyone with read access could harvest working API keys.
  • Log the keccak256 U256 hashes (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.
  • Linear: CPL-297

Scope

This PR addresses fix item 1 only from the ticket. Deferred (separate decisions):

  • Item 2: CI lint to flag tracing::*!.*api_key patterns
  • Item 3: lowering default RUST_LOG from trace to info and removing the trace override in docker-compose.phala.yml
  • Items 4–5: operational (key rotation during leak window, customer notification)

Test plan

  • cargo check -p lit-api-server passes
  • CI green
  • Manual: invoke add_usage_api_key and confirm logs show account_api_key_hash=0x… / usage_api_key_hash=0x… (no plaintext)

🤖 Generated with Claude Code

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>
@GTC6244 GTC6244 requested review from a team and Copilot May 18, 2026 15:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 info log.
  • Leaves the existing contract call behavior unchanged.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants