Repository navigation
fix(auth): audit the failure that exhausts the attempt budget (ADR-0024) - #204
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
APIError: Insufficient Balance (request_id: b11f2979-806e-4af8-9b09-553ba5ae5682) |
…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]>
PR Review: fix(auth): audit the failure that exhausts the attempt budget (ADR-0024) (#204)Decision: 🟢 Approved Executive summaryThis fix correctly moves the No findings reached the reporting threshold (≥ 80). |
9d87c46 to
445e354
Compare
|
APIError: Insufficient Balance (request_id: 1ba3a5a3-f3ff-499b-81ce-dc442466a591) |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
445e354 to
8e4ef13
Compare
|
APIError: Insufficient Balance (request_id: 55745b3e-c322-425c-b8af-de9eab390922) |
Every failure branch of Expect::authenticate checked `attempts >= MAX_AUTH_ATTEMPTS` and disconnected before emitting auth.failed, and the probe path checked the budget before looking the key up. The twelfth failure — the one that ends the connection — left no audit record, only the general-tier "post-kex protocol violation" line, which RUST_LOG can suppress. ADR-0024 audits every failed attempt. auth.failed is now emitted before the budget check on every failure path, and an unknown-key probe is counted and audited before it. Tests: the max-attempts test now captures the audit events and expects failure_count 1..=12, for signed requests and for unsigned probes; both fail on main (1..=11). Found by claude-review on #203 (the audit-schema freeze). Claude-Session: https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW Signed-off-by: Gonzalo Fleming <[email protected]>
8e4ef13 to
23b92b8
Compare
|
APIError: Insufficient Balance (request_id: 03ab284e-b0c8-442a-9b09-4538ce66a709) |
…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]>
… 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]>
…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]>
Summary
The authentication request that exhausts the attempt budget now emits
auth.failed, like every other failure, before the disconnect. Before, the twelfth failure, which is the one that ends the connection, left no audit record. All it produced was the general-tierpost-kex protocol violationdiagnostic, whichRUST_LOGcan suppress.claude-review found this while reviewing the audit-schema freeze (#203).
Motivation
This is a bug fix in the plain-PR lane: ADR-0024 audits every failed attempt (
auth.failed, withfailure_countper connection).Expect::authenticatehas four failure branches. Each one checkedattempts >= MAX_AUTH_ATTEMPTSand disconnected before itswarn!(target: "audit", …, "auth.failed"). The probe path checked the budget before it even looked the key up. A brute-force connection therefore logged at most elevenauth.failedrecords, and the attempt that triggered the lockout, the strongest signal, was missing.Type of change
Changes
transport.rs:auth.failedis emitted before the budget check.tests/accept.rs: the max-attempts test is now a helper,exhaust_auth_attempts(signed), with two tests, one for signed requests and one for unsigned probes. A capturing subscriber records everyauth.failed, and the tests expectfailure_count1 to 12 before the disconnect.CHANGELOG.md: aFixedentry.Checklist
git commit -s).cargo fmt --allandcargo clippy --workspace --all-targets -- -D warningslocally.docs/, orREADME.md) where appropriate.CHANGELOG.mdentry under## [Unreleased]if this change is user-visible.cargo deny check. (No new dependency.)Security considerations
Tests
max_auth_attempts_disconnects(signed requests) andmax_auth_attempts_by_unknown_key_probes_disconnects(unsigned probes): twelve failures,failure_count1 to 12, thenSSH_DISCONNECT_BY_APPLICATION. Withmain'stransport.rs, both fail withleft: [1, …, 11].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)andbuild (macos-latest)— fmt, clippy, tests, release build —,cargo deny,openssh-interop;cargo auditruns weekly, not per PR) and manual review when needed.https://claude.ai/code/session_01HxXXh6HEpJBs7tbuz3NmtW