Path building re-parses every intermediate on each budgeted call (unbudgeted CPU cost)

Abierto
#540 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@batmnnn ya está trabajando en esto.

Desde el 23/10/2026.

  • #1 de @batmnnn — abierto
  • #548 de @batmnnn — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
cryptography

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
166
Forks
111
Merge medio
3 h 39 min
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rustls/webpki

Todos los issues de rustls/webpki

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.