Rejected encrypted reads must not durably create missing streams
perfloop-oss/s2 · Uncatalogued correctness
https://perfloop.ai/t/oss/case_5jzt0arwbn
Verdict
VERIFIED · settled 2026-11-16
What happened: The check fails before this change and passes with it.
Hypothesis
A missing-key read in an encrypted, auto-create basin durably creates the missing stream before returning an error that promises no side effects. This changes the catalog even though read admission fails. One local HTTP counterexample is confirmed; deployment frequency is unknown.
The shared owner calls provision_stream and obtains a guarded client before invoking resolve_encryption at core.rs:419. Backend::open_for_read supplies EncryptionSpec::resolve. Missing, malformed-base64, and wrong-length keys can fail there. ServiceError maps that failure to bad_header, and api/src/v1/error.rs:125-149 explicitly guarantees no side effects for that code. Provisioning waits for remote durability, and public list_streams filters at DurabilityLevel::Remote. All three read-handler modes use this owner. The claim concerns rejected encryption admission, not every read failure or invocation.
A new integration check, lite/tests/read_admission_checks.rs::keyless_read_must_not_create_a_durable_stream, used the real HTTP router and public backend operations. Its complete bound was one AEGIS-256 basin with create_stream_on_read=true, one initially absent stream, one unary GET with seq_num=0&wait=0, no encryption key, no concurrent mutations, and a 10-second timeout. Command from the repository root: cargo test --locked -p s2-lite --test read_admission_checks keyless_read_must_not_create_a_durable_stream -- --exact --nocapture. After initializing the required committed dashboard submodule, it printed: bound=one-request status=400 Bad Request code="bad_header" before_remote_streams=0 after_remote_streams=1 message="missing encryption key for stream cipher 'aegis-256'". It then failed with 'bad_header promises no side effects, but the failed read durably created a stream', left: 1, right: 0; exit 101, 0 passed and 1 failed. The earlier attempt stopped at the missing dashboard build prerequisite, not a property assertion.
The independent Case target is side-effect-free encryption rejection across the supported read modes and stream ciphers while retaining successful automatic creation, basin-default inheritance, and existing-stream behavior. The new-file test placement and a bounded admission matrix are provisional proof methods, not additional fixed implementation requirements. Start with the deterministic counterexample; unchanged remote catalog state with the same error after repair confirms that witness is removed. The other key-error classes and concurrent basin configuration changes remain to be checked rather than inferred from that one run.
Current upstream PR https://github.com/s2-streamstore/s2/pull/808 touches this handler but its actual hunks only document response codes and retry guidance; they do not change creation or encryption admission. The complete open-PR page showed no other matching implementation. A bounded recent file-history fetch was also read; older history beyond its shallow window was not assessed. No customer closure reasons or prior findings were supplied.
Change to test: Make automatic catalog creation conditional on successful encryption admission against the metadata that determines the new stream’s cipher, so a key-resolution error leaves no durable stream behind. Preserve existing-stream cipher handling, valid auto-creation, and the documented error classification; avoid a separate precheck that can become stale before creation.
Where it lives
perfloop-oss/s2 · lite/src/handlers/v1/records.rs
Evidence
The check fails before this change and passes with it: `With no concurrent mutations, missing-stream reads in auto-create basins using AEGIS-256 or AES-256-GCM reject missing, malformed-base64 (!!!!), or four-byte encryption keys with bad_header before any remotely visible stream is created; unary JSON/protobuf, SSE, and S2S reads with a valid key still create the stream with inherited basin defaults and the supplied configuration patch.`
The check passes with this change: `When read auto-creation observes a plaintext basin and a concurrent actor durably changes its cipher to AEGIS-256 or AES-256-GCM before creation can commit, admission is retried against the updated cipher and a missing key is rejected without a remotely visible stream; a keyless retry also rejects encryption without creating a stream.`
Checks: 3 of 3 passed. Verification: no defect found.
Timeline
2026-11-12· Case opened2026-11-14· PR opened