Skip to content

UID2-6717: validate operator key against core service before enclave startup#2477

Open
sunnywu wants to merge 2 commits intomainfrom
swi-UID2-6717-operator-key-preflight-validation
Open

UID2-6717: validate operator key against core service before enclave startup#2477
sunnywu wants to merge 2 commits intomainfrom
swi-UID2-6717-operator-key-preflight-validation

Conversation

@sunnywu
Copy link
Copy Markdown
Contributor

@sunnywu sunnywu commented Apr 2, 2026

Summary

  • Adds OperatorKeyRejectedError (E07) to confidential_compute.py — a new startup error class for when the core service explicitly rejects the operator key.
  • Adds validate_operator_key_with_service() called at the end of validate_configuration(), after the existing connectivity check. It POSTs to {core_base_url}/attest with Authorization: Bearer {operator_key} and no attestation payload. The core service authenticates the key before touching the payload, so a 401 → invalid key / 400 → valid key distinction is reliable and stable.
  • Non-blocking on connection errors, timeouts, or unexpected HTTP status codes — startup is not gated on the pre-flight check failing for reasons unrelated to the key itself.
  • Adds unit tests in scripts/tests/test_confidential_compute.py covering all relevant code paths.

Background

Private operators can misconfigure their key by copying it incorrectly (e.g. I vs l). The existing validations (regex format + env alignment + network connectivity) pass for such keys; the failure only surfaces as AttestationFailure: invalid operator key inside the running enclave, which is hard to diagnose. See UID2-6717 and the originating Slack thread.

How it works

POST {core_base_url}/attest
Authorization: Bearer {operator_key}
Content-Type: application/json
{}
Response Meaning Action
401 Key unknown/rejected by auth middleware Raise E07: OperatorKeyRejectedError, abort startup
400 Key accepted, payload missing (expected) Log and continue
Other Unexpected — don't block startup Log warning and continue

Test plan

  • python3 -m pytest scripts/tests/test_confidential_compute.py -v — all 9 tests pass
  • Confirm E07 fires when an invalid key is used in a dev deployment
  • Confirm normal startup is unaffected with a valid key

🤖 Generated with Claude Code

sunnywu and others added 2 commits April 2, 2026 18:19
…startup

Adds a pre-flight POST to `{core_base_url}/attest` with the operator key in
the Authorization header. The core service returns 401 before inspecting the
attestation payload for any unrecognised key, so a 401 here unambiguously
means the key is wrong. Any other response (400 for missing payload, 5xx,
timeout) is logged and does not block startup, keeping the change safe to
roll out without new failure modes.

This catches subtle transcription errors (e.g. I vs l) that pass the existing
regex and environment-alignment checks but are rejected at attestation time,
saving operators from a confusing failure deep inside a running enclave.

Adds unit tests covering: 401 rejection, 400 pass-through, 200 pass-through,
connection error, timeout, unexpected exception, and endpoint URL/header
correctness.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…th_core_service

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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