Skip to content

docs(rfc): RFC-0013 — SFTP subsystem in a first-party SFTP v3 re-exec helper - #194

Merged
gonzafg2 merged 6 commits into
mainfrom
docs/rfc-0013-sftp-subsystem
Oct 29, 2026
Merged

gonzafg2 merged 6 commits into
mainfrom
docs/rfc-0013-sftp-subsystem

Conversation

@gonzafg2

Copy link
Copy Markdown
Owner

Summary

RFC-0013 proposes that QuantumSSH serve the sftp subsystem with its own SFTP version 3 server, written in Rust with no first-party unsafe. It runs as a single-threaded helper mode of the quantumssh binary, which the channel layer starts as an ordinary pipe child. The helper inherits ADR-0038's process supervision and audit, keeps file access out of the server process, and is where Phase 3 will drop privileges.

This PR stays a Draft for the 14-day comment period, until 2026-10-26. Implementing ADRs and code follow acceptance.

Motivation

Refs #109

  • SFTP is part of the 0.1.0 MVP (README.md:57).
  • OpenSSH's scp uses SFTP by default (scp.c:458, :1004), so today both scp and sftp fail against QuantumSSH.
  • Threat model §5.4.4 expects a session-level record of SFTP use.

What the RFC decides

  • The request: subsystem "sftp" once in Idle, exclusive with exec and shell. It is refused after a pty-req, and any other subsystem name is refused.
  • The helper: a re-exec mode next to the PTY helper. It is single-threaded and synchronous, starts in $HOME, and serves until EOF.
  • The protocol profile:
    • Version and bounds: version 3 only, and OpenSSH's 256 KiB packet bound. Malformed input ends the session (fail-closed).
    • Responses: exactly one per request. STATUS always carries the message and language strings.
    • SYMLINK: OpenSSH's reversed argument order.
    • Extensions: limits@, posix-rename@, fsync@ and expand-path@.
  • Filesystem semantics: operations run as the service account with no Phase-2 confinement, which is the same access a shell already has. Create modes are masked to 0777. RENAME and posix-rename follow OpenSSH's semantics.
  • Audit: exec.* with request_type = "subsystem" and command = "sftp". exec.finished gains bytes_received and bytes_sent. No paths and no content are logged.
  • Multiplexing is not needed: sftp and scp use one session channel. This corrects ADR-0038's Consequences ("SFTP brings multiplexing") and the scoping note.

Sources

All protocol claims cite openssh-portable V_10_6_P1 (sftp-server.c, sftp-client.c, scp.c, session.c, PROTOCOL) and draft-ietf-secsh-filexfer-02 by line number.

Alternatives weighed

  • OpenSSH's sftp-server: C code, and the feature would depend on what the host has installed.
  • russh-sftp: it expands the trust base and belongs to the russh ecosystem that RFC-0003 declined.
  • An in-process async server: incompatible with the single-threaded identity change Phase 3 needs.
  • Waiting for Phase 3.

Open questions for reviewers

  1. Extensions: should statvfs@ and hardlink@ join the initial set?
  2. Configuration: a [sftp] switch, or none?
  3. Byte counts: on every exec.finished, or only on subsystems?
  4. Handle cap: what value?

Checklist

Automated reviews

PRs authored by dependabot[bot] (and other bots) do not trigger opencode or Claude Code Review. Codex reviews through the Codex cloud GitHub App (ADR-0037).
They are covered by CI (commit-lint, build (ubuntu-latest) and build (macos-latest) — fmt, clippy, tests, release build —, cargo deny, openssh-interop; cargo audit runs weekly, not per PR) and manual review when needed.

https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW

@gonzafg2 gonzafg2 added documentation Improvements or additions to documentation rfc Request for comments / design proposal labels Oct 13, 2026
@opencode-agent

Copy link
Copy Markdown

PR Review: docs(rfc): RFC-0013 — SFTP subsystem in a first-party SFTP v3 re-exec helper (#194)

Decision: 🟢 Approved
Iteration: First review
Lenses applied: Design decision (docs/rfcs/0013-sftp-subsystem.md), governance/process (ADR-0015, docs/rfcs/README.md), threat-model consistency (§4.1–§4.3, §5.4, §6, §8.12)

Executive summary

RFC-0013 proposes serving the sftp subsystem with a first-party SFTP v3 server that runs as a single-threaded re-exec helper, and fixes the protocol profile, filesystem semantics, and audit record; it also corrects ADR-0038's "SFTP brings multiplexing" expectation. Measured against the five commitments and the threat model it holds up: no new dependency, no first-party unsafe, the post-auth parser is treated as fuzzable with explicit bounds, framing is fail-closed, Hybrid/PQ and AEAD posture are untouched, and both mandated exec.* fields (authenticated_identity, executing_uid) are present. I found nothing that reaches the ≥80 reporting bar.

New findings

No finding scored ≥80. The three candidates I examined and rejected:

  • ADR-0038 "correction" without a supersession/erratum pointer (docs/rfcs/0013-sftp-subsystem.md:40-44 vs docs/adr/0038-phase-2-interactive-pty-sessions.md:698) — refuted. ADR-0015's immutability rule governs edits to an accepted ADR; RFC-0013 edits nothing and RFCs cannot supersede ADRs (ADR-to-ADR only, per RFC-0007 §2). The RFC explicitly reconciles the statement by quoting and correcting it. An ADR-0038 erratum would be hygiene, not a rule violation.
  • Audit-schema expansion bundled into the SFTP RFC (docs/rfcs/0013-sftp-subsystem.md:201-216) — below threshold. The RFC states the detail is locked by an implementing ADR and recorded in ADR-0024's Status field, which is exactly the subsidiary-decision routing docs/rfcs/README.md §"Scope" requires.
  • command asserted on exec.finished (docs/rfcs/0013-sftp-subsystem.md:205) — out of scope. ADR-0024's field list omits command on exec.finished, but the implementation emits it (crates/quantumssh-core/src/channel.rs:598-612); this is a pre-existing ADR/implementation gap the RFC does not introduce.

💡 Suggestions (nice to have)

  • docs/rfcs/0013-sftp-subsystem.md:40-44: optionally note that the factual correction to ADR-0038's Consequences will be mirrored as an annotated Post-acceptance errata entry on ADR-0038. It is not required, but it is the corpus's normal discoverability path (Anchor: ADR-0015).

Limitations

The RFC's OpenSSH citations (sftp-server.c, sftp-client.c, scp.c, session.c, PROTOCOL) reference tag V_10_6_P1 and were not verifiable in this environment (no network, and the tag postdates the public tree), so I did not treat any line-number discrepancy as a finding. Commit signature verification, by contrast, was checked via the GitHub API and is valid for a42fe9e, with DCO sign-off present.

Decision: 🟢 Approved

github run

gonzafg2 added a commit that referenced this pull request Oct 13, 2026
… erratum

The implementing PR records the corrected "SFTP brings multiplexing"
statement as a post-acceptance erratum on ADR-0038 (ADR-0015), the
corpus's discoverability path. From opencode's review of #194.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
@opencode-agent

Copy link
Copy Markdown

PR Review: docs(rfc): RFC-0013 — SFTP subsystem in a first-party SFTP v3 re-exec helper (#194)

Decision: 🟢 Approved
Iteration: Review #2 (1 resolved, 0 open) — previous review: opencode-agent
Lenses applied: Design decision (docs/rfcs/0013-sftp-subsystem.md), governance/process (ADR-0015, docs/rfcs/README.md step 5 & Scope), threat-model consistency (§2.7, §4.1, §5.4, §6.2, §8.12). Rust and CI lenses are not applicable: the diff is one document, +339/-0, no code and no workflow changes.

Executive summary

RFC-0013 proposes serving subsystem "sftp" with a first-party, unsafe-free SFTP v3 server run as a single-threaded re-exec helper, and fixes the protocol profile, filesystem semantics and audit record while correcting ADR-0038's "SFTP brings multiplexing" expectation. Measured against the five commitments and the threat model it holds: no new dependency, no first-party unsafe, the post-auth parser is explicitly treated as bounded and fuzzable, framing is fail-closed, Hybrid/PQ and AEAD posture are untouched, and both mandated exec.* fields are present. Nothing reaches the ≥80 reporting bar; the one actionable item from the prior review is resolved.

Previous issues

# Issue Status Notes
1 Suggest noting that the ADR-0038 multiplexing correction be mirrored as an annotated erratum (ADR-0015) ✅ resolved docs/rfcs/0013-sftp-subsystem.md:44-46 now states the implementing PR records the correction as a post-acceptance erratum on ADR-0038. Added in 27581c7 ("…the ADR-0038 multiplexing correction becomes an erratum").
2 Three prior candidates (ADR-0038 erratum vs supersession; audit-schema expansion; command on exec.finished) ✅ no change needed Re-examined; all remain below threshold or out of scope, see below.

New findings

No finding scored ≥80. The candidates examined and rejected this iteration:

  • ADR-0038 §1 decision reversal needs a superseding ADR (docs/rfcs/0013-sftp-subsystem.md:11-20, :24, :44-46 vs docs/adr/0038-phase-2-interactive-pty-sessions.md:150-156) — refuted. §1's subsystem refusal is a Decision-section entry, but RFC-0013 explicitly names §1 as the state it changes and routes the mechanics to "Implementing ADRs lock the details" (:24). Errata are scoped at :44-46 to the factual "SFTP brings multiplexing" prediction only, which ADR-0015 permits. Repo precedent (RFC-0004, RFC-0008) is that an RFC does not name its not-yet-existent implementing ADR; a Draft that edits nothing cannot break ADR-0015.
  • 14-day comment period is 13 days (PR body "until 2026-10-26", createdAt 2026-10-13T00:15Z) — refuted. The author commits in -03:00; the PR opened 2026-10-12T21:15-03:00, matching the RFC's own Created: 2026-10-12 (0013-sftp-subsystem.md:5), and inclusive counting to 2026-10-26 is exactly 14 days. The rule (docs/rfcs/README.md:83-86) is a floor with no stated anchor, the PR is still a Draft, and no merge has occurred — no concrete breach.

💡 Suggestions (nice to have)

  • docs/rfcs/0013-sftp-subsystem.md:209-212: bytes_received/bytes_sent are proposed for every exec.finished, widening the 0.1.0 freeze surface beyond the SFTP need and including protocol framing, which is not threat-model §5.4.4's "transferred N bytes". Scoping the counts to request_type = "subsystem" would keep the record faithful to §5.4.4 and keep the freeze delta minimal. (Below threshold; the RFC already routes the schema addition to ADR-0024's Status field at :216-218, which is the correct governance path.)

Limitations

  • The RFC's OpenSSH citations (sftp-server.c, sftp-client.c, scp.c, session.c, PROTOCOL) reference tag V_10_6_P1, which is not present in this environment (no network), so no line-number discrepancy was treated as a finding.
  • Commit signature verification via git log --format=%G? is meaningless on a runner (no gpg.ssh.allowedSignersFile). Checked through the GitHub API instead: both a42fe9e and 27581c7 report commit.verification.verified = true, and both carry DCO Signed-off-by: trailers.

Decision: 🟢 Approved

github run

@opencode-agent

Copy link
Copy Markdown

PR Review: docs(rfc): RFC-0013 — SFTP subsystem in a first-party SFTP v3 re-exec helper (#194)

Decision: 🟢 Approved
Iteration: Review #3 (1 resolved, 1 open suggestion) — previous reviews: opencode-agent #1, opencode-agent #2
Lenses applied: Design decision (docs/rfcs/0013-sftp-subsystem.md), governance/process (ADR-0015, docs/rfcs/README.md, threat-model "Maintenance"), threat-model consistency (§2.5, §5.4.4, the proposed §5.4.5, §6.2, §8.12). Rust and CI lenses are not applicable: the diff is one document, +380/−0, no code and no workflow changes.

Executive summary

RFC-0013 proposes serving subsystem "sftp" with a first-party, unsafe-free SFTP v3 server run as a single-threaded re-exec helper, fixing the protocol profile, filesystem semantics and audit record, correcting ADR-0038's "SFTP brings multiplexing" prediction, and (in the new commit c636898) carrying the threat model's proposed §5.4.5 entry. Measured against the five commitments and the threat model it holds: no new dependency, no first-party unsafe, the post-auth parser is treated as bounded and fuzzable, framing is fail-closed, Hybrid/PQ and AEAD posture are untouched, and both mandated exec.* fields are present. The one actionable item from review #2 still stands as a suggestion-level open question, not a defect. No finding reaches the ≥80 bar.

Previous issues

# Issue Status Notes
1 Suggest mirroring the ADR-0038 "SFTP brings multiplexing" correction as an annotated erratum ✅ resolved docs/rfcs/0013-sftp-subsystem.md:44-46 routes it to the implementing PR; added in 27581c7
2 Scope bytes_received/bytes_sent to subsystems rather than every request type ❌ open (suggestion-level) docs/rfcs/0013-sftp-subsystem.md:209-212 still says "every request type", and :364-365 lists it as unresolved question #3. Below the reporting bar, as review #2 held
3 Re-examined prior candidates (ADR-0038 §1 reversal needs a superseding ADR; 14-day window; command on exec.finished) ✅ no change needed Unchanged; all still refuted or out of scope

New findings

No finding scored ≥80. The new commit c636898 adds ### 6. Threat model changes (docs/rfcs/0013-sftp-subsystem.md:220-259): a verbatim proposed §5.4.5 "SFTP request handling" entry plus a factual update to §5.4.4. I verified the entry against the repository:

  • Its cross-references resolve — §2.8 Service availability (docs/threat-model.md:226), §6.2 Implementation posture (:1234, fuzzing at :1245-1248), §8.12 Per-user UID isolation (:1497), and §5.4.4 is currently the last §5.4.x entry, so §5.4.5 is the correct next number.
  • The "Maintenance" note (docs/threat-model.md:9-15) does require additions to in-scope attack vectors to go through the RFC process; carrying the entry here satisfies it, as RFC-0002's proposed §8.12 did.
  • The ADR-0038 correction is routed as a post-acceptance erratum (ADR-0015), not an in-place edit, and the audit addition is routed to ADR-0024's Status field (docs/rfcs/0013-sftp-subsystem.md:44-46, :216-218).

The candidates examined and rejected this iteration:

  • Threat-model entry bundled into the SFTP RFC (docs/rfcs/0013-sftp-subsystem.md:220-259 vs docs/rfcs/README.md:41-48) — below threshold. The one-decision rule sends subsidiaries to separate ADRs, but the Maintenance note only requires the RFC process, and RFC-0002:451-461 set the precedent that a small schema/threat-model addition rides with the RFC that motivates it. Judgment, not a rule break.
  • [RFC-0013](rfcs/0013-sftp-subsystem.md) at docs/rfcs/0013-sftp-subsystem.md:247 does not resolve from within docs/rfcs/ — below threshold. The link is written for its destination document (docs/threat-model.md, where rfcs/… is correct, cf. docs/threat-model.md:1522), which the RFC states is where it is added verbatim. No rule is broken; a reader of the RFC's own copy sees a dead link. (No anchor → not reported as a finding.)

💡 Suggestions (nice to have)

  • docs/rfcs/0013-sftp-subsystem.md:234-235: the proposed §5.4.5 "Assets at risk" lists "the files the service account can reach", which reads awkwardly against threat-model §5.4.4's "None that QuantumSSH was protecting" (docs/threat-model.md:1020-1021) and §2.5/§8.12 (confinement beyond the service account "is not a QuantumSSH-side goal"). The entry itself concedes no confinement at :239-241. Consider naming the helper process's availability/integrity as the asset, and the service-account files as reachable-but-not-QQuantumSSH-protected, to match the corpus. (Anchor: threat model §5.4.4, §2.5, §8.12.)

Limitations

  • The RFC's OpenSSH citations (sftp-server.c, sftp-client.c, scp.c, session.c, PROTOCOL, tag V_10_6_P1) are not present in this tree (no network), so no line-number discrepancy was treated as a finding.
  • Commit signature verification via git log --format=%G? is meaningless here (no gpg.ssh.allowedSignersFile). Checked through the GitHub API instead: all three commits (a42fe9e, 27581c7, c636898) report commit.verification.verified = true with reason valid, and each carries a DCO Signed-off-by: trailer.
  • CI results were not observable from this environment; per the PR body they are commit-lint, the two build jobs, cargo deny, and openssh-interop.

Decision: 🟢 Approved

github run

gonzafg2 added a commit that referenced this pull request Oct 14, 2026
…ane per review)

Codex on #203: the frozen audit log is a new public compatibility
contract, an RFC under CLAUDE.md; and the freeze refines two accepted
RFCs (RFC-0010's error classes, RFC-0008's authenticated_identity), which
an ADR cannot. ADR-0044 becomes RFC-0014 (Draft, 14-day window).

Review findings folded in:
- server.config_error splits into `class` (RFC-0010's four classes plus
  the startup ones) and `error`, keeping RFC-0010's stable classes
  machine-readable (Codex);
- successful configuration load is recorded: server.started gains
  config_file, server.config_override joins the catalogue (Codex, §2.7);
- connection.refused keeps `limit`, superseding ADR-0028's `reason`
  explicitly (Codex);
- RFC-0008: authenticated_identity stays the proven key's fingerprint;
  certificate fields arrive additively, conditional on certificate
  authentication (Codex);
- exec.finished's `command` listed as a change against ADR-0024
  (claude-review);
- every failed attempt, the budget-exhausting one included, emits
  auth.failed — fixed in #204 (claude-review);
- failure_count is per connection; aggregate by IP (claude-review);
- all enumerations are open; changing an event's level is breaking
  (claude-review);
- the SFTP additions cite #194/#195 as proposed, not as existing ADRs
  (both reviewers).

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2
gonzafg2 marked this pull request as ready for review October 17, 2026 15:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T00:37:37.876263Z 7358c0f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gonzafg2
gonzafg2 marked this pull request as draft October 17, 2026 15:26
@opencode-agent

Copy link
Copy Markdown

PR Review: docs(rfc): RFC-0013 — SFTP subsystem in a first-party SFTP v3 re-exec helper (#194)

Decision: 🟢 Approved
Iteration: Review #4 (1 resolved, 2 open suggestions) — previous reviews: opencode #1, #2, #3; Codex completed with no findings
Lenses applied: Design decision (docs/rfcs/0013-sftp-subsystem.md) and governance/threat-model consistency. Rust and CI lenses are not applicable: the diff is one document, +380/−0, with no code or workflow changes.

Executive summary

RFC-0013 proposes serving subsystem "sftp" with a first-party, unsafe-free SFTP v3 server run as a single-threaded re-exec helper, fixing the protocol profile, filesystem semantics and audit record. The new commit c636898 carries the proposed threat-model §5.4.5 entry; its cross-references resolve and it follows the threat model's Maintenance rule. Measured against the five commitments and the threat model, no new finding reaches the ≥80 reporting bar; the two remaining items are prior suggestion-level open questions, not defects.

Previous issues

# Issue Status Notes
1 Mirror the ADR-0038 "SFTP brings multiplexing" correction as an annotated erratum ✅ resolved docs/rfcs/0013-sftp-subsystem.md:44-46; added in 27581c7
2 Scope bytes_received/bytes_sent to subsystems instead of every request type ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:209-212 still says "every request type"; :364-365 keeps it as unresolved question #3. Still below the reporting bar, as in reviews #2–#3
3 Align proposed §5.4.5 "Assets at risk" wording with §5.4.4/§2.5/§8.12 ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:234-235 still lists "the files the service account can reach"; re-examined this iteration and refuted as a rule break
4 Earlier candidates: ADR-0038 §1 reversal needs a superseding ADR; 14-day window; command on exec.finished ✅ no change needed Re-examined; all remain refuted or out of scope

New findings

No finding scored ≥80. The candidates examined and rejected this iteration:

  • Proposed §5.4.5 asset/mechanism vs §5.4.4, §2.5, §8.12 (docs/rfcs/0013-sftp-subsystem.md:228-241) — refuted. The threat model's "Assets at risk" field describes what a malicious peer can damage, not a QuantumSSH protection claim; §5.4.5 already concedes that path tricks map to no technique because Phase 2 grants no confinement (:239-241, :252-255). This overlaps the open suggestion in the table and is not a rule break.
  • PR marked ready on 2026-10-17 while the body promises Draft until 2026-10-26 — refuted. docs/rfcs/README.md:83-86 governs merge, not the ready flag; the PR is currently isDraft: true and mergedAt: null, so the 14-day comment period has not been cut short by any observable merge.
  • ADR-0038 §1's accepted subsystem refusal (docs/rfcs/0013-sftp-subsystem.md:11-24, :44-46) — refuted again. The RFC edits no ADR, routes subsidiary mechanics to implementing ADRs, and limits the erratum to the factual multiplexing prediction; an accepted ADR changes only by supersession or annotated errata (ADR-0015).

Limitations

  • The RFC's OpenSSH citations (sftp-server.c, sftp-client.c, scp.c, session.c, PROTOCOL, tag V_10_6_P1) could not be verified against the referenced tree, so no line-number discrepancy was treated as a finding.
  • Commit signatures were checked through the GitHub API rather than git log --format=%G?: all three commits (a42fe9e, 27581c7, c636898) report commit.verification.verified = true with reason valid, and each carries a DCO Signed-off-by: trailer.
  • Final comment-period close and any future merge are not observable while the PR remains open; no merge is reported.

Decision: 🟢 Approved

github run

@gonzafg2
gonzafg2 marked this pull request as ready for review October 17, 2026 21:43
@claude

claude Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@gonzafg2
gonzafg2 marked this pull request as draft October 17, 2026 21:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c636898919

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/rfcs/0013-sftp-subsystem.md Resolved
Comment thread docs/rfcs/0013-sftp-subsystem.md Resolved
Comment thread docs/rfcs/0013-sftp-subsystem.md Resolved
Comment thread docs/rfcs/0013-sftp-subsystem.md Resolved
Comment thread docs/rfcs/0013-sftp-subsystem.md Resolved
@opencode-agent

Copy link
Copy Markdown

PR Review: docs(rfc): RFC-0013 — SFTP subsystem in a first-party SFTP v3 re-exec helper (#194)

Decision: 🟢 Approved
Iteration: Review #5 (1 resolved, 2 open suggestions) — previous reviews #1–#4 in this thread; Codex review was still running at review time.
Lenses applied: Design decision (docs/rfcs/0013-sftp-subsystem.md), governance/process (docs/rfcs/README.md, ADR-0015), threat-model consistency (§2.5, §2.7, §2.8, §4.1, §5.4.4, §6.2, §8.12), and a code-reality cross-check of the RFC's claims about the existing tree. Rust and CI lenses are not applicable: the diff is one document, +380/−0, with no code or workflow changes.

Executive summary

RFC-0013 proposes serving subsystem "sftp" with a first-party, unsafe-free SFTP v3 server run as a single-threaded re-exec helper, fixing the protocol profile, filesystem semantics, audit record and the proposed threat-model §5.4.5 entry. Measured against the five commitments and the threat model it holds: no new dependency, no first-party unsafe, the post-auth parser is bounded and shaped for fuzzing, framing is fail-closed, PQ/AEAD posture is untouched, and both mandated exec.* fields are present. No finding reaches the ≥80 bar; the two actionable items from earlier reviews remain open, and the PR is now marked ready before the stated comment-period end, which is a process observation rather than a rule breach.

Previous issues

# Issue Status Notes
1 Mirror the ADR-0038 "SFTP brings multiplexing" correction as an annotated erratum ✅ resolved docs/rfcs/0013-sftp-subsystem.md:44-46; added in 27581c7
2 Scope bytes_received/bytes_sent to subsystems instead of every request type ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:209-212 still says "every request type"; :364-365 keeps it as unresolved question #3. Below the reporting bar
3 Align proposed §5.4.5 "Assets at risk" wording with §5.4.4/§2.5/§8.12 ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:234-235 still lists "the files the service account can reach"; re-examined and still refuted as a rule break
4 Earlier candidates: ADR-0038 §1 reversal needs a superseding ADR; 14-day window; command on exec.finished ✅ no change needed Re-examined; the RFC edits no ADR, the downstream ADR-0041 (stacked #195) records the partial supersession in ADR-0038's Status, and command on exec.finished is pre-existing code (channel.rs:598-611), not introduced here

New findings

No finding scored ≥80. The candidates examined and rejected this iteration:

  • PR marked ready on 2026-10-17 while the body promises Draft until 2026-10-26 — process, below threshold (35/100). docs/rfcs/README.md:83-86 constrains merge, not the GitHub ready flag; the PR is still OPEN with mergedAt: null, so no observable breach. The body's Draft statement is now stale, however. See Suggestions.
  • RFC §1 reverses ADR-0038 §1's accepted subsystem refusal without naming the superseding ADR — governance, below threshold (60/100). The RFC routes only the factual multiplexing prediction to an erratum (:44-46), while :11-24 reverses the decision. ADR-0015:36 says a decision change needs a new superseding ADR, not errata. The destination does exist downstream: ADR-0041 (stacked docs(adr): ADR-0041 and ADR-0042 — SFTP v3 server details; exec.finished byte counts (Proposed) #195) and feat(sftp): SFTP v3 subsystem in a re-exec helper; exec.finished byte counts (ADR-0041, ADR-0042) #196's Status pointer record the partial supersession, and :24 says "Implementing ADRs lock the details." Clarity suggestion only.
  • command asserted on exec.finished — out of scope. ADR-0024:43-44 lists command only on exec.started, but the current code already emits it on exec.finished (crates/quantumssh-core/src/channel.rs:598-611); the stacked implementation adds the ADR-0024 erratum. This RFC does not introduce the drift.
  • Proposed §5.4.5 asset wording — refuted as a rule break. The threat model's "Assets at risk" describes what an attack can damage; §5.4.5 already concedes no Phase-2 confinement (:239-241, :252-255). It remains the open suggestion in the table.
  • Byte counts on every exec.finished — refuted as a commitment-4 violation. It is an additive pre-freeze schema change, acknowledged at :216-218 and routed to ADR-0024's Status; the freeze-surface cost is judgment, not a hard-rule break. It remains the open suggestion in the table.
  • Security design — no flaw found. Fail-closed framing, the 256 KiB bound, the read clamp, fixed handle cap, symlink/path semantics, no Phase-2 confinement, helper isolation, no first-party unsafe, and no new dependency are coherent with ADR-0016/0023/0038 and threat-model §4.1/§8.12.

💡 Suggestions (nice to have)

  • docs/rfcs/0013-sftp-subsystem.md:3 / PR state: the PR is now isDraft: false while the body says it stays Draft until 2026-10-26. Since docs/rfcs/README.md:83-86 governs merge, this is not a breach yet; restore Draft or update the body, and do not merge before 2026-10-26.
  • docs/rfcs/0013-sftp-subsystem.md:22-24: add one sentence naming that the implementing ADR supersedes ADR-0038 §1's refusal. The erratum at :44-46 covers only the factual multiplexing prediction; a pointer would make the ADR-0015 routing explicit in the RFC itself. (Anchor: ADR-0015:36; CLAUDE.md "Do not edit an accepted ADR in place…".)
  • docs/rfcs/0013-sftp-subsystem.md:209-212: consider scoping the byte counts to request_type = "subsystem" to keep the 0.1.0 freeze delta minimal and match threat-model §5.4.4's "transferred N bytes" more closely. (Open suggestion, below threshold.)

Limitations

Decision: 🟢 Approved

github run

gonzafg2 added a commit that referenced this pull request Oct 17, 2026
…-relative link in the §5.4.5 block

Codex on #194:
- the helper exits 0 only at EOF on a packet boundary; EOF inside a
  packet is truncated input and takes the framing rule's fail-closed path;
- the §5.4.5 block links RFC-0013 by a repository-root path, which
  resolves both here and once copied into docs/threat-model.md.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Oct 17, 2026
Follows RFC-0013's clarification from Codex on #194; the implementation
already returns 2 for EOF inside a packet (read_packet).

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Oct 17, 2026
…, verbatim from the RFC

RFC-0013 now carries the root-relative link (Codex on #194); the entry
stays a verbatim copy.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
@opencode-agent

Copy link
Copy Markdown

PR Review: docs(rfc): RFC-0013 — SFTP subsystem in a first-party SFTP v3 re-exec helper (#194)

Decision: 🟢 Approved
Iteration: Review #6 (6 resolved, 5 open suggestions) — previous reviews #1–#5 in this thread; Codex completed with five inline findings
Lenses applied: Design decision (docs/rfcs/0013-sftp-subsystem.md), governance (docs/rfcs/README.md, ADR-0015), protocol conformance (draft-ietf-secsh-filexfer-02, OpenSSH V_10_6_P1). Rust and CI lenses are not applicable: the diff is one document, +381/-0, with no code or workflow changes.

Executive summary

RFC-0013 proposes serving subsystem "sftp" with a first-party, unsafe-free SFTP v3 server run as a single-threaded re-exec helper, fixing the protocol profile, filesystem semantics, audit record and the proposed threat-model §5.4.5 entry. Measured against the five commitments and the threat model it holds: no new dependency, no first-party unsafe, the post-auth parser is explicitly bounded and shaped for fuzzing, malformed framing is fail-closed, PQ/AEAD posture is untouched, and both mandated exec.* fields remain present. No new finding reaches the ≥80 bar; the remaining items are prior suggestion-level gaps.

Previous issues

# Issue Status Notes
1 Mirror the ADR-0038 "SFTP brings multiplexing" correction as an annotated erratum ✅ resolved docs/rfcs/0013-sftp-subsystem.md:44-46; added in 27581c7
2 Scope bytes_received/bytes_sent to subsystems instead of every request type ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:210-212, :365-366. Still a judgment call, not a rule break; the stacked ADR-0042 answers it
3 Align proposed §5.4.5 "Assets at risk" wording with §5.4.4/§2.5/§8.12 ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:235-236. Re-examined; the entry already concedes no Phase-2 confinement, so this is wording, not a rule break
4 Name the ADR that supersedes ADR-0038 §1's subsystem refusal ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:24, :44-46. Validated as refuted for a rule break: the RFC edits no ADR and routes mechanics to implementing ADRs; ADR-0041 (stacked #195) records the partial supersession in ADR-0038's Status
5 14-day comment period / PR marked ready before 2026-10-26 ✅ resolved The PR is isDraft: true again with mergedAt: null; docs/rfcs/README.md:83-86 governs merge, not the ready flag
6 command asserted on exec.finished ✅ no change needed Pre-existing ADR-0024/implementation drift (crates/quantumssh-core/src/channel.rs:598-611), not introduced by this RFC
7 Codex P1: commit lacks signature and DCO sign-off ✅ refuted, no action GitHub API reports commit.verification.verified = true, reason valid, for all four commits (a42fe9e, 27581c7, c636898, 832bcd5), each with a Signed-off-by: trailer. Local %G? returns N/E only because no gpg.ssh.allowedSignersFile is configured on the runner
8 Codex P2: rfcs/0013-sftp-subsystem.md link dead from within docs/rfcs/ ✅ resolved 832bcd5 changed the §5.4.5 copy to /docs/rfcs/0013-sftp-subsystem.md (:248)
9 Codex P2: exit 0 on mid-packet EOF conflicts with the framing rule ✅ resolved docs/rfcs/0013-sftp-subsystem.md:105-109 now limits exit 0 to EOF at a packet boundary; mid-packet EOF takes the fail-closed path
10 Codex P2: extension advertisement omits the required revision values ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:165-179 lists only names. OpenSSH requires "1" for all four; ADR-0041 §3 (stacked #195) records it. Below the bar because the RFC routes wire detail to implementing ADRs (:24)
11 Codex P2: empty path is not normalized to the session home ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:183-189. draft-02 §6.2 defines "" as the default directory; OpenSSH special-cases it for REALPATH/expand-path. The stock client never sends "", so no stock-client interop failure; worth one sentence, not a finding

New findings

No finding scored ≥80. The candidates examined and rejected this iteration:

  • ADR-0038 §1 reversal needs a superseding ADR (docs/rfcs/0013-sftp-subsystem.md:11-24, :44-46) — refuted. The RFC calls only the factual multiplexing prediction an erratum; it edits no accepted ADR and says "Implementing ADRs lock the details" (:24). Repo precedent (RFC-0005/0006/0008/0009) does not require a Draft RFC to name its future implementing ADR, and ADR-0041 in the stacked PR records the partial supersession pointer.
  • Audit-schema change packaged into the SFTP RFC (docs/rfcs/0013-sftp-subsystem.md:204-219, :365-366) — refuted as a rule break. request_type already exists from ADR-0038 §9; the byte fields are routed to ADR-0024's Status field and answered by ADR-0042 in the stack. Question 3 states a proposed default, so it is a consultation, not a self-contradiction.
  • Commit signature/DCO (Codex P1) — refuted by the GitHub API and the commit trailers, as above.
  • Extension revision values / empty-path normalization — real but below the reporting bar; tracked as open suggestions Decide on HSTS preload list submission (target: ~2026-07-10) #10 and Tighten DMARC policy: p=none -> p=quarantine after 30+ days of reports #11, not new findings.
  • Security design — no flaw found. Fail-closed framing, the 256 KiB bound, the read clamp, fixed handle cap, symlink/path semantics, no Phase-2 confinement, helper isolation, no first-party unsafe, and no new dependency are coherent with ADR-0016/0023/0038 and threat-model §4.1/§8.12.

Limitations

Decision: 🟢 Approved

github run

@opencode-agent

Copy link
Copy Markdown

APIError: Insufficient Balance (request_id: 3f8f0594-c54d-4e53-9d84-8e77507277a3)

github run

@gonzafg2

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 6412ba1439

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@opencode-agent

Copy link
Copy Markdown

APIError: Insufficient Balance (request_id: 571d23a6-3410-4897-b400-abb15dfb6138)

github run

@gonzafg2
gonzafg2 marked this pull request as ready for review October 29, 2026 00:26
@opencode-agent

Copy link
Copy Markdown

APIError: Insufficient Balance (request_id: d8537335-e53b-4389-9637-7e2b8cdb1878)

github run

gonzafg2 added a commit that referenced this pull request Oct 29, 2026
… erratum

The implementing PR records the corrected "SFTP brings multiplexing"
statement as a post-acceptance erratum on ADR-0038 (ADR-0015), the
corpus's discoverability path. From opencode's review of #194.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2
gonzafg2 force-pushed the docs/rfc-0013-sftp-subsystem branch from 1d70b67 to 67f61d9 Compare October 29, 2026 00:27
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
…-relative link in the §5.4.5 block

Codex on #194:
- the helper exits 0 only at EOF on a packet boundary; EOF inside a
  packet is truncated input and takes the framing rule's fail-closed path;
- the §5.4.5 block links RFC-0013 by a repository-root path, which
  resolves both here and once copied into docs/threat-model.md.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
@opencode-agent

Copy link
Copy Markdown

APIError: Insufficient Balance (request_id: 3d0dacb3-f943-464f-85cb-20d2883ef304)

github run

… helper

Proposes serving `subsystem "sftp"` with QuantumSSH's own SFTP v3 server,
a single-threaded helper mode of the quantumssh binary started as an
ordinary pipe child, so it inherits ADR-0038's process supervision and
is the place Phase 3 drops privileges. It sets the protocol profile
(version 3, OpenSSH's 256 KiB bound, limits/posix-rename/fsync/
expand-path), the filesystem semantics as the service account, and the
audit record (request_type "subsystem", bytes per direction). It also
notes that SFTP needs no channel multiplexing: sftp and scp use one
session channel.

Alternatives weighed: OpenSSH's sftp-server (C, host-dependent),
russh-sftp (trust base, russh ecosystem), an in-process async server
(Phase-3 incompatible), and waiting for Phase 3.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
… erratum

The implementing PR records the corrected "SFTP brings multiplexing"
statement as a post-acceptance erratum on ADR-0038 (ADR-0015), the
corpus's discoverability path. From opencode's review of #194.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
A new in-scope attack vector goes through the RFC process (threat
model, Maintenance), so the §5.4.5 "SFTP request handling" entry is
part of this RFC and the implementation PR adds it verbatim. From
opencode's review of #195.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
…-relative link in the §5.4.5 block

Codex on #194:
- the helper exits 0 only at EOF on a packet boundary; EOF inside a
  packet is truncated input and takes the framing rule's fail-closed path;
- the §5.4.5 block links RFC-0013 by a repository-root path, which
  resolves both here and once copied into docs/threat-model.md.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
… working directory

The OpenSSH 10.6 client enables each extension only when its version
string is exactly "1" (sftp-client.c:499-536), so the table now says so.
SFTP v3 §6.2 makes an empty path the user's default directory; the helper
reads it as ".", except SYMLINK's target, which is link content.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2
gonzafg2 force-pushed the docs/rfc-0013-sftp-subsystem branch from 67f61d9 to dde1532 Compare October 29, 2026 00:32
@gonzafg2

Copy link
Copy Markdown
Owner Author

@claude review this RFC (RFC-0013). The PR left Draft after its 14-day window, and the claude-review run 00:27 finished green without posting. Head dde1532 is rebased on main with signed commits; the RFC text is unchanged by the rebase.

@claude

claude Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @gonzafg2's task in 33s —— View job


Review of RFC-0013 (head dde1532)

Verdict: no blocking issues. The RFC is ready to accept once the open questions are settled. I read the whole document and checked it against CLAUDE.md, ADR-0038 and ADR-0040.

I did not check the OpenSSH V_10_6_P1 line citations. That tree isn't available in this environment, so I took them as written. The earlier threads on the extension version string ("1"), the empty path and EOF at a packet boundary are all addressed in the current text (§3, §4, §2).

Against the five commitments

  1. Memory safety: holds. The helper is first-party Rust with no unsafe. The getpwnam limitation is handled by using numeric uid/gid in the NAME longname, so the RFC does not need unsafe.
  2. Post-quantum: unaffected, since the RFC does not touch the transport.
  3. Zero legacy: unaffected. Version 3 is the only SFTP version, and OpenSSH supports no other.
  4. Small surface:
    • The RFC adds no dependency and no config key.
    • The extension set is minimal and each extension is justified.
    • The bytes_* audit fields are the only schema widening, and they are routed to ADR-0024's Status field.
  5. Open: unaffected.

Hard security rules

  • Fail-closed framing: the 256 KiB bound, truncation and an INIT-first requirement end the session with a nonzero exit.
  • Allocations: each attacker-controlled size is bounded, except one gap noted below.
  • Audit: authenticated_identity and executing_uid stay on every exec.* event, and command stays a structured field. No paths or contents are logged.
  • Process isolation: the parser runs outside the host-key process.

Suggestions (none blocking)

  1. Handle cap (§3, open question 4). The RFC says the cap is "fixed" and that limits@ reports it, yet no value is given. This is the one attacker-controlled resource without a number. Pick a value in the RFC or in the implementing ADR before acceptance; 1024 is a reasonable start, and it must stay below the helper's fd limit. The same applies to the symlink depth for REALPATH ("bounded depth").
  2. Per-key restrictions (§1 and the guide-level "same access" claim). The claim "SFTP grants no access that the server does not already grant" is true today. ADR-0040 refuses any authorized_keys line with options, so no restricted key can exist. Once restrictions are enforced, a key with command= or restrict must not be able to open subsystem sftp. One sentence in §1 would pin that: subsystem is gated by the same per-key restrictions as shell and exec. Otherwise the future work could add a bypass without anyone noticing. "Future possibilities" mentions a read-only mode but not this gating.
  3. Unknown request types (§3). Answering OP_UNSUPPORTED is better than OpenSSH's silence. The RFC should say that the request id is read from the fixed position after the type byte, and that a packet too short to carry an id is treated as truncation and ends the session. Otherwise the "exactly one response" rule has an edge case.
  4. Byte counts (open question 3). I lean toward your proposed default of every request type. It gives one uniform exec.finished, and ADR-0024 is not frozen yet. The RFC could state plainly that the SFTP count includes framing, as §5 already does, so nobody reads it as file-content bytes.
  5. §5.4.5 "Assets at risk". "The files the service account can reach" reads as a protection claim. §5.4.4 and §8.12 say QuantumSSH does not protect those. Wording such as "reachable by the service account, which QuantumSSH does not protect in Phase 2" would match the rest of the corpus. This repeats an earlier suggestion and is wording only.
  6. ADR-0038 §1 reversal. The RFC calls the multiplexing prediction an erratum, which fits ADR-0015. Its subsystem refusal is a decision, though, not a prediction, so ADR-0015 says it needs a superseding or partially superseding ADR. The stacked docs(adr): ADR-0041 and ADR-0042 — SFTP v3 server details; exec.finished byte counts (Proposed) #195 appears to record that. A short pointer in §1 would make it visible from the RFC.

Process

  • The 14-day comment period ends 2026-10-26, and today is 2026-10-29, so the window has closed.
  • The document is still Status: Draft. The status flip and the "Implementation PR" link are bookkeeping for acceptance.
  • Open questions 1–4 need a recorded answer first. Suggestion 1 above could close question 4.

I made no changes to the branch.

…R-0038 pointer

From Claude's review of the final head:
- Once authorized_keys options are enforced, a restriction that limits
  shell and exec limits subsystem too.
- An unknown request type's id is the uint32 after the type byte, and a
  packet too short for one takes the framing rule's fail-closed path.
- The §5.4.5 assets line says QuantumSSH does not protect the service
  account's files from that account in Phase 2 (§8.12).
- §1 points at ADR-0041 (#195, TBD) for superseding ADR-0038 §1's
  subsystem refusal.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2

Copy link
Copy Markdown
Owner Author

Thanks. Applied in 7358c0f, point by point:

  1. Handle cap and symlink depth: no RFC change. Open question 4 leaves the cap to the implementing ADR. ADR-0041 (docs(adr): ADR-0041 and ADR-0042 — SFTP v3 server details; exec.finished byte counts (Proposed) #195) fixes it at 256 open handles, which [email protected] reports, and REALPATH at 32 links (SYMLOOP_MAX).
  2. Per-key restrictions: added to §1. Once authorized_keys options are enforced (ADR-0040 refuses them until then), a restriction that limits shell and exec limits subsystem too.
  3. Unknown request types: added to §3. The id is the uint32 after the type byte, whatever the type, and a packet too short for one takes the framing rule's fail-closed path. The helper in feat(sftp): SFTP v3 subsystem in a re-exec helper; exec.finished byte counts (ADR-0041, ADR-0042) #196 already does this: it reads the id before dispatching.
  4. Byte counts: no change. §5 already says the SFTP count includes framing.
  5. §5.4.5 assets: now ends "which QuantumSSH does not protect from that account in Phase 2 (§8.12)". The same wording goes into feat(sftp): SFTP v3 subsystem in a re-exec helper; exec.finished byte counts (ADR-0041, ADR-0042) #196's docs/threat-model.md, which carries the block verbatim.
  6. ADR-0038 §1: §1 now says the refusal is a decision, superseded through ADR-0041 (docs(adr): ADR-0041 and ADR-0042 — SFTP v3 server details; exec.finished byte counts (Proposed) #195, TBD).

@gonzafg2

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 7358c0f573

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gonzafg2
gonzafg2 merged commit f2ce221 into main Oct 29, 2026
11 checks passed
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
…hed byte counts (Proposed)

Implementing ADRs for RFC-0013 (Draft, #194):

- ADR-0041 locks the SFTP server: the subsystem request rules, the
  helper dispatch and the Config::helper rename, OpenSSH's 256 KiB and
  read bounds, a 256-handle cap, exactly one response per request, the
  operation mapping on std::fs/rustix, OpenSSH's RENAME and SYMLINK
  semantics, the four advertised extensions, fixed status messages, and
  a numeric, UTC longname. It answers the RFC's open questions 1, 2 and 4.
- ADR-0042 adds bytes_received and bytes_sent to exec.finished for every
  request type, counted at the channel driver, realising threat model
  §5.4.4's record (the RFC's question 3).

Both stay Proposed until RFC-0013 is accepted and the implementation
lands.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
Follows RFC-0013's clarification from Codex on #194; the implementation
already returns 2 for EOF inside a packet (read_packet).

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
#194 merged on 2026-10-28 (f2ce221). Per docs/rfcs/README.md step 6,
the merge is the acceptance, and the Status flips in a follow-up, as
#214 did for RFC-0012. ADR-0041's and ADR-0042's Related lines no longer
call it a Draft.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>
@claude

claude Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

PR Review: docs(rfc): RFC-0013 — SFTP subsystem in a first-party SFTP v3 re-exec helper (#194)

Decision: 🟢 Approved
Iteration: Review #2 for claude (previous: claude Oct-17); opencode ran 6 iterations, Codex found no issues on 6412ba1
Lenses applied: Design decision (docs/rfcs/0013-sftp-subsystem.md), governance/process (ADR-0015, docs/rfcs/README.md), threat-model consistency (§4.1, §5.4.4, §8.12), CLAUDE.md five commitments

Executive summary

RFC-0013 proposes serving subsystem "sftp" with a first-party, unsafe-free SFTP v3 server run as a single-threaded re-exec helper. Against the five commitments and the threat model it holds: no first-party unsafe, no new dependency, fail-closed framing at every attacker-controlled boundary (256 KiB limit, EOF mid-packet, first-packet rule), the type-state channel exclusivity is respected (subsystem only in Idle, refused after pty-req), and both mandated exec.* fields (authenticated_identity, executing_uid) plus a structured command field are present. No finding reaches the ≥80 reporting bar.

Previous issues

# Issue Status Notes
1 Mirror ADR-0038 "SFTP brings multiplexing" correction as a post-acceptance erratum (ADR-0015) ✅ resolved docs/rfcs/0013-sftp-subsystem.md:44-46 routes it to the implementing PR
2 Name the superseding ADR for ADR-0038 §1's subsystem refusal ✅ resolved docs/rfcs/0013-sftp-subsystem.md:75-76 now names ADR-0041 (#195, TBD) explicitly
3 Extension advertisement must include revision strings ✅ resolved Extensions table at docs/rfcs/0013-sftp-subsystem.md:171 adds "each with version string "1""
4 Exit 0 on mid-packet EOF contradicts fail-closed framing ✅ resolved docs/rfcs/0013-sftp-subsystem.md:105-109 limits exit 0 to EOF at a packet boundary; mid-packet EOF is fail-closed
5 rfcs/0013-sftp-subsystem.md link dead in §5.4.5 copy ✅ resolved Link changed to /docs/rfcs/0013-sftp-subsystem.md
6 Scope bytes_received/bytes_sent to subsystems only ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:210-212 still proposes every request type; Unresolved question #3 tracks it
7 Align §5.4.5 "Assets at risk" wording with §5.4.4/§2.5/§8.12 ❌ open (suggestion) docs/rfcs/0013-sftp-subsystem.md:234-235 still lists "the files the service account can reach"; §5.4.5's third test-handle bullet already says "Any path the service account can reach is reachable" — this is cosmetic only

New findings

No finding scored ≥80. The single candidate examined and rejected this iteration:

  • §5.4.5 test handle and Alternative 3 isolation claim (docs/rfcs/0013-sftp-subsystem.md:252-254) — refuted. The statement "outside the server process that holds the host key" is about memory isolation: a parser memory-corruption bug in the helper cannot reach the server's in-process key material. This is accurate. The same section's third test-handle bullet explicitly says "Any path the service account can reach is reachable" — the RFC does not claim file-access isolation. Confidence after cross-check: 65 (below threshold).

Limitations

Decision: 🟢 Approved

gonzafg2 added a commit that referenced this pull request Oct 29, 2026
…hed byte counts (Proposed) (#195)

* docs(adr): ADR-0041 and ADR-0042 — SFTP v3 server details; exec.finished byte counts (Proposed)

Implementing ADRs for RFC-0013 (Draft, #194):

- ADR-0041 locks the SFTP server: the subsystem request rules, the
  helper dispatch and the Config::helper rename, OpenSSH's 256 KiB and
  read bounds, a 256-handle cap, exactly one response per request, the
  operation mapping on std::fs/rustix, OpenSSH's RENAME and SYMLINK
  semantics, the four advertised extensions, fixed status messages, and
  a numeric, UTC longname. It answers the RFC's open questions 1, 2 and 4.
- ADR-0042 adds bytes_received and bytes_sent to exec.finished for every
  request type, counted at the channel driver, realising threat model
  §5.4.4's record (the RFC's question 3).

Both stay Proposed until RFC-0013 is accepted and the implementation
lands.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 applies RFC-0013's §5.4.5 entry; ADR-0038 Status pointer for request_type

- The threat model's new §5.4.5 entry now comes from RFC-0013 (RFC
  lane), and the implementation PR adds it verbatim; §5.4.4 gets only a
  factual pointer to ADR-0042.
- The implementation PR also records on ADR-0038's Status that this ADR
  extends §9's request_type values with "subsystem".

From opencode's review of #195.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 — APPEND writes, CLOSE errors, OpenSSH's full RENAME, ADR-0038 §1 pointer

From the reviews of #195 (Codex, claude-review, opencode), checked
against openssh-portable V_10_6_P1 and rustix 1.1.5:

- WRITE on an APPEND handle uses write_all, as OpenSSH skips lseek for
  O_APPEND; positional writes never carry APPEND, since pwrite ignores
  O_APPEND on macOS (POSIX).
- CLOSE syncs a written file with sync_data before dropping it and maps
  a failure, the only safe way to see a deferred write error: File's
  Drop ignores close errors and rustix's close is unsafe and returns
  nothing. The fdatasync per written file is a recorded cost.
- RENAME follows OpenSSH fully: the EOPNOTSUPP/ENOSYS/EXDEV fallback to
  check-then-rename, and removing the spare link when unlink fails.
- The planned ADR-0038 Status pointer names §1 (subsystem now honoured)
  as well as §9.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 — OpenSSH's OPEN flags, realpath and expand-path; EPERM link fallback; no sync on special files

Codex on #195, each checked against openssh-portable V_10_6_P1:
- OPEN builds OpenSSH's flags_from_portable flags with rustix::fs::open:
  READ|APPEND stays read-only and READ|CREAT is valid, which OpenOptions
  cannot express;
- REALPATH follows OpenSSH's sftp-realpath.c, the final symlink included
  (32 links), so a dangling final symlink resolves to its target;
- expand-path takes ~ from the working directory ($HOME or /), as
  process_extended_expand uses getcwd;
- RENAME's link fallback also covers Linux EPERM (LINK_OPNOTSUPP_ERRNO);
- CLOSE syncs written regular files only: fdatasync fails with EINVAL on
  FIFOs, sockets and devices.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 — RENAME's existence check does not follow symlinks; future mtimes show the year

Codex on #196:
- every RENAME existence check uses symlink_metadata, so a dangling
  symlink at the destination is never replaced (stricter than OpenSSH's
  stat, in the direction of the no-overwrite invariant);
- the longname uses the time form only for an mtime in the six months
  up to now; a future mtime gets the year (OpenSSH's sftp-common.c rule).

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 — cap checked before OPEN; non-blocking SETSTAT size; READDIR errors and metadata

Second review round on #196:
- the handle cap is checked before the open: a refused OPEN has no side
  effect;
- SETSTAT's size on a path uses a write-only, non-blocking open and
  ftruncate, so a FIFO with no reader fails at once (OpenSSH: truncate(2));
- READDIR's metadata comes through the open directory without following
  symlinks; unreadable entries are skipped (as OpenSSH's failed lstat);
  a failed directory read is the reply's status, EOF only when exhausted.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 — exit 0 only at EOF on a packet boundary (RFC-0013)

Follows RFC-0013's clarification from Codex on #194; the implementation
already returns 2 for EOF inside a packet (read_packet).

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 — Alternative 1 lists every rustix use

claude-review on #195: the rationale said rustix is used only for
utimensat, but §4 now also uses it for OPEN's flag mapping and for
SETSTAT's non-blocking size change on a path.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 — an empty path is read as "." (RFC-0013 §4)

OpenSSH's sftp-server normalizes the empty path only in REALPATH and
expand-path; the helper does it for every path argument, as SFTP v3
§6.2 defines, except SYMLINK's target.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(rfc): mark RFC-0013 as Accepted

#194 merged on 2026-10-28 (f2ce221). Per docs/rfcs/README.md step 6,
the merge is the acceptance, and the Status flips in a follow-up, as
#214 did for RFC-0012. ADR-0041's and ADR-0042's Related lines no longer
call it a Draft.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

---------

Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
…, verbatim from the RFC

RFC-0013 now carries the root-relative link (Codex on #194); the entry
stays a verbatim copy.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
… counts (ADR-0041, ADR-0042) (#196)

* feat(sftp): SFTP v3 subsystem in a re-exec helper; exec.finished byte counts (ADR-0041, ADR-0042)

Implements RFC-0013 through ADR-0041 and ADR-0042:

- sftp.rs: a first-party SFTP version 3 server, run by the binary's
  --quantumssh-internal-sftp-server helper mode (dispatched in main
  after the PTY helper). Single-threaded and synchronous over fds 0/1,
  starting in $HOME. OpenSSH's 256 KiB packet bound and read clamp, a
  256-handle cap, exactly one response per request, fail-closed on
  malformed input (exit 2), fixed STATUS messages. Operations on
  std::fs plus rustix::fs::utimensat; APPEND writes are sequential,
  CLOSE syncs written files to surface deferred errors, RENAME and
  SYMLINK follow OpenSSH. Extensions: posix-rename, fsync, limits,
  expand-path (~ only). Longnames carry numeric owners and UTC dates.
- channel.rs: `subsystem "sftp"` is honoured in Idle with no pending PTY
  and a helper configured; the child is the ordinary pipe child
  (exec::spawn_sftp). exec.* carry request_type "subsystem" and command
  "sftp". exec.finished gains bytes_received and bytes_sent for every
  request type, counted at the driver.
- server::Config::pty_helper is renamed Config::helper: one binary
  hosts both helpers.
- Tests: sftp.rs unit tests; a core test for the no-helper refusal;
  binary-crate tests that re-exec the real binary for a 100 KB
  round trip and the refusals; sftp -b and scp both ways in the OpenSSH
  interop gate.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): accept ADR-0041 and ADR-0042 with the SFTP implementation; errata and threat model §5.4.5

- ADR-0041 and ADR-0042 flip to Accepted with this implementing PR, on
  RFC-0013's acceptance (2026-10-26; adjust if merged another day).
- ADR-0038's Status records the partial supersession of §1 (subsystem
  now honoured) and §9 (request_type "subsystem"); an erratum corrects
  "SFTP brings multiplexing".
- ADR-0024's Status adds ADR-0042's fields; an erratum adds `command`
  to the exec.finished row, which the code emitted at acceptance
  (a3921d5).
- The threat model gains RFC-0013's §5.4.5 entry verbatim, and §5.4.4
  names the byte counts as its record.
- CHANGELOG, README and CLAUDE.md list SFTP as landed.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* fix(sftp): OpenSSH's OPEN flags, realpath and expand-path; safer RENAME; INIT, CLOSE, READDIR and stdin credit fixes

Codex on #195 and #196, each checked against openssh-portable V_10_6_P1:
- OPEN uses rustix::fs::open with flags_from_portable's flags:
  READ|CREAT creates a read-only handle, READ|APPEND grants no write;
- REALPATH ports sftp-realpath.c: every symlink is followed, the final
  one included (32 links), and only a missing last component is
  accepted, so a dangling final symlink resolves to its target;
- expand-path takes ~ from the working directory ($HOME or /) that the
  helper passes in, as OpenSSH's getcwd; relative REALPATHs use it too;
- RENAME's existence checks use symlink_metadata (a dangling symlink at
  the destination is never replaced) and the link fallback covers Linux
  EPERM (LINK_OPNOTSUPP_ERRNO);
- CLOSE syncs only written regular files (fdatasync fails with EINVAL on
  devices, FIFOs and sockets);
- INIT must carry its version; a truncated INIT ends the session;
- READDIR reads each entry's metadata through the open directory
  (DirEntry::metadata), not a rebuilt path;
- the longname uses the year for a future mtime (sftp-common.c rule),
  via a pure ls_date;
- pump_stdin credits each successful partial write, so a child that
  reads a prefix and exits is counted in bytes_received (ADR-0042).

Tests: init_without_a_version_ends_the_session,
open_maps_flags_independently, close_of_a_written_device_succeeds,
realpath_follows_symlinks_the_final_one_included, the extended
realpath_resolves_a_missing_last_component,
rename_does_not_replace_a_dangling_symlink, ls_dates_follow_openssh,
pump_stdin_credits_partial_writes (fails with the old write_all).
macOS and Linux (rust:1.99.0-bookworm) suites pass; local interop with
OpenSSH 10.3 passes openssh_sftp and openssh_scp.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* fix(sftp): no side effect from a refused OPEN; non-blocking SETSTAT size; partial-write latch; READDIR errors; drain stdin credits

Second review round on #196 (Codex and claude-review):
- the handle cap is checked before the open, so an OPEN refused at the
  cap has not created or truncated the file (claude-review);
- SETSTAT's size opens the path write-only and non-blocking, then
  ftruncate: a FIFO with no reader fails at once instead of hanging the
  single-threaded helper, matching OpenSSH's truncate(2) (claude-review);
- WRITE sets the handle's written latch as soon as any byte reaches the
  file, so CLOSE syncs after a write that failed part-way (Codex);
- a failed directory read is reported as the READDIR status, after any
  names already gathered, instead of looking like EOF (Codex);
- exec.finished drains the stdin credits still queued when the channel
  closes, so bytes the child received are counted (Codex, ADR-0042).

Tests: a_refused_open_leaves_the_file_untouched,
setstat_size_on_a_fifo_does_not_block. macOS and Linux suites pass;
local interop with OpenSSH 10.3 passes openssh_sftp and openssh_scp.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(threat-model): §5.4.5 links RFC-0013 by its repository-root path, verbatim from the RFC

RFC-0013 now carries the root-relative link (Codex on #194); the entry
stays a verbatim copy.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(sftp): the module doc names every rustix use

Matches ADR-0041 Alternative 1 (claude-review on #195).

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* fix(sftp): an empty path names the working directory

SFTP v3 (draft-ietf-secsh-filexfer-02 §6.2) defines an empty path as the
user's default directory, but path arguments went to std::fs unchanged,
so STAT, OPENDIR and the other path requests answered NO_SUCH_FILE for
"". path_arg now reads it as ".". SYMLINK's target is link content and
stays as sent.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* fix(sftp): ~//x in expand-path stays under the working directory

PathBuf::join drops the base when the suffix is absolute, so ~//upload
resolved to /upload. The helper now concatenates the working directory,
a slash and the suffix, as OpenSSH's "%s/%s" does
(sftp-server.c:1569-1572), and REALPATH collapses the repeated slash.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(threat-model): §5.4.5 assets line, verbatim from RFC-0013 7358c0f

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(adr): ADR-0041 and ADR-0042 dates follow RFC-0013's acceptance (2026-10-28)

#194 merged on 2026-10-28, not on the 2026-10-26 the drafts assumed.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* ci: re-run the required checks against the main base

The rebuilt branch was pushed while the PR still targeted the ADR
branch, so the main-only workflows did not run on 967a073.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* fix(sftp): REALPATH reads components through a cursor, not drain

left.drain(..=i) shifted the rest of the buffer for every component, so
a 256 KiB path of ./ cost quadratic time: about 280 ms against 8 ms with
the cursor on a debug build. A test pins a packet-sized path.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(sftp): FIFO OPEN blocks as in OpenSSH; parsers vs handlers in §5.4.5

ADR-0041 §4 says that opening a FIFO with no peer blocks the helper, as
it blocks OpenSSH's sftp-server, and that closing the channel kills the
process group. Threat model §5.4.5 no longer calls the whole parser a
pure function: the framing and field parsers are, and the handlers act
on the filesystem, so the Phase-3 harness drives them in a scratch
directory. RFC-0013, now accepted, keeps its original wording.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

---------

Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
…ane per review)

Codex on #203: the frozen audit log is a new public compatibility
contract, an RFC under CLAUDE.md; and the freeze refines two accepted
RFCs (RFC-0010's error classes, RFC-0008's authenticated_identity), which
an ADR cannot. ADR-0044 becomes RFC-0014 (Draft, 14-day window).

Review findings folded in:
- server.config_error splits into `class` (RFC-0010's four classes plus
  the startup ones) and `error`, keeping RFC-0010's stable classes
  machine-readable (Codex);
- successful configuration load is recorded: server.started gains
  config_file, server.config_override joins the catalogue (Codex, §2.7);
- connection.refused keeps `limit`, superseding ADR-0028's `reason`
  explicitly (Codex);
- RFC-0008: authenticated_identity stays the proven key's fingerprint;
  certificate fields arrive additively, conditional on certificate
  authentication (Codex);
- exec.finished's `command` listed as a change against ADR-0024
  (claude-review);
- every failed attempt, the budget-exhausting one included, emits
  auth.failed — fixed in #204 (claude-review);
- failure_count is per connection; aggregate by IP (claude-review);
- all enumerations are open; changing an event's level is breaking
  (claude-review);
- the SFTP additions cite #194/#195 as proposed, not as existing ADRs
  (both reviewers).

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>
gonzafg2 added a commit that referenced this pull request Oct 29, 2026
…sioned JSON contract (#203)

* docs(adr): ADR-0044 — freeze the audit-log schema as version 1 in a project-owned JSON envelope (Proposed)

The first item of the 0.1.0 freeze checklist. The JSON log becomes a
project-owned, versioned contract:

- envelope: one flat object per line — schema_version (1), timestamp,
  level, event (catalogue) or message (diagnostics), peer_addr, then the
  event's fields; no target, span name or span list; a FormatEvent in
  the binary encoding with serde_json (already in the build);
- the version-1 catalogue: ADR-0024's events plus rekey.completed,
  connection.refused and ADR-0038's fields, all on the non-suppressible
  audit tier (six events move there);
- server.config_error's `message` field becomes `error` (today it
  duplicates the JSON key that holds the event name);
- compatibility: additive changes (new event, field or open-enumeration
  value) keep version 1; anything else bumps it with an ADR and a
  CHANGELOG migration note.

The inventory also found audit events without peer_addr — fixed in #202.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(rfc): RFC-0014 — audit-log schema version 1 (was ADR-0044; RFC lane per review)

Codex on #203: the frozen audit log is a new public compatibility
contract, an RFC under CLAUDE.md; and the freeze refines two accepted
RFCs (RFC-0010's error classes, RFC-0008's authenticated_identity), which
an ADR cannot. ADR-0044 becomes RFC-0014 (Draft, 14-day window).

Review findings folded in:
- server.config_error splits into `class` (RFC-0010's four classes plus
  the startup ones) and `error`, keeping RFC-0010's stable classes
  machine-readable (Codex);
- successful configuration load is recorded: server.started gains
  config_file, server.config_override joins the catalogue (Codex, §2.7);
- connection.refused keeps `limit`, superseding ADR-0028's `reason`
  explicitly (Codex);
- RFC-0008: authenticated_identity stays the proven key's fingerprint;
  certificate fields arrive additively, conditional on certificate
  authentication (Codex);
- exec.finished's `command` listed as a change against ADR-0024
  (claude-review);
- every failed attempt, the budget-exhausting one included, emits
  auth.failed — fixed in #204 (claude-review);
- failure_count is per connection; aggregate by IP (claude-review);
- all enumerations are open; changing an event's level is breaking
  (claude-review);
- the SFTP additions cite #194/#195 as proposed, not as existing ADRs
  (both reviewers).

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(rfc): RFC-0014 — config_file on server.config_error too

Codex on #203: a startup failure after a successful config load (host
key, authorized_keys, runtime, bind) returns before server.started, so
the error record could not name the configuration that produced it.
config_file is now on every server.config_error as well (the canonical
path once resolved, the path as given if that failed, "" without
--config), so each error record stands on its own.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(rfc): RFC-0014 — no edits to accepted RFCs; fingerprint and override-key formats

Codex on #203:
- accepted RFCs are not edited in place (docs/rfcs/README.md, "After
  acceptance"): only ADR-0024 and ADR-0028 gain Status pointers;
  RFC-0010 and RFC-0008 keep their text and this RFC states what it
  supersedes;
- host_key_fingerprint's representation is frozen: `SHA256:` + unpadded
  standard base64 of SHA-256 over the public-key blob (OpenSSH's format);
- server.config_override's `key` values are the TOML paths
  (server.listen, server.host_key, auth.authorized_keys,
  server.handshake_timeout, logging.format); new keys use the same form.

Refs #109

Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(rfc): RFC-0014 — a superseding ADR, not Status pointers, changes ADR-0024/0028/0029

docs/adr/README.md allows an accepted ADR to change only through a
superseding ADR, so the implementing PR adds one that supersedes the
listed parts of ADR-0024, ADR-0028 and ADR-0029, as ADR-0031 does for
ADR-0008. ADR-0029's info-level override diagnostic and RFC-0010's
"no new audit event names" clause join §6, since server.config_override
changes both. RFC-0012 is cited as proposed (#172, TBD).

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(rfc): RFC-0014 — SFTP's fields are version 1; references brought up to date

#196 landed the SFTP stack before the freeze, so request_type subsystem
and exec.finished's bytes_received and bytes_sent move from the planned
additive changes into the version-1 catalogue (§3, §4), with command
"sftp" for the subsystem. RFC-0012 is cited as accepted, the two audit
gaps as fixed (#202, #204), and ADR-0024's command erratum as landed
with #196.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(rfc): RFC-0014 — pin kex.failed's reason tokens; summary count; SFTP wording

kex.failed's reason was "no-hybrid-kex, no-strict-kex, …". §4 now lists
the eleven tokens the transport emits with disconnect code 3 and keeps
the enumeration open, as for the override keys. The Summary counts five
documents, not three decisions, and the SFTP note moves out of the
planned-change list.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

* docs(rfc): RFC-0014 — exit_status sentinels, full control-character escape, threat-model qualifiers

From claude-review on 4a9b58f:
- §4 pins exit_status: the exit code, 128 + n for a signal (also with
  exit-signal on the wire), and 127 when the child could not be started
  or waited on or no status was recorded.
- §2 and §7: the JSON encoder escapes every char::is_control character
  (C0, DEL, C1) as \u00XX, the set the human formatter escapes;
  serde_json alone covers only C0.
- Three threat-model citations (§2.7, §8.12) carry the qualifier.

Claude-Session: https://claude.ai/code/session_01QpBZ4qUr3ypV22CvmVwwHp
Signed-off-by: Gonzalo Fleming <[email protected]>

---------

Signed-off-by: Gonzalo Fleming <[email protected]>
@gonzafg2
gonzafg2 deleted the docs/rfc-0013-sftp-subsystem branch December 1, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation rfc Request for comments / design proposal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant