8000 prek, tealdeer: trust the system CA store by default by bryan-minimal · Pull Request #1131 · gominimal/pkgs · GitHub
[go: up one dir, main page]

Skip to content

prek, tealdeer: trust the system CA store by default - #1131

Merged
bryan-minimal merged 4 commits into
mainfrom
sysca-prek-tealdeer-system-ca
Nov 3, 2026
Merged

bryan-minimal merged 4 commits into
mainfrom
sysca-prek-tealdeer-system-ca

Conversation

@bryan-minimal
Copy link
Copy Markdown
Member

Part of gominimal/pkgmgr-rs#1026 (prefer the system trust store), following the CVE-2026-111943 (eMudhra) response.

Why: both tools trust a root list compiled into the binary, so a CA removed from ca-certificates stays trusted until they're rebuilt. The Cargo.lock floors on main keep the bundled list current only as of the last rebuild.

prek 0.5.7

  • Upstream uses native TLS only when PREK_NATIVE_TLS=1. This patches the unset case to "on when /etc/ssl/certs/ca-certificates.crt exists". Without that file, native TLS would trust nothing.
  • An explicit PREK_NATIVE_TLS=0 or 1 still wins.
  • A grep fails the build if upstream rewrites the code, rather than silently dropping the default.
  • Verified that crates/prek/src/http.rs still ends that expression with .unwrap_or(false); at v0.5.7.

tealdeer 1.9.1

  • Builds only the rustls-with-native-roots backend (--no-default-features --features …). Upstream's default compiles both rustls backends and picks webpki first.
  • A config naming rustls-with-webpki-roots now fails with "Unsupported TLS backend", instead of quietly trusting the compiled-in list.
  • Verified the feature, the kebab-case tls_backend names and that error string at v1.9.1.

Tests: each package gets a standalone system_ca_default test with a negative control:

  • prek: PREK_NATIVE_TLS=0 must still select the compiled-in roots;
  • tealdeer: a webpki config must be rejected.

This is the 10-20 sysca/build branch re-applied onto current main. Main's Cargo.lock security-floor checks and --locked builds are kept. (deno and claude-code were done in #956; uv is #1130.)

🤖 Generated with Claude Code

prek: patch the unset PREK_NATIVE_TLS case to native TLS when
/etc/ssl/certs/ca-certificates.crt exists (an explicit 0/1 still wins; a
grep fails the build if upstream rewrites the code). tealdeer: build only
the rustls-with-native-roots backend, which makes it the config default.
Either way a CA removed from ca-certificates (CVE-2026-111943) stops
being trusted without a rebuild.

Re-applied from the 10-20 sysca/build branch (144d3d0) onto current main:
keeps main's Cargo.lock security-floor checks and --locked builds, and
tealdeer 1.9.1. Targets verified unchanged at prek v0.5.7 (http.rs
.unwrap_or(false)) and tealdeer v1.9.1 (rustls-with-native-roots feature,
'Unsupported TLS backend' error).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner October 27, 2026 20:44
@coderabbitai
coderabbitai Bot commented Oct 27, 2026 •
Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 4 billable files and costs up to $1.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 17 seconds for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 75 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8b95e83 and 9223355.

Files selected for processing: 4
  • packages/prek/build.ncl
  • packages/prek/build.sh
  • packages/tealdeer/build.ncl
  • packages/tealdeer/build.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@mitodrummer mitodrummer left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The tealdeer change is good. The rustls-with-native-roots-only build matches the v1.9.1 feature table, and needs.internet puts ca-certificates into its closure. One gap in prek:

  • packages/prek/build.ncl:27-30: add ca-certificates to runtime_deps. prek declares no needs.internet and none of its runtime deps bring in the store, so a session or task with prek and no curl/git has no /etc/ssl/certs/ca-certificates.crt. The patched default (Path::new(...).is_file()) then quietly falls back to the compiled-in webpki roots, which is exactly what this PR is meant to stop. AGENTS.md "Trust store → Declare the store when you read it" asks for the edge, and #1130/#1133/#1134/#1135 all add it. The system_ca_default test would not catch this, because it puts ca-certificates (and git, which brings curl) in test_deps. Right now ca-certificates is imported only for that test.

Everything else checks out. The sed target .unwrap_or(false); is the only such line in crates/prek/src/http.rs at v0.5.7, and the grep guard fails the build if upstream rewrites it.

msample
msample previously approved these changes Oct 28, 2026
@msample
msample dismissed their stale review October 28, 2026 20:15

see Karl's feedback

@mitodrummer
Copy link
Copy Markdown
Member

@bryan-minimal one item is still open here, from my review on 10-28: add ca-certificates to prek's runtime_deps (packages/prek/build.ncl:27-30). Without it, a session with prek but no curl or git has no /etc/ssl/certs/ca-certificates.crt, and the patched default falls back to the compiled-in roots. #1130, #1133, #1134 and #1135 all merged with that edge. It would also be worth taking ca-certificates out of the system_ca_default test's test_deps, so the test proves the runtime edge rather than supplying the file itself. The tealdeer half is good to go. Happy to push the change if you'd rather I did.

bryan-minimal and others added 2 commits November 2, 2026 10:48
…t (review)

The patched PREK_NATIVE_TLS default reads /etc/ssl/certs/ca-certificates.crt,
so the store has to be in prek's closure, as #1130/#1133/#1134/#1135 do.
Without it a session with prek and no store silently uses the compiled-in
roots. ca-certificates leaves system_ca_default's test_deps (base and git do
not bring it), so the test's `test -s` line now proves the runtime edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
Copy link
Copy Markdown
Member Author

@mitodrummer thanks, good catch. Done in dbdc66b:

  • ca-certificates is now in prek's runtime_deps, with a comment explaining why: the patched default reads /etc/ssl/certs/ca-certificates.crt, and without the store it silently falls back to the compiled-in roots.
  • system_ca_default no longer lists it in test_deps. I checked that nothing left in the test closure brings it in: base, git, and git's curl/openssl/expat/pcre2/zlib/libpsl don't. So the test's existing test -s /etc/ssl/certs/ca-certificates.crt line now passes only through prek's own runtime edge.

I also merged main (e80e0e8) so the build picks up the tzdata test fix from #1241.

@mitodrummer
Copy link
Copy Markdown
Member

Thanks, the runtime_deps edge in dbdc66b is right. The test still can't prove it, though. Per AGENTS.md (Trust store, item 1), ca-certificates is injected into the closure of anything that declares needs.internet and follows it to everything that depends on it at runtime. curl declares needs.internet (packages/curl/build.ncl:33-36), and git has curl in runtime_deps, so the [base, git] test closure still gets the store through git. The test -s /etc/ssl/certs/ca-certificates.crt line passes with or without prek's edge, and the new comment ("nor brought by base/git") isn't accurate.

If system_ca_default needs git, the simplest fix is to drop the test -s claim and its comment: the runtime edge is still correct and covered by review. If it doesn't need git (it only fetches deno's version list), use test_deps = [base], and then the test -s line does prove the edge. Either way, fix the comment. Then this is good from me.

git brings curl, which declares needs.internet, so the [base, git] closure
of system_ca_default gets ca-certificates injected (AGENTS.md "Trust store",
item 1) and its `test -s` passed with or without prek's edge. Move the check
to store_from_runtime_deps with test_deps = [base]: base plus prek's runtime
closure has no needs.internet package, so the store can only come from
prek's own runtime_deps. system_ca_default keeps git (prek shells out to it)
and its comment now says what that closure gets, host network included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
Copy link
Copy Markdown
Member Author

@mitodrummer you're right, and thanks for checking. git → curl → needs.internet injects the store into the [base, git] closure, so that test -s proved nothing. Fixed in 9223355, taking your second option as its own test:

  • New store_from_runtime_deps test, test_deps = [base]. It runs test -s /etc/ssl/certs/ca-certificates.crt and then prek --version. Standalone tests mount Transitives::for_toplevels(test_deps + [prek]) (minimal crates/op/src/standalone_test.rs). I walked the runtime_deps of base, glibc and gcc in the recipes, and nothing in that closure declares needs.internet, so the store can only come from prek's own edge. Drop the edge and this test fails.
  • system_ca_default keeps [base, git]. prek shells out to git (git init/git add in the script, and prek's own repo discovery). The test -s line is gone and the comment is rewritten. It now says git brings curl's needs.internet, so that closure gets the store injected regardless of prek's edge.
  • That same needs.internet also gives that test the host network (need_internet is OR-ed over the closure in standalone_test.rs). So "with no network the fetch fails" was wrong too. The comment now says the TLS log line comes before the fetch, so the check holds either way.

@mitodrummer mitodrummer left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code is right now. store_from_runtime_deps (packages/prek/build.ncl:57-72) runs with test_deps = [base], and I walked the runtime closure of base plus prek: nothing in it declares needs.internet, so the store can only come from prek's own edge (:30-32). The system_ca_default comment (:73-81) now says correctly that git brings the store and the network in regardless.

The one open item is CI: the build-bot hasn't posted a minimal build check on 9223355 yet, so the new test has never run. I'll approve once it passes on both arches.

@mitodrummer mitodrummer left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The last open item was the build: minimal build is green on 9223355, and the other checks pass. The store_from_runtime_deps test with test_deps = [base] is in the diff, as checked last round. Approving.

@bryan-minimal
bryan-minimal added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit a6c5b63 Nov 3, 2026
13 checks passed
@bryan-minimal
bryan-minimal d 82D3 eleted the sysca-prek-tealdeer-system-ca branch November 3, 2026 04:42
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.

3 participants

0