Path building re-parses every intermediate on each budgeted call (unbudgeted CPU cost)
@batmnnn is already working on this.
Since Oct 23, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- cryptography
Research direction
Start at src/verify_cert.rs, in build_chain_inner/PathBuilder where the issue links lines 149-150: each recursive step calls Cert::from_der over all intermediate_certs before the issuer comparison. Hoist that parsing into a Vec<Cert> built once at the start of build_chain (skipping or recording parse failures), keeping Budget semantics unchanged. Read the Budget definition and the test_too_many_path_calls regression test first, then run cargo test to confirm budget and path-building tests still pass; done means intermediates are parsed once and the per-recursion step is only a name comparison.
Written by the indexing model from the issue text.
Description
While reviewing rustls-webpki 0.103.15 we noticed that path building re-parses every peer-supplied intermediate on each budgeted path-building call, and that this parsing is not itself counted against the budget.
Where. In build_chain_inner (ChainOptions in 0.103.15, PathBuilder on main), every recursive step iterates over all of intermediate_certs and calls Cert::from_der on each one before the issuer comparison (0.103.15 src/verify_cert.rs:108; on current main at https://github.com/rustls/webpki/blob/3d0adc46704c1d985a9fefe2034650488d96d49e/src/verify_cert.rs#L149-L150). The Budget (the RUSTSEC-2023-0053 fix) limits build-chain calls and signature checks, but the per-call parse of each intermediate is outside it.
Cost. This is bounded: at most the 200,000-call budget times the bytes of intermediates, and rustls caps the Certificate message at 64 KiB. In practice, a filler-padded chain that fits in a 64 KiB handshake message costs about 0.5-1 s of CPU per handshake on our hardware (worst measured 758 ms). Plain degenerate chains (the test_too_many_path_calls shape) stop within about 66 ms. So a malicious TLS server can make a client spend up to roughly a second of CPU per connection attempt before the handshake fails.
Suggestion (hardening, not a vulnerability report). Parse the intermediates once per build_chain (for example into a Vec<Cert> up front, skipping or remembering the ones that fail to parse) and reuse the parsed certificates in each recursive step. That would make the per-call cost an issuer-name comparison rather than a full DER parse, without changing the budget semantics.
We are filing this as an enhancement idea only; we know the budget is a deliberate, tested design copied from mozilla::pkix, and we are not asking for a change to it.
- Dominant language
- Rust
- Stars
- 167
- Forks
- 112
- Avg merge
- 4h 28m
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rustls/webpki
-
Difficulty 4/5 3-5 days Newbie friendliness 22/100
-
Improve error message when denying subject name due to wildcard in public suffixMay be free again @ctz claimed this 79 days ago, and no pull request is open. Open
-
Consider all candidate CRLsMay be free again @cpu claimed this 85 days ago, and no pull request is open. Open
-
Add opt-in support for ignoring URI name constraintsPossibly taken @djc claimed this 135 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Eyevinn/open-live-ingest#36 · 1 comment ·
Maintainers usually reply within 1 day
-
app
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
bug bug jury peripheral:i2s
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
esp-rs/esp-hal#6828 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
ライブラリを追加Openpriority middle
Difficulty 1/5 Under an hour Newbie friendliness 62/100
KATO-Hiro/AtCoderClans#13015 ·
Maintainers usually reply within 1 day