Repository navigation
feat(config): TOML configuration file v1 with StrictModes startup checks - #128
Conversation
Implements RFC-0010 via ADR-0029: - crates/quantumssh/src/config.rs (new): schema v1 (schema_version, [server], [auth], [logging]) as serde structs with deny_unknown_fields on the root document struct and every section — a premature deferred section ([limits], [session]) refuses to start with schema_error, never boots ignored. schema_version is mandatory and only 1 is accepted (version_unsupported otherwise); durations are integer seconds. - StrictModes: trusted paths are canonicalised first (symlink bypass), then the file predicates (not group/world-writable; owner root or process uid; host key additionally not group/world-readable) and the ancestor writability walk run over the canonical path via rustix::fs::stat. A failed predicate is insecure_permissions; a check that cannot run is file_unavailable — never conflated. - main.rs: --config flag; CLI > config > default merge with the override logged at info per key; the config loads before the subscriber exists so its [logging] format can decide the format, and config failures still reach server.config_error. StrictModes now applies to the host key and authorized_keys whether the path came from a flag or the config (ADR-0029). - Dependencies: basic-toml (one new crate in the lockfile) + serde derive; rustix gains the fs feature on the existing pin. - tests/interop: the workdir moves from /tmp (world-writable ancestor — StrictModes now correctly refuses it) to target/. Verification: 151 workspace tests (19 new: schema fail-closed cases, exhaustive pure predicates, e2e walk incl. the symlink case), clippy -D warnings clean, local interop gate PASS against OpenSSH 10.2, and a manual config smoke: boots from file alone, premature [limits] refuses with key+line, 0644 host key refuses with the predicate. Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa Signed-off-by: Gonzalo Fleming <[email protected]>
Review:
|
There was a problem hiding this comment.
Pull request overview
Implements Phase-2 TOML configuration file schema v1 and StrictModes startup checks in the quantumssh binary crate, wiring config loading into startup with CLI > config > default precedence and updating interop harnessing to satisfy ancestor-directory permission checks.
Changes:
- Added TOML config schema v1 parsing/loading with fail-closed
deny_unknown_fields, mandatoryschema_version, and StrictModes (stat+ ancestor writability walk). - Updated
main.rsto support--config, resolve precedence, and apply StrictModes to config/host key/authorized_keys paths before reading. - Moved interop workdir under
target/to avoid/tmpancestor permission rejection; added new dependencies (basic-toml,serde,rustixfs).
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/interop/run_openssh_client.sh | Moves interop workdir under target/ to satisfy StrictModes ancestor checks. |
| crates/quantumssh/src/main.rs | Adds --config, config load + precedence resolution, StrictModes application, and override logging. |
| crates/quantumssh/src/config.rs | New module: schema v1 structs + parsing, error classification, and StrictModes implementation with tests. |
| crates/quantumssh/Cargo.toml | Adds binary-crate deps for config parsing and StrictModes checks. |
| Cargo.toml | Adds workspace deps for serde + basic-toml and enables rustix fs feature. |
| Cargo.lock | Records the new basic-toml dependency and serde_derive usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot review on #128: check_trusted_file now returns the canonical path and every caller reads from it — the checked file is the read file even when the configured name is a symlink, narrowing the symlink-retarget window (the residual stat-to-open race stays within the ADR-0029 best-effort stance). Also: the override log field is explicitly Display-recorded, and the interop harness strips group/world write from target/ for umask-002 environments. Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa Signed-off-by: Gonzalo Fleming <[email protected]>
Review:
|
| # | Commitment | Status |
|---|---|---|
| 1 | Memory-safe by construction — no first-party unsafe |
PASS |
| 2 | PQ by default — no KEX-algorithm config key; transport untouched | PASS |
| 3 | Zero legacy — no new crypto or legacy protocol surfaces | PASS |
| 4 | Small surface — one new crate, fully justified in ADR-0029 | PASS |
| 5 | Permanently open — basic-toml is MIT OR Apache-2.0, in deny.toml allow-list |
PASS |
Threat-model rules check
| Rule | Source | Status |
|---|---|---|
| Pre-auth path — config loaded synchronously at startup, not on wire | §4.1 | PASS |
Fail closed — every failure is server.config_error + ExitCode::FAILURE |
§4.1 | PASS |
Key material zeroized — host key PEM is Zeroizing-wrapped |
§4.3 | PASS |
| Config integrity via StrictModes — file + ancestor walk over canonical path | §4.2, §4.4 | PASS |
Host key confidentiality — TrustedClass::Secret rejects READ_OTHERS |
§5.5.3 | PASS |
| Transport type-state machine — untouched | RFC-0003 | PASS |
| AEAD-only — MAC path unchanged | ADR-0021 | PASS |
Audit log fields — server.config_error preserves ADR-0024 schema |
ADR-0024 | PASS |
Code review1 issue found.
|
claude-review on #128: this PR implements every decision ADR-0029 records, which triggers the ADR's own lifecycle clause. Flipping the Status inside the implementing PR makes the state atomic at merge — no dangling Proposed awaiting a sweep, unlike the Phase-1 batch that needed #86. Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa Signed-off-by: Gonzalo Fleming <[email protected]>
Review:
|
| Rule | Source | Status |
|---|---|---|
| Config loaded synchronously at startup, never on pre-auth surface | §4.1 | PASS |
Fail closed — every error path routes to server.config_error + exit |
§4.1 | PASS |
Double deny_unknown_fields (root + section structs) prevents silent ignore of unknown sections |
ADR-0029 §Decision | PASS |
Canonical-path-return from check_trusted_file closes symlink-TOCTOU (#127) |
ADR-0029 §Decision | PASS |
StrictModes applied to both --flag and TOML-named files |
Threat model §4.2/§4.4/§5.5.3 | PASS |
Host key PEM remains Zeroizing-wrapped |
Threat model §4.3 | PASS |
basic-toml (MIT OR Apache-2.0) is in deny.toml license allow-list |
MANIFIESTO #4/#5 | PASS |
Interop harness chmod go-w target prevents group-writable ancestor under umask 002 |
#127 review finding | PASS |
| ADR-0029 Status flipped to Accepted, dated 2026-07-19, referencing this PR | ADR-0015 | PASS |
The #128 pattern: this PR implements every ADR-0028 decision, so the Status flips atomically with the merge. Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa Signed-off-by: Gonzalo Fleming <[email protected]>
…utdown (#129) * feat(runtime): concurrent accept loop, admission control, graceful shutdown Implements ADR-0028 (extends ADR-0022; the Phase-1 spawn-and-join becomes a JoinSet-driven concurrent loop): - crates/quantumssh-core/src/admission.rs (new): the four admission checks in the ADR's load-shedding order — three non-mutating cap reads (global 256, half-open 100, per-source 10; IPv6 by /64), the state-mutating token bucket last (burst 10, 1/s) so a cap refusal never grows the per-source map. RAII ConnectionGuard: global slot for the connection's life, half-open slot until userauth success; drop-time prune plus an amortised sweep bound the source map. - server.rs: select! over accept / join_next_with_id / the shutdown broadcast. Refused connections close pre-banner and emit connection.refused (limit as structured field) inside the connection span, mutually exclusive with connection.accepted. Panic JoinErrors log connection.closed with the reason as a structured field and the peer recovered via task id. - Graceful shutdown: the broadcast carries the drain deadline; pre-auth connections disconnect immediately, channel-phase connections run until the deadline and are then cancelled — the ADR-0023 backstops (owned-Child kill, exec.finished drop-guard) fire on the drop. The loop aborts stragglers 2 s past the deadline; a second signal aborts immediately. Drained shutdown returns Ok. - main.rs: sync main building the runtime with max_blocking_threads = 4 x max_connections (ADR-0028 blocking-pool sizing); SIGTERM/ SIGINT listener drives the broadcast; exit 0 on both paths. - config: [limits] section and [server].drain_timeout (integer seconds), config-file-only per RFC-0010; zero values are schema_error. [limits] graduates from the deferred-section list. - tokio binary features: +signal, +sync, +time (signal is the only addition to the workspace allowlist, per the ADR). Verification: 168 workspace tests (17 new: admission unit incl. sweep/prune/IPv6-/64/remainder-accrual, schema, and 6 integration: concurrency, cap and rate refusals pre-banner, pre-auth immediate disconnect, drain-at-deadline). Clippy -D warnings clean. Interop gate PASS. Live smoke: two overlapping OpenSSH sessions served concurrently; SIGTERM with drain_timeout=3 drained a sleep-30 exec in ~4 s, exit 0, connection.closed reasons correct. Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa Signed-off-by: Gonzalo Fleming <[email protected]> * docs(adr): flip ADR-0028 to Accepted with its implementing PR The #128 pattern: this PR implements every ADR-0028 decision, so the Status flips atomically with the merge. Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa Signed-off-by: Gonzalo Fleming <[email protected]> * fix(admission): sweep only in the mutating phase, never on the refusal path claude-review on #129: the amortised sweep ran at the top of try_admit, so every cap-refused call advanced the counter and every 64th paid an O(sources) retain under the admission mutex — contradicting the load-shedding order the ADR fixes (refusals stay read-only) and the counter's own name. The sweep now sits after the three cap checks, in the mutating phase: a cap-refused flood never advances it nor pays it. New test pins the invariant: a saturated-cap refusal flood past 2x SWEEP_INTERVAL leaves a prunable lingering entry untouched. Claude-Session: https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa Signed-off-by: Gonzalo Fleming <[email protected]> * fix(server): emit connection.closed per ADR-0024 on join errors Re-enter the original connection span so peer_addr is inherited, keep only reason on the event at INFO, and use ADR-0028's shutdown reason for drain aborts. Signed-off-by: Gonzalo Fleming <[email protected]> * fix(channel): re-key before close when a threshold was crossed while draining A fast exec could flush past the byte/packet limit and become ready to close in the same turn; rekey_due was only checked in Running/Idle, so the connection closed under the old keys and byte_threshold_triggers _server_rekey flaked on loaded runners. Signed-off-by: Gonzalo Fleming <[email protected]> * fix(server): emit connection.refused at INFO Align with ADR-0024's connection lifecycle levels; a cap refusal is routine load-shedding, not a security-policy failure. Signed-off-by: Gonzalo Fleming <[email protected]> --------- Signed-off-by: Gonzalo Fleming <[email protected]>
Point README and the Phase-2 scoping note at #128 (config) and #129 (runtime) so "implemented" is verifiable without relying on stale RFC implementation-PR headers. Signed-off-by: Gonzalo Fleming <[email protected]>
* docs: align README and Phase-2 scoping with landed Phase 1/2 work Phase 1 is complete; Phase 2 has config + concurrent runtime. Drop the stale "no Rust code" status and mark the remaining Usable items. Signed-off-by: Gonzalo Fleming <[email protected]> * docs: cite implementing PRs for landed Phase-2 workstreams Point README and the Phase-2 scoping note at #128 (config) and #129 (runtime) so "implemented" is verifiable without relying on stale RFC implementation-PR headers. Signed-off-by: Gonzalo Fleming <[email protected]> --------- Signed-off-by: Gonzalo Fleming <[email protected]>
Flips Status to Accepted inside the implementing PR (repo pattern since #128), points Links/Decision at #179, and historicises the three drafting-time phrasings (table header, advisory sentence, ADR-0035 availability). Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]>
…-dalek 5) (#179) * docs(adr): ADR-0036 — move ed25519-dalek and x25519-dalek to 3.x together (Proposed) The coordinated bump the #109 comment of 2026-07-18 deferred, subsidiary to RFC-0003. Evaluates the four points that comment asked for: API (ed25519-dalek 3 drops std; no first-party code change needed), zeroize and static_secrets (kept; x25519 secrets now erase on drop only), MSRV (1.85, below the workspace's 1.92), and maturity/audit (no advisory on either line; Verus coverage applies to curve25519-dalek 4.1.3, not 5.0; no known public audit of 5.0/3.0). States the value plainly: no vulnerability fixed; Cargo.lock 102 -> 88, no duplicated crates in quantumssh-core, signature 3 aligned with ADR-0035's ml-dsa. Records that the dalek crates are BSD-3-Clause (RFC-0003 says Apache-2.0 or MIT; deny.toml allows BSD-3-Clause). Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> * fix(deps): declare zeroize's alloc feature explicitly Zeroizing<Vec<u8>> (kex.rs, auth.rs, transport.rs) and Zeroizing<String> need zeroize's alloc feature. The workspace never declared it: it arrives only through feature unification from ed25519-dalek's std feature (ed25519-dalek/std -> alloc -> zeroize?/alloc and curve25519-dalek/alloc). Dropping std from ed25519-dalek, as its 3.x line requires, would break the build in 35 places with no code change of ours. Declare it where it is used. Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> * chore(deps): move ed25519-dalek and x25519-dalek to 3.0.0 (curve25519-dalek 5) Implements ADR-0036. ed25519-dalek drops the removed std feature and the unused rand_core feature; x25519-dalek keeps static_secrets and zeroize. No first-party code change. Cargo.lock: 102 -> 88 packages; cargo tree -d -e normal -p quantumssh-core prints nothing (was sha2, digest, rand_core, block-buffer, crypto-common, cpufeatures in two versions each). fmt, clippy -D warnings, test --workspace (34 + 103 + 35) and build --release pass. Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> * docs(adr): ADR-0036 Accepted with the implementing PR #179 Flips Status to Accepted inside the implementing PR (repo pattern since #128), points Links/Decision at #179, and historicises the three drafting-time phrasings (table header, advisory sentence, ADR-0035 availability). Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> * docs(adr): ADR-0036 — review fixes (2.x release date, two manifest lines, present vs future controls) claude-review on #177: - 'The 4.x/2.x line has had no release since mid-2024' was false for ed25519-dalek 2.2.0 (2025-07-09); now scoped per crate. - The diff is two manifest lines (zeroize/alloc belongs to #175). - The Verus-loss paragraph listed Phase-3 fuzzing as a present control; present controls (RFC 7748 vectors, OpenSSH interop gate) are now separated from the future one, and the text says nothing currently replaces the formal guarantee. opencode suggestions on #177 and #179: - Refers to 'the ml-dsa ADR proposed in #174' instead of citing the not-yet-permanent number ADR-0035 as established. - pkcs8/der/spki leave Cargo.lock (they are not compiled today). - The RFC-0003 licence sentence lives in its Guide-level explanation. Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> * docs(adr): ADR-0036 — review fixes (2.x release date, two manifest lines, present vs future controls) claude-review on #177: - 'The 4.x/2.x line has had no release since mid-2024' was false for ed25519-dalek 2.2.0 (2025-07-09); now scoped per crate. - The diff is two manifest lines (zeroize/alloc belongs to #175). - The Verus-loss paragraph listed Phase-3 fuzzing as a present control; present controls (RFC 7748 vectors, OpenSSH interop gate) are now separated from the future one, and the text says nothing currently replaces the formal guarantee. opencode suggestions on #177 and #179: - Refers to 'the ml-dsa ADR proposed in #174' instead of citing the not-yet-permanent number ADR-0035 as established. - pkcs8/der/spki leave Cargo.lock (they are not compiled today). - The RFC-0003 licence sentence lives in its Guide-level explanation. Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> * docs(adr): ADR-0036 — ed25519-dalek 3's runtime vs optional/dev dependencies opencode review #2 suggestion on #177: getrandom 0.4 is a dev-dependency of ed25519-dalek 3.0.0, and rand_core 0.10 and signature 3 are optional there (signature 3 still enters through ed25519 3, a normal dependency). The API bullet now names the runtime moves only. Verified against the crates.io dependency metadata of ed25519-dalek 3.0.0 and ed25519 3.0.0. Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> * docs(adr): ADR-0036 — yanked 4.2.0 and licence cell wording opencode suggestions on #177 (review #3) and #179 (review #2): - curve25519-dalek 4.2.0 was published 2025-07-09 and yanked; both maintenance statements now say 'no usable 4.x release since 2024-06-18' and name it (verified on crates.io). - The licence cell said 'all six' with no referent; it now says 'all three crates'. Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> * docs(adr): ADR-0036 — cite RFC-0003's Guide-level explanation for the primitive stack opencode suggestion on #179 (review #3): RFC-0003 section 'Operational dependencies of this decision' only lists four follow-up ADRs and never mentions the dalek crates; the primitive stack (with x25519-dalek and ed25519-dalek) is in its Guide-level explanation. Related and Links now point there, consistent with the licence note. Refs #109 Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]> --------- Signed-off-by: Gonzalo Fleming <[email protected]>
…ates (#219) CLAUDE.md's status paragraph listed "no config file" among the missing production features, but the config file landed with #128 (ADR-0029). The remaining gap it names is per-user privilege separation, until Phase 3 (threat model §8.12). The ADR-0024 and ADR-0038 errata entries added by #196 were dated 2026-10-26, from the draft, while #196 merged on 2026-10-28. Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp Signed-off-by: Gonzalo Fleming <[email protected]>
What
The keystone Phase-2 workstream (#109): implements RFC-0010 exactly as ADR-0029 locks it. On merge, ADR-0029 flips to Accepted per the #86 pattern.
config.rs(new, in the binary crate per ADR-0017/ADR-0029): schema v1 as serde structs,deny_unknown_fieldson the root document struct and every section — a premature[limits]/[session]refuses to start withschema_error(never boots ignored),schema_versionmandatory (only1accepted), durations as integer seconds.rustix::fs::stat. Failed predicate →insecure_permissions; check-couldn't-run →file_unavailable. Applies to host key andauthorized_keyswhether named by flag or config.main.rs:--config,CLI > config > defaultmerge (each override logged at info), config loads before the subscriber so[logging] formatcan decide the format while failures still reachserver.config_error.basic-toml(the one new lockfile crate, per ADR-0029) +serdederive;rustixgainsfson the existing pin.cargo denygates it in CI./tmp→target/— StrictModes now correctly refuses the world-writable/tmpancestor.Verification
schema_version), exhaustive pure permission predicates, and an e2e walk over the real filesystem including the symlink-to-dirty-dir case.cargo fmt+clippy -D warningsclean, release build ok.[limits]→schema_error: … unknown field \limits` … at line 2 column 1; a0644host key →insecure_permissions: … group/world-readable private key (mode 0644)`.Behaviour change (deliberate, ADR-0029 §Negative)
Flag-only deployments with sloppy modes (world-readable host key, group-writable
authorized_keys, or either under/tmp) now refuse to start with a message naming the file and predicate. This is the threat-model §4.2/§5.5.3 posture finally enforced.Implements RFC-0010 / ADR-0029. Refs #109.
https://claude.ai/code/session_01J2SZwLuDm1KjfYyPM8npTa