Skip to content

fix(tee): exclude the operator token from the gateway measurement - #768

Merged
imran-siddique merged 1 commit into
agentrust-io:mainfrom
Yatsuiii:fix/measure-exclude-operator-token
Oct 17, 2026
Merged

imran-siddique merged 1 commit into
agentrust-io:mainfrom
Yatsuiii:fix/measure-exclude-operator-token

Conversation

@Yatsuiii

Copy link
Copy Markdown
Contributor

What

CMCP_OPERATOR_TOKEN is no longer part of the measured configuration. _CONFIG_SECRET_KEYS in tee/measurement.py now holds bearer_token and operator_token.

Why

This is the precondition named in the #462 design comment, sent on its own first.

operator_token was added to Config in #629 without being added to _CONFIG_SECRET_KEYS, so since v0.6.0 it has fed the config component of the gateway measurement. Rotating the operator credential changes the gateway digest. With the real load_config and gateway_measurement over examples/bfsi-demo, two operator tokens give config components 8c9e31da... and de8e9475... on main, and different gateway digests. On this branch both are identical.

That is out of line with docs/spec/tpm-security-model.md, which says the resolved configuration is measured with secrets excluded. It also means a verifier that recomputes the expected digest, as attestation.md section 3.3.2 describes, needs the production operator token to do it. For #462, a sealed key would refuse to unseal after every token rotation.

Refs #462.

Security impact

  • The digest of the operator token no longer reaches the measurement index, the certify envelope components, the SEV-SNP and TDX report nonce, or the startup and reload logs. Before, a deployment with a low-entropy operator token exposed an offline guessing oracle for it, which is the reason bearer_token is excluded. The changelog entry, under Security, tells such deployments to rotate the token after upgrading.
  • The config digest changes once for every deployment on upgrade, including those without an operator token, since the payload carried "operator_token": null. A verifier pinning expected_gateway_measurement recomputes it on upgrade, as it already must on any release that changes the code digest. The v1 prefix is unchanged, as it was when feat(session): implement the monotonic session boundary the spec describes #629 added session_state_path and operator_token to the payload.
  • Unchanged: in dev mode, whether an operator token is set is not measured, the same as the bearer token. Production refuses to start without one.

Test plan

  • pytest passes: 2548 passed, 37 skipped, on a host with no TPM visible to the tests, as on a CI runner
  • ruff check src/ tests/ passes
  • mypy src/cmcp_runtime/ passes
  • Manual test performed

New tests in tests/unit/test_gateway_measurement.py, both against the real Config:

  • test_every_credential_field_of_the_real_config_is_excluded: every field of Config and its nested config dataclasses whose name ends in token, secret, password or api_key must be in the exclusion set, so the next credential field cannot be missed the way this one was. Fails on main.
  • test_config_digest_ignores_each_excluded_field_of_the_real_config, parametrized over the exclusion set: setting or rotating each field leaves the digest unchanged.

Manual: the load_config and gateway_measurement comparison above, run on main and on this branch with the same two operator tokens.

DCO sign-off

_CONFIG_SECRET_KEYS held only bearer_token, so CMCP_OPERATOR_TOKEN fed the
configuration digest. Rotating the operator credential changed the gateway
digest, a digest over the secret reached the measurement index and the report
nonce, and a verifier recomputing an expected digest needed the production
token. The spec already says the configuration is measured with secrets
excluded.

Add operator_token to the exclusion set. Test that setting or rotating each
excluded field of the real Config leaves the digest unchanged, and guard that
every credential-named field of Config, nested ones included, is in the set so
the next one cannot be missed.

Signed-off-by: Yatsuiii <battyrises@gmail.com>
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Contributor Check: MEDIUM

Check Result
Profile MEDIUM
Credential LOW
Overall MEDIUM

Automated check by AgenTrust Contributor Check.

@github-actions github-actions Bot added the needs-review:MEDIUM Contributor check flagged MEDIUM risk label Oct 16, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@rajnisht7 rajnisht7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the changes looks good, operator_token was correctly missing from _CONFIG_SECRET_KEYS since #629, rotating it was changing the gateway digest, which shouldn't happen, and the new tests properly guard against the same miss happening again with future credential fields. Matches the security model.

@dinakarjs dinakarjs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Independent approval of the bounded measurement correction at ffcb490. No blocking defect found in this three-file change. It excludes operator_token alongside bearer_token; it does not implement TPM sealing or establish hardware resistance.

Linux/Python 3.12 with imports resolving to this checkout: measurement module 45 passed; full unit/conformance selection 2,450 passed, 6 skipped. The first broad run had 9 transport/soak failures from inherited SOCKS proxy settings; the complete rerun with proxy variables unset passed. Ruff passes on the changed Python files and mypy passes measurement.py. Diff whitespace passes. No native TPM operations were performed.

Independent real-Config controls: None, empty, synthetic-A and synthetic-B values for each excluded token yield the same config digest; both names are absent from the reduced payload. Changing dev_mode, listen_addr, policy_bundle_path or catalog_path changes the digest, preserving non-secret configuration sensitivity.

Load-bearing control: temporarily remove only operator_token from the exclusion set. The measurement suite fails its credential-inventory regression (1 failed, 43 passed); a separate Config(operator_token='a') versus Config(operator_token='b') digest-equality assertion also fails. Restored source returns 45/45, clean worktree. The parametrized rotation test enumerates the exclusion set, so that separate inventory test is essential when a credential is accidentally omitted.

The changelog appropriately describes a one-time digest transition and rotation advice. The field-name heuristic catches the documented usual credential spellings; it is not exhaustive secret discovery. Approval applies to source behavior and these software controls, not #462 sealing, live attestation or the wider hardware acceptance tracker.

@imran-siddique imran-siddique left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checked ffcb490. On main, config_digest(Config(operator_token="a")) and "b" differ, and on this head they match, so rotating the operator token no longer moves the gateway measurement or the report nonce. The measurement tests pass 45 of 45; dropping operator_token from _CONFIG_SECRET_KEYS fails the credential-name test. The one-time digest change on upgrade is in the changelog, which is what a verifier pinning expected_gateway_measurement needs.

tee/ is a security path, so this needs a second approval. @rajnisht7, could you review it by Monday 19 October?

@rajnisht7

Copy link
Copy Markdown
Member

@imran-siddique already approved this head earlier today. Re-ran the gate job and it’s green now

@imran-siddique
imran-siddique merged commit f500651 into agentrust-io:main Oct 17, 2026
20 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:MEDIUM Contributor check flagged MEDIUM risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants