Skip to content

impl(010): rustev-serve increment 1, the HTTP service sources - #190

Merged
bartekus merged 1 commit into
mainfrom
impl/010-serve-src
Oct 23, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/010-serve-src

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Split from #186, stacked on #189. The rustev-serve crate sources under the approved binding record (A-47): HTTP/1.1 and HTTP/2 over TLS 1.3 with required client certificates, Unix sockets, the handler layer, signed plan registration (Ed25519, offline Sigstore), decisions, the 042 3.5.1 refusal table, idempotency, lookup, cancellation, SSE streaming, health/readiness/metrics, shutdown and standalone sinks. Every review finding raised on #186 is already fixed here. Tests and fixtures follow in the next PR. Checks: build, clippy, make gate, couple.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the new integrations/rustev-serve/ crate and related changes.

Cargo / dependency changes look correct. The sigstore-verify, ring, and new transitive deps (jiff, cms, etc.) are all at pinned versions or fixed ranges, and their use is confined to integrations/ as the governance boundary rule requires.

specs/010-integrations/spec.md — the planned: true removal is correct (directory now exists), and the new record entry is consistent with the spec's in-progress status. I cannot verify "A-47" as an owner act; that is enforced elsewhere.

tools/rustev-release/release-set.json — the rustev-serve crate is correctly moved from the absent (planned, with kind) list to excluded (name + reason only), matching the format of all other excluded entries. The image entry stays in absent. No inconsistency.

src/subjects.rs — the DER TLV parser uses checked arithmetic and slice indexing throughout. The subject() function correctly skips the optional version ([0]) field and then skips four TLVs to reach the Subject Name. The ClientCertVerifier delegates WebPKI chain validation before applying the allowlist. OK.

src/signatures.rs — Sigstore verification correctly requires certificate_verified(), tlog_verified() and identity_policy_checked() all three. The intact_but_untrusted distinction is sound. The has_inclusion_proof() pre-check is correct. OK.

src/transport.rs — bearer-token comparison is a constant-time HMAC trick: HMAC(SHA256(stored), SHA256(provided)) == HMAC(SHA256(stored), SHA256(stored)), which reduces to SHA256(provided) == SHA256(stored) in constant time. Correct, though convoluted. Token file validation with is_ascii_graphic() correctly rejects newlines, so trailing newline mismatch is prevented. OK.

src/transport.rs — principal() decoder — unpadded base64url, len % 4 == 1 rejection, non-canonical trailing-bit check, and the 1024-byte cap are all correct.

src/service.rs — concrete defect: In the run method, when request.snapshot is None the code immediately calls request.context.as_ref().unwrap() without a guard. context is an Option; if the ServeDecide schema has a gap that allows both snapshot and context to be absent, or if any future change breaks the invariant, this panics. The spawned-task panic propagates to decide_stream's joiner, which calls self.begin_shutdown() — taking down the entire service instead of returning an error. A second consequence: the state entry inserted before the spawn has expires: None and reply: None, so prune() retains it indefinitely (the is_none_or branch keeps entries with no expiry forever), leaking memory for the life of the (now-shutting-down) process.

src/offline.rs — Roots::resolve uses file.take(max_bytes as u64), matching the bytes helper's T::LIMITS.max_bytes + 1 call correctly. Path-traversal mitigation via canonicalize() + starts_with() is standard and acknowledged as having TOCTOU limitations.

src/stream.rs — the enable() pattern for Notify prevents missed wake-ups. Final event delivery on the separate oneshot channel is guaranteed regardless of progress-event drops. The documented no-final-on-panic case is an open item, not a defect introduced here.

src/sinks.rs — delivery loops correctly propagate may_have_received uncertainty; the validate_digest call in receipt() covers the Duplicate digest-mismatch case tested in the unit tests.

{"head": "208e2b62574009a359cdc33d50fba14fc604d5a3", "verdict": "findings", "findings": [{"path": "integrations/rustev-serve/src/service.rs", "line": null, "summary": "In `run`, `request.context.as_ref().unwrap()` panics when both `snapshot` and `context` are `None`; a panic in the spawned task causes `decide_stream` to call `self.begin_shutdown()`, shutting down the entire service, while the corresponding state entry (expires: None, reply: None) is retained forever by `prune()` because the expiry is never set."}]}

Subject: f1ade4e...208e2b6, diff digest 0dcf19c4c9c2d4bc25f3174dfad6af9913cd0fd4729203216e68587bf1fa5191, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 23, 2026 08:29 — with GitHub Actions Error
Base automatically changed from impl/010-runtime-observer to main October 23, 2026 08:44
@bartekus
bartekus force-pushed the impl/010-serve-src branch 3 times, most recently from 6b28e8a to ad08652 Compare October 23, 2026 08:50
@bartekus
bartekus enabled auto-merge (squash) October 23, 2026 08:50
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for bugs, security issues, and inconsistencies.

Architecture & security checks performed:

  1. Bearer token comparison (transport.rs): The HMAC-based comparison hashes both sides with SHA-256 first, then uses ring::hmac::verify (constant-time). The construction — sign SHA256(token) with key SHA256(token), verify SHA256(got) against that tag — is equivalent to constant-time equality of the two SHA-256 values. Correct.

  2. Unix socket binding (transport.rs): symlink_metadata rejects existing paths including dangling symlinks; parent must be 0700; bind_unix is only 0600/0660. The TOCTOU gap is acknowledged in the README and mitigated by the private-parent requirement. Correct.

  3. Path confinement in offline resolver (offline.rs): Double canonicalize() with starts_with(), regular-file check, and on Unix an fstat/stat inode comparison. The README explicitly documents this is not race-free against a concurrent hostile writer. Acceptable as stated.

  4. DER subject parser (subjects.rs): The bounded TLV reader uses checked_mul/checked_add, rejects indefinite-length encodings (n==0), and is called only after WebPKI validation. The 4-field skip correctly handles optional v3 extension (0xa0 tag). Correct.

  5. Sigstore path (signatures.rs): Both the happy path and the intact_but_untrusted path require certificate_verified() && tlog_verified(). An invalid chain root correctly surfaces as SignatureInvalid even when the artifact signature and log proof are intact. Correct.

  6. Blocking semaphore ownership (offline.rs): Slot is held for the full lifetime of the spawned blocking closure; on a timeout the function returns but the slot is retained until the blocking function exits, as documented.

  7. release-set.json schema: The rustev-serve crate entry moves from absent (with "kind": "crate") to excluded (no kind, only name and reason), matching every other excluded entry (rustev-bedrock, rustev-jev). The image absent entry is updated in place. Consistent with the spec.md record.

  8. spec.md planned: true removal: The directory now exists; removing the flag is correct.

  9. Mutex ordering: State → refused is the only order used (register, metrics, decide_stream all acquire state first, refuse() acquires refused). No inversion found.

  10. Body and header bounds, principal base64url decoding, traceparent validation: All appear correctly bounded and canonically enforced.

No concrete defect supported by the supplied evidence.

{"head": "eb37d547baa6566e324df014db8cd38259df0226", "verdict": "no-findings", "findings": []}

Subject: a5d8dc4...eb37d54, diff digest 10dd3716378a8f4969eb6c4145e1093da0287ce57781ff329050ce471c1af7b0, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit e8c78d1 into main Oct 23, 2026
31 checks passed
@bartekus
bartekus deleted the impl/010-serve-src branch October 23, 2026 09:18
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