feat(research): seal research results to the enrolled key and sign them #289
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.55) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.55 · 563 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.379
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #289"
general
weight: 0.35
abendrothj
What and why
Part of #177 (P55), following the split agreed with #176 on #177: this PR provides what #176's sealed handler (#275) calls once a query has run. Nothing routes to it yet; #275 wires it in.
ConnectorQueryService::verify_recipientaccepts a sealed request'srecipient_keyonly if it equals, by suite and bytes, the key enrolled for the researcher (ADR 0010 "Recipient key"): 400 for a malformed key, 403 with no enrolled key or a different one, 502 for an unreadable enrollment record. Each refusal is audited once asauth.decisionwith the key's fingerprint (SHA-256("recipient-key-v1" ‖ suite ‖ key)), never the key. It callssealed::verify_recipient(dev_build, vault, …), which runs the release-build gate, reads the enrollment record and compares the key in one call; the gate and the compare are private tosealed, so nothing in the crate can supply the enrolled key or skip the gate, and only this path builds aVerifiedRecipient.ConnectorQueryService::seal_research_resultseals the whole result (counts andbudget_remainingincluded) to that key underresearch_result(tid, research_query_binding(grant_id, request_nonce, sql, schema_version)), in the key's suite. It signs the frame with the key set's result-signing key and returns ADR 0010'sSealedQueryResponse, with the signature asSignatureWire. The payload is serialized byto_json_zeroizinginto an exactly sizedZeroizingbuffer, so no outgrown copy is freed unwiped, and wiped after sealing. #275'sto_vecof the stored response can use the same helper.verify_recipient, so #275's handler gets it by calling the recipient check.enrolled_keymoves intolib.rs, shared by the upload path's suite check and the recipient check.THREAT_MODEL.mddescribe the seal, the signature and the recipient check as built but not routed.THREAT_MODEL.mdrecords that sealed results depend on create-once enrollment (P33) and TLS inside the VM (P67), and that release builds answer 503 until P33.#275 also changes
sealed.rsandquery.rsand merges first; this PR then rebases onto it, renames one of the twosealed_research_apptest helpers, and keeps onerecipient_key400 check. Wiring these calls into the handler, and the "Retries" item in #177's done-when, land after both.How it was tested
sealed.rsunit tests:- a sealed result opens only with the intended key;
- a flipped byte anywhere in the frame is refused;
- a result signed by any other key set, or with a signature that does not decode, is refused;
- a result replayed against another request nonce, SQL text, grant or schema version is refused;
- the result
infocarries the role label and the researcher;- the recipient fingerprint layout is pinned;
- only the enrolled key is a recipient, and a malformed key is a 400;
- a release build gets 503 even for the enrolled key, and a dev build accepts the same request;
-
verify_recipientreads the enrolled key itself: another key is a 403, no record a 403, an unparseable record a 502;- results serialize into a buffer whose capacity equals its length;
-
Debugprints neither the bound SQL nor the recipient key.tests/sealed_result_api.rs:- a research result run through the query service is sealed to the enrolled key and signed, verifies against the key set from the evidence bundle, carries no result value in the clear, and does not open against a replayed request;
- a recipient key substituted in the enrollment record is refused.
audit_coverage.rs: each recipient refusal, including the release-build 503, is audited exactly once (count_outcome), with fingerprints only.scripts/check.shpasses locally.Checklist
scripts/check.shpasses locallySECURITY_AUDIT_EVENTcovered byaudit_coverage.rsdocs/DATA_POLICY.md)CHANGELOG.mdupdated for user-visible changesdocs/adr/if one was made (n/a: implements ADR 0010)