Skip to content

docs(specs): pilot a Quint model of statement routing - #485

Draft
tobyhede wants to merge 7 commits into
mainfrom
claude/project-thread-p8sn3b
Draft

tobyhede wants to merge 7 commits into
mainfrom
claude/project-thread-p8sn3b

Conversation

@tobyhede

@tobyhede tobyhede commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Toby

A proof-of-concept formal model, in Quint, of how Proxy decides to map, forward or refuse each statement.
The property it checks is that plaintext never reaches an encrypted column, except when the client uses UNSAFE_DISABLE_MAPPING.
It's a design-level model only: it changes no production code, and no Rust code is tested against it yet.

Start with specs/quint/routing/requirements.md, which has the scope, assumptions, properties, findings and open decisions.
verification.md has the exact results.

What it models

Results (Quint 0.33.0, TLC, exhaustive for each finite instance)

  • S1–S3 hold as built, including UNSAFE_DISABLE_MAPPING and concurrent DDL.
    With a stable schema they hold on Proxy's routing alone, even with PostgreSQL's domain check switched off.
  • TLC catches each of four injected faults: write fallback, no unresolvable-table refusal, no batch rule (main's pre-refactor(proxy): route each statement through one refuse-by-default decision #484 behaviour), and no Bind settings check.

Findings to confirm against real Proxy before acting

These are recorded as expected counterexamples, so CI fails if one stops reproducing.

  • F3 (retracted): the first version of the model left out the Bind settings check (PreparedSettingsChanged), so it reported a plaintext path that Proxy does not have. The model now includes the check, and mutation M4 covers it.
  • F1: routes go stale under concurrent DDL. Prepared statements are routed once, at Parse, and transactions pin the schema. Only PostgreSQL's type and domain checks stop the plaintext write.
  • F2: COPY FROM STDIN, DO and CALL are never type checked, so nothing in routing stops them writing plaintext.

PostgreSQL's domain check should reject the value in every case, so none of these is a confirmed leak. Each would need a failing test first.

Tooling

  • specs/quint has a pinned package-lock.json, and check.sh covers typecheck, scenario tests, simulation, TLC and mutations.
  • .github/workflows/quint.yml runs on changes under specs/quint only. It isn't a required check, and the full run takes about 8 minutes.
  • npm audit flags adm-zip, which Quint uses only to unpack its own Apalache download (noted in the README).

Acknowledgment

By submitting this pull request, I confirm that CipherStash can use, modify, copy, and redistribute this contribution, under the terms of CipherStash's choice.


Generated by Claude Code

@tobyhede tobyhede self-assigned this Oct 22, 2026
A design-level model of how Proxy maps, forwards or refuses each
statement, checked with TLC: plaintext must never reach an encrypted
column except with UNSAFE_DISABLE_MAPPING. Covers the refuse-by-default
route from #484, simple Query batches, Parse and Bind, transactions and
concurrent DDL.

TLC confirms the safety properties for clients that never disable
mapping, and records three findings as expected counterexamples:
stale routes under concurrent DDL, statement kinds Proxy never type
checks, and a Parse under UNSAFE_DISABLE_MAPPING bound after mapping is
enabled again. Three injected faults are each caught.

Adds a non-required CI workflow. No production code changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
S3 tracks writes into columns that are encrypted when the write
happens; values already stored before DDL makes a column encrypted are
out of scope. The README and verification record no longer imply that
a change to Proxy's Rust code alone changes the TLC results.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
@tobyhede
tobyhede force-pushed the claude/project-thread-p8sn3b branch from a2c955f to dd25d54 Compare October 22, 2026 23:51
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>
Proxy refuses a Bind with PreparedSettingsChanged when the mapping
setting differs from the one at Parse, for any statement it type checks.
The model left that check out, so it reported a plaintext path (F3) that
Proxy built from main does not have. Model the check, drop the
candidate-fix instances, and add mutation M4, which removes it and is
caught by S1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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