Skip to content

feat(tlsio,repo): CA-path validation for sc+https:// (ADR-0054) - #202

Merged
tonibergholm-codento merged 3 commits into
mainfrom
tls-ca
Oct 19, 2026
Merged

tonibergholm-codento merged 3 commits into
mainfrom
tls-ca

Conversation

@tonibergholm

@tonibergholm tonibergholm commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Problem

sc+https:// trust is pin-only (ADR-0042): the client pins SHA-256(SPKI) and ignores names and validity. That fits a self-minted identity and fits a CA-issued certificate badly: an ACME/certbot certificate rotates every few weeks, usually with a new key, so the pin breaks on every renewal, and the first connection is unverified even though a CA vouches for the server. ADR-0042 named CA-path validation as an additive follow-on; the server already serves an operator PEM pair (--tls-cert/--tls-key).

Change

A client opts in with SC_HTTPS_CA_FILE=<pem> (a CA bundle) or SC_HTTPS_CA=system (platform roots via rustls-native-certs, already in the lockfile through the AWS SDK). scl_tlsio::client_connect_ca validates like a browser: chain to a trusted anchor, validity window, and that the certificate covers the name or IP dialled; handshake signatures as always, and the handshake completes before any application byte (the bearer token) is written.

  • Replaces pinning for that connection: the pin file is neither read nor written; SC_HTTPS_STRICT has no meaning.
  • Fails closed: an unreadable or empty bundle, an empty system store, an unrecognized SC_HTTPS_CA value, both knobs at once, or SC_HTTPS_FINGERPRINT together with CA trust is an error, never a fall back to accept-new.
  • Pin mode is unchanged and the default. scl_tlsio stays the only crate linking rustls; the repo layer carries the choice as CaSource in TlsClientPolicy.
  • Not done: revocation (CRL/OCSP), a CLI flag in place of the env vars, mTLS.

ADR-0054 records it; THREAT-MODEL, ROADMAP, CLAUDE.md and the CLI reference are updated.

Verification

  • scl_tlsio end to end with a throwaway CA and the leaf it issued: connects by DNS name and by IP and moves data; a certificate from another CA is rejected; a certificate issued for a different name is rejected despite a valid chain; an empty or missing bundle is an error.
  • scl_repo: the env resolver fails closed on every bad combination; a CA policy against a real TLS server refuses it, never creates the pin file and fails closed on a missing or empty bundle.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added optional CA-based TLS validation for sc+https:// connections. Configure a PEM bundle with SC_HTTPS_CA_FILE or use the system trust store with SC_HTTPS_CA=system.
    • CA validation checks the certificate chain, validity period, and server name. It replaces pinning for that connection and does not access the pin file.
  • Documentation

    • Updated the client reference, threat model, roadmap, and TLS documentation with CA validation settings and behavior.

SC_HTTPS_CA_FILE=<pem> or SC_HTTPS_CA=system switches a client from SPKI
pinning to validating the chain, validity window and name against a CA, so a
CA-issued (ACME/private CA) server needs no first-connect trust and survives
certificate rotation. It replaces pinning for the connection (the pin file is
neither read nor written), completes the handshake before any application byte,
and fails closed on an unusable bundle, an unrecognized value, both knobs, or a
pre-pin combined with CA trust. Revocation is not checked. Pin mode is the
unchanged default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T13:10:00.556040Z 5a410c6 New commits
🔒 Security Review ✅ Completed 2026-10-19T13:11:47.398247Z 5a410c6 New commits
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eef5a0d2-2f75-4806-bca2-1e1dbaf149d3
📥 Commits

Reviewing files that changed from the base of the PR and between 3a6d79e and 5a410c6.

⛔ Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing: 12
  • .claude/skills/sc-cli-reference/SKILL.md
  • CLAUDE.md
  • ROADMAP.md
  • crates/repo/src/http_transport.rs
  • crates/repo/src/tls_pins.rs
  • crates/tlsio/Cargo.toml
  • crates/tlsio/src/lib.rs
  • crates/tlsio/src/stream.rs
  • crates/tlsio/src/trust.rs
  • docs/THREAT-MODEL.md
  • docs/adr/0054-tls-ca-validation.md
  • docs/adr/README.md
+-------------------------------------------------------------------------------+
| FUZZY BUNNY: Finding Unresolved Zero-day Zingers, Bugs, Nasties, and Yuckies. |
+-------------------------------------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

…to pinning)

Sol review: a CA variable that is present but empty (an unset shell variable)
or not valid UTF-8 read as absent and silently restored TOFU, which would send
the bearer token to an unverified host; both are now errors, as is a
non-UTF-8 SC_HTTPS_FINGERPRINT. A PEM bundle with a block that is not a
certificate is refused instead of quietly shrunk; partial system-store load
errors are reported as warnings (the loaded roots still validate); and CA mode
no longer needs HOME/XDG/SC_HTTPS_KNOWN_HOSTS to resolve an unused pin file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tonibergholm

Copy link
Copy Markdown
Member Author

Independent Codex Sol (gpt-6.1-sol, read-only) security review of the diff found five issues, all fixed in the follow-up commit with tests: (1, high) an empty SC_HTTPS_CA_FILE/SC_HTTPS_CA (an unset shell variable) read as absent and silently restored TOFU, sending the bearer token to an unverified host; now an error. (2) a non-UTF-8 SC_HTTPS_CA did the same, and a non-UTF-8 SC_HTTPS_FINGERPRINT evaded the CA/pre-pin conflict check; both are errors. (3) a bundle with one valid CA plus a block that is not a certificate succeeded silently; now refused. (4) partial system-store load errors were discarded; the loaded roots still validate (a smaller trust set), and the problems are now printed as warnings. (5) CA mode failed without HOME/XDG while resolving an unused pin path; it no longer needs one. Sol found no verification or token-ordering bypass: the handshake completes before the HTTP opening, name checking uses the dialled host (IP literals need IP SANs), and CA and pin modes share provider and protocol defaults.

@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: 149dcb202a

ℹ️ 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 crates/repo/src/tls_pins.rs Resolved
Comment thread crates/repo/src/tls_pins.rs Resolved
Comment thread crates/repo/src/http_transport.rs Resolved
…e-pin

Codex: from_env rejected the combination but the public env-free seam let CA
validation silently win over a requested fingerprint.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tonibergholm

Copy link
Copy Markdown
Member Author

All three Codex findings are handled on the current head: CA selection now resolves before the pin path is required (known_hosts_path().unwrap_or_default() in CA mode, so a missing HOME no longer fails it) and a non-Unicode SC_HTTPS_CA (or SC_HTTPS_FINGERPRINT) is an error, both from the Sol-review commit (the review ran on the first commit); and connect_with_pins now refuses a policy that carries both a CA and a pre-pin, with a test, so the invariant holds at the env-free seam as well as in from_env.

@tonibergholm-codento
tonibergholm-codento merged commit 981e6d0 into main Oct 19, 2026
8 of 9 checks passed
@tonibergholm
tonibergholm deleted the tls-ca branch October 19, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants