Skip to content

fix: evidence packs verify after signer expiry, spool gap, session TTL overflow, two hygiene fixes - #299

Merged
jfcmartins merged 5 commits into
mainfrom
claude/focused-thompson-2eqaf3
Nov 10, 2026
Merged

jfcmartins merged 5 commits into
mainfrom
claude/focused-thompson-2eqaf3

Conversation

@jfcmartins

Copy link
Copy Markdown
Collaborator

What and why

This PR has five small, independent fixes, one commit each. They come from a routine review, and none of them overlaps the open PRs #294, #295 or #276.

  1. Evidence packs stopped verifying about a day after export (limen-verify/src/pack.rs).
    • verify_pack checked the signer's certificate against now. The control plane's certificate lives LIMEN_COMPONENT_CERT_TTL (24h by default), so limen audit verify --evidence rejected every genuine pack once that certificate expired. That is exactly when an auditor checks a pack (ADR-0029: "verify offline").
    • The pack is now judged as of the manifest's signed generated_at, the same way bucket.rs already judges audit manifests with verify_at.
    • tests/reviews.rs didn't catch this because it verifies the pack straight after generating it.
  2. A spool read could return a batch with a gap (limen-audit/src/spool.rs, read_from).
    • scan returned fewer records than requested when a closed, fsynced segment had been damaged after open (a truncated or bad-CRC tail), and read_from ignored the short count.
    • run_consumer then committed past the missing records, so they were never shipped, and the segment was later deleted.
    • It now returns SpoolError::Corrupt, which matches the module's own rule of never skipping records silently.
  3. The proxy panicked on an oversized max_session_ttl (limen-proxy/src/sessions.rs).
    • Policy validation puts no upper bound on max_session_ttl: 3000000d parses. now + ttl panics past year 9999, so one such role broke every session open for the people holding it.
    • The expiry is now computed with checked_add, and the session is denied with a reason on overflow.
  4. The ElastiCache STS session token is now wrapped in Secret (limen-worker/src/redis/target.rs).
    • The Credentials struct derives Debug and held session_token: Option<String>, unlike db/sigv4.rs. Nothing logs it today; this keeps the "secrets never logged" invariant from depending on that.
  5. The demos' skipped-test guards can now fire (demos/demo-idp-offboarding.sh, demos/demo-shadow.sh).
    • demo-idp-offboarding ran cargo test without --nocapture. libtest swallows a passing test's stderr, which is where SKIPPED: … is printed, so grep '^SKIPPED' could never match.
    • Both demos now grep a here-string instead of a pipe, because pipefail plus grep -q exiting early can SIGPIPE the echo and turn a match into a miss.

Related: no phase work; these are bug fixes to shipped behaviour (ADR-0029 for item 1).

How it was verified

  • cargo fmt --all: clean.
  • cargo clippy --locked -p limen-verify -p limen-audit -p limen-proxy -p limen-worker --all-targets --all-features -- -D warnings: clean.
  • cargo test --locked -p limen-verify -p limen-audit -p limen-proxy --lib: all pass (7, 23 and 38 tests), and cargo test -p limen-verify integration tests pass.
  • cargo test --locked -p limen-worker --lib redis::: 57 pass.
  • New tests:
    • pack::tests::a_pack_still_verifies_after_its_signers_certificate_expires issues a 1-second certificate and waits 2.1s.
    • pack::tests::a_pack_dated_after_its_signers_certificate_expired_is_refused.
    • spool::tests::a_closed_segment_damaged_after_open_fails_the_read_instead_of_skipping.
    • sessions::tests::a_session_ttl_past_year_9999_is_refused_not_a_panic.
    • redis::target::tests::debug_output_hides_the_secret_key_and_session_token.
  • I reverted each fix locally to confirm its test fails without it: both pack tests fail, and the spool test fails.
  • The libtest capture behaviour behind item 5 was checked with a scratch crate: SKIPPED appears 0 times without --nocapture and once with it.
  • bash -n on both demos.

Not verified

  • I did not run the full workspace clippy or cargo test --workspace --all-features; CI runs them. I did not run any integration tests needing PostgreSQL/KMS/S3 or Dex, including limen-control-plane/tests/reviews.rs, which calls verify_pack.
  • I did not run either demo end to end (no Docker here), and did not run shellcheck, gitleaks or cargo deny (not installed). No external dependency was added: the new dev-dependencies of limen-verify (limen-ca, limen-core, rcgen) are already in the workspace.

Review guide

  • Item 1 has a trade-off, the same one bucket.rs documents. Someone holding a key from an expired control-plane certificate could sign a pack backdated into that certificate's validity. Before this change, every pack failed once its certificate expired, so this widens what verifies back to what ADR-0029 intended. The evidence.export audit event, which carries manifest_sha256, is the anchor that catches a forged pack. Worth a look whether limen audit verify --evidence should require that event by default.
  • Item 2: a consumer now gets an error on the damaged segment. The spool then fills and appends are refused, which fails closed, rather than shipping a batch with a hole.

Checklist

  • Tests added or updated; cargo fmt and cargo clippy ... -D warnings clean (on the touched crates)
  • Docs updated: n/a
  • Phase work: n/a (demo guards fixed, demos not run)
  • Secrets stay out of logs (limen_core::secret::Secret); mTLS and fail-closed audit intact
  • New dependency: n/a (workspace crates only)
  • New entry point or data store: n/a
  • Commits are conventional, small and focused

Compatibility and rollback

None. Two behaviour changes:

  • A session whose computed expiry would overflow is now denied instead of crashing the handler.
  • Packs older than their signer's certificate now verify.

Revert any single commit to roll it back.


Generated by Claude Code

verify_pack checked the signing control plane's certificate against the
current time. That certificate lives about a day, so every genuine pack
stopped verifying offline a day after export, which is when an auditor
checks it. Judge it as of the manifest's signed generated_at instead, as
the audit bucket verifier already does for manifests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYXpNCrqYnNbKiHVaey
read_from ignored scan's short result, so a closed segment damaged after
open returned a batch with a gap; the consumer committed past it and the
missing records were never shipped. Return a corruption error instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYXpNCrqYnNbKiHVaey
max_session_ttl has no upper bound in policy validation, and now + ttl
panics past year 9999, so one oversized role broke every session open for
its holders. Compute the expiry with checked_add and deny on overflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYXpNCrqYnNbKiHVaey
redis::target::Credentials derives Debug and held the session token as a
plain String, unlike db/sigv4.rs. Nothing logs it today; this keeps it
that way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYXpNCrqYnNbKiHVaey
demo-idp-offboarding ran cargo test without --nocapture, so libtest
swallowed the SKIPPED line a passing-but-skipped test prints and the
guard could never trigger. Both demos now grep a here-string rather than
a pipe, which pipefail plus grep -q could turn into a miss.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEiXYXpNCrqYnNbKiHVaey
@jfcmartins
jfcmartins marked this pull request as ready for review November 10, 2026 17:14
@jfcmartins
jfcmartins merged commit c8fe547 into main Nov 10, 2026
17 checks passed
@jfcmartins
jfcmartins deleted the claude/focused-thompson-2eqaf3 branch November 10, 2026 17:46
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.

2 participants