Skip to content

Commit Cargo.lock; constant-time API-key lookup - #1

Merged
domsteil merged 1 commit into
mainfrom
fix/lockfile-and-const-time-apikey
Jun 14, 2026
Merged

Commit Cargo.lock; constant-time API-key lookup#1
domsteil merged 1 commit into
mainfrom
fix/lockfile-and-const-time-apikey

Conversation

@domsteil

Copy link
Copy Markdown
Contributor

Two hardening fixes from a code review of the handler.

1. Track Cargo.lock

This crate ships binaries (stateset-icp-handler, icp-conformance, icp-mcp-stdio), so the lockfile belongs in version control for reproducible CI/Docker builds. The pinned stateset-embedded rev fixed direct deps, but transitive deps floated — which contradicted the "keeps CI/Docker builds reproducible" note in Cargo.toml. Removed Cargo.lock from .gitignore and committed the resolved tree.

2. Constant-time API-key lookup

ApiKeyStore::lookup used HashMap::get, making request latency a (weak) comparison oracle for the bearer token. Replaced it with a no-early-exit constant-time comparison over all stored keys, mirroring the existing webhook HMAC check (webhook::signing::constant_time_eq) for defense-in-depth. Keys are high-entropy, so impact was low, but this removes the oracle entirely and keeps the auth path consistent with the webhook path.

Verification

  • cargo build
  • cargo clippy -D warnings ✅ (clean)
  • cargo test --test auth_enforcement ✅ (5 passed)
  • cargo test --test integration ✅ (31 passed)

🤖 Generated with Claude Code

Two hardening fixes surfaced during a code review:

- Track Cargo.lock. This crate ships binaries (stateset-icp-handler,
  icp-conformance, icp-mcp-stdio), so the lockfile belongs in version
  control for reproducible CI/Docker builds. The pinned stateset-embedded
  rev fixed direct deps, but transitive deps floated -- contradicting the
  reproducibility note in Cargo.toml.

- Replace HashMap::get in ApiKeyStore::lookup with a no-early-exit
  constant-time comparison over all stored keys, so request latency is not
  a comparison oracle for the bearer token. Mirrors the existing webhook
  HMAC check (webhook::signing::constant_time_eq) for defense-in-depth.

Build, clippy (-D warnings), auth_enforcement, and integration suites pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@domsteil
domsteil merged commit 8f78828 into main Jun 14, 2026
1 of 5 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.

1 participant