Repository navigation
Merge rustls 0.23.46 and make the crate publishable as shaped-rustls - #2
Merged
Merged
Conversation
This test was only fetching ECH config data from DNS and then checking we could unmarshal it. The daily tests CI is now configured to use the full-fledged ech-example.rs binary for the same test sites. Doing that _also_ tests the DNS ECH config list handling, but goes further and uses the unmarshalled configs for a real ECH enabled handshake. We can delete these tests on the back of that improved end-to-end coverage.
The libcrux crates have fixed this upstream but a release may not be available for some time. Ignore the unmaintained transitive dep warning for now.
Add a `max_tls13_tickets` field to `ServerConfig` that caps the number of tickets the server will send in response to a client ticket_request extension. Defaults to 0 (disabled), preserving current behavior. This is the backwards-compatible equivalent of the `Tls13Tickets` struct on `main`.
Allow a TLS 1.3 client to request a specific number of session tickets via the ticket_request extension, and let the server honor that request up to its configured max_tls13_tickets. The client sends new_session_count/resumption_count in its ClientHello (configured via ClientConfig::send_ticket_request); the server replies with the expected count in EncryptedExtensions and sends min(requested, max_tls13_tickets) NewSessionTicket messages. Backport of the feature from main, adapted for the rel-0.23 API surface.
Test/example code only; fixed on main by dropping the dependency.
On Unix, open the key log with mode 0o600 so a typical umask does not leave traffic secrets world-readable. Existing files are left unchanged.
RFC 9849 section 6.1.4 makes a HelloRetryRequest's ECH decision final: section 6.1.5 requires the ServerHello to confirm an acceptance again (else illegal_parameter), and section 6.1.6 continues with the outer hello after a rejection. The client decided afresh from the ServerHello, so a missing confirmation after an accepting HelloRetryRequest became a rejection, and a confirmation after a rejecting one revived the offer. Record the decision in EchState and hold the ServerHello to it.
Previously, only the record at exactly the limit was caught. Alerts are encrypted without checking the limit, so in TLS 1.2 a warning alert (such as the no_renegotiation alert sent in response to a HelloRequest) could take that slot, after which application data would continue to be encrypted with the exhausted key.
Previously, the limit was checked for each fragment in turn, so a write crossing the limit in TLS 1.2 would send a prefix of its data followed by close_notify. A peer that treats close_notify as the end of the data could then accept the truncated data as complete.
The AEAD nonce sequence was incremented before authentication, so a rejected ciphertext consumed sequence zero and the retry failed.
Previously, a key update was only sent after an entire write had been encrypted, so a write spanning the confidentiality limit kept encrypting records under the exhausted keys. Instead, stop before the record that would take the last sequence number allowed by the current keys, send the key update request with that sequence number, and continue the write under the new keys. This is a targeted backport of the fix for rustls#3302 from rustls#3342.
Previously, when a call to `WriteTraffic::encrypt()` reached the confidentiality limit of the traffic keys, the key update was only sent at the start of the next call, so the current keys were used for more records than allowed. Instead, request the key update before encrypting application data that would take the last sequence number allowed by the current keys, so that the key update takes that sequence number. Like the previous commit, this addresses rustls#3302 for the unbuffered API.
Like the client session types, this avoids printing the master secret.
Brings the branch from rustls 0.23.40 to 0.23.46, which carries the fixes for RUSTSEC-2026-0285, -0346, -0348 and -0349. Conflicts were in Cargo.lock (upstream's, then regenerated) and in rustls/src/client/hs.rs: - the config's version and cipher suite lookups take the protocol now, so the planned and default supported versions take it too; - upstream keeps the offered cipher suites in the hello details and checks a ServerHello against them; the branch's own copy of that list is gone, and the check of a HelloRetryRequest's suite reads upstream's field; - raw extensions still count as sent. Two adaptations outside the conflicts: an extension plan can disable the new ticket_request extension (RFC 9149), and upstream's new ECH test builds its supported versions through the constructor, since the branch made the struct's fields private. No ClientHello byte changes: the shaping tests of this crate and the uTLS byte oracles of xray-rust pass unchanged.
…ist is exact Seven shaping tests compare the emitted extensions with a fixed list that has no compress_certificate. With the brotli or zlib feature the default config offers it, and the tests failed on the order check before any shaping was compared. They now clear the config's decompressors, as their neighbours do.
The package is renamed from `rustls` to `shaped-rustls` so that it can go to
crates.io beside upstream. Its library keeps the name `rustls`: code written
for rustls compiles against it with one line in the manifest,
`rustls = { package = "shaped-rustls", version = "0.23.4600" }`.
A version is `0.23.PPRR`, upstream patch `PP` and fork release `RR`, so a
`^0.23` requirement follows both a fork fix and a rebase onto the next
upstream patch.
- every manifest of the workspace that takes the crate by path names the
package;
- the `[patch.crates-io]` entry that put the local crate under third-party
crates is gone: a package of another name cannot stand in for `rustls`.
With it goes `tokio-rustls-smoke`, which tested exactly that. tokio-rustls,
quinn and the like keep upstream rustls; a shaped hello under them needs an
adapter built against this crate;
- `admin/check-clienthello-compat` derives the upstream tag from the new
version scheme and builds its harness against the renamed package;
`admin/clippy` and `admin/coverage` name the package;
- the README's own section says what the fork is, how to depend on it, how
it is versioned and that RustSec advisories for rustls are not matched to
it;
- `.github/workflows/shaped.yml` tests the crate with `ring` and with
`ring,brotli,zlib` and builds the package on the `shaped/**` and `xray/**`
branches.
No behaviour change. The planned key share group is the plan's first supported group, said as that instead of a loop that broke after one turn; positioned GREASE extensions are merged by iterating the real order; four error strings lose a no-op conversion; the GREASE ECH arm carries its condition as a guard; an unneeded pattern and an unneeded borrow go.
The FIPS provider offers no X25519 key share, so with the fips feature two shaping tests that plan one stopped at 'ClientHello key share group is not supported by this config' before comparing anything.
- rust-version is 1.85, not 1.71: the aws_lc_rs feature, on by default, depends on the shake crate (edition 2024, Rust 1.85). The manifest said 1.71 since that dependency was added, which was not true of a default build. - An unknown extension in a TLS 1.3 certificate entry is ignored, where upstream rejects the message; Go's crypto/tls ignores it too. That has been so on this branch since 94f088e; the README now says it, and the BoGo test SendUnknownExtensionOnCertificate-TLS13, which expects the rejection, is disabled with that reason.
Upstream's workflows named the package in twelve places (-p rustls, --package rustls, admin/all-features-except ... rustls); they name shaped-rustls now, and the MSRV job uses Rust 1.85. CIFuzz runs for the upstream repository only: OSS-Fuzz does not know this one. fuzz/Cargo.lock follows the rename, which --locked requires.
rustls-webpki 0.103.15 -> 0.103.17 (RUSTSEC-2026-0382), webpki-roots 1.0.9 -> 1.0.12 (RUSTSEC-2026-0381), tokio 1.53.1 -> 1.54.1 (RUSTSEC-2026-0386) and hickory-net, hickory-proto and hickory-resolver 0.26.1 -> 0.26.3. The lockfile serves this repository's own tests and examples; a dependent resolves its own. crypto-bigint 0.5.5 (RUSTSEC-2026-0387), a dependency of the provider example, has no compatible fixed release and stays.
The first run with rust-version 1.85 left three jobs red: - MSRV: its second step still installed 1.75 for the all-features check; it installs 1.85 now. - Clippy: it reads the minimum version from the manifest, and at 1.85 it asks to rewrite upstream's code with newer APIs (io::Error::other, core::error::Error, repeat_n, div_ceil). rustls/.clippy.toml pins Clippy's msrv to upstream's 1.71, so upstream's code is linted as upstream lints it. - audit: RUSTSEC-2026-0387 against crypto-bigint 0.5.5, which the provider example and the ECH test dependencies pull in through elliptic-curve 0.13 and which has no compatible fixed release; it joins deny.toml's ignore list with that reason. The manifest's homepage repeated its repository, which current Cargo warns about; it is removed.
With the library clean, Clippy reached two things it had not got to before: - the shaping tests named std::sync::Arc, which rustls/.clippy.toml disallows in favour of the crate's own sync::Arc (86 places), and five of them filled a default ClientExtensions field by field. They use crate::sync::Arc and a struct initializer now; - rustls-bench with all features takes rustls-graviola, which is built against upstream's rustls package: its types are not this crate's and the bench does not compile with it. Before the rename the workspace's [patch] entry put the local crate under it. admin/clippy lints the bench with every other feature.
cargo-semver-checks takes the latest release on crates.io as its baseline. shaped-rustls has none yet, so the job could only fail, and it kept every run of this branch red. It now asks crates.io first: no crate, no check; any answer other than found or not found fails the job. After the first release the check runs as upstream's does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings the branch from rustls 0.23.40 to 0.23.46 and makes the crate publishable on crates.io under its own name. Nothing is published by this PR.
Merge with a merge commit, not squash or rebase: the first commit is a merge of the upstream tag, and the next merge of upstream needs that ancestry.
Commits
Merge rustls 0.23.46 (2f6b6ed). Carries upstream's fixes for RUSTSEC-2026-0285, -0346, -0348 and -0349. Conflicts were in
Cargo.lockand in four places ofrustls/src/client/hs.rs:Two adaptations outside the conflicts: an extension plan can disable the new
ticket_requestextension (RFC 9149), and upstream's new ECH test builds its supported versions through the constructor, because this branch made the struct's fields private.client tests: pin the certificate decompressors where the extension list is exact (422ef19). Seven shaping tests compare the emitted extensions with a fixed list that has no
compress_certificate. With thebrotliorzlibfeature the default config offers it, so they failed on the order check, on this branch before the merge as well (14 failures: seven tests, two providers).Publish the crate as shaped-rustls 0.23.4600 (b2f2ab8). The rename, the manifests that name the package, the README's own section, and a workflow for this fork's branches.
After the first CI run on this PR (see below):
rust-versionis 1.85, and the README names the two differences listed under "Decisions".rustlsin twelve places; the MSRV job uses 1.85; CIFuzz runs for the upstream repository only;fuzz/Cargo.lockfollows the rename.After the second CI run:
rustls/.clippy.tomlpins Clippy'smsrvto upstream's 1.71, so that Clippy does not ask to rewrite upstream's code for the newer version; RUSTSEC-2026-0387 (crypto-bigint, through the provider example and the ECH test dependencies) joinsdeny.toml's ignore list; the manifest'shomepage, which repeatedrepository, is removed.After the third CI run:
sync::Arcinstead ofstd::sync::Arc, whichrustls/.clippy.tomldisallows (86 places), and struct initializers where five of them filled a default value field by field.admin/clippylintsrustls-benchwith every feature exceptgraviola: rustls-graviola is built against upstream'srustlspackage, whose types are not this crate's now that the workspace[patch]entry is gone.After the fourth CI run:
Decisions
Confirmed by the owner:
shaped-rustls, libraryrustls. Code written for rustls compiles unchanged withrustls = { package = "shaped-rustls", version = "0.23.4600" }. Renaming the library as well would touch every doctest, example and test of upstream and make each later merge harder.0.23.PPRR: upstream patchPP, fork releaseRR.0.23.4600is the first release on rustls 0.23.46, a fork-only fix would be0.23.4601, a move to rustls 0.23.47 would be0.23.4700. A^0.23requirement follows both.Still to look at in review:
[patch.crates-io]entry andtokio-rustls-smokeremoved. A package of another name cannot stand in forrustlsunder[patch], and the smoke crate tested exactly that. tokio-rustls, quinn and the like keep upstream rustls; a shaped hello under them needs an adapter built against this crate.aws_lc_rsfeature, on by default, has depended on theshakecrate (edition 2024) since this branch added it; the manifest's 1.71 was not true of a default build.crypto/tlsdoes; this PR does not change it. It documents it in the README and disables the one BoGo test that expects the rejection,SendUnknownExtensionOnCertificate-TLS13. Ignoring only what the hello itself offered would keep the default path as strict as upstream; that is a change to the handshake parsing and is not part of this PR.First CI run (on b2f2ab8)
shaped-rustlsworkflow: 3 of 3 jobs passed.rustlsworkflow: 7 passed, 10 failed, 11 were cancelled after those. The failures and what commits 4 to 8 do about them:rustls: fixed in 7;fipsfeature and failed three shaping tests: 5;SendUnknownExtensionOnCertificate-TLS13, and passed the rest: 6;Second CI run (on ca6bc0f)
shaped-rustlsworkflow: 3 of 3 passed.rustlsworkflow: BoGo, Features (with FIPS), docs, coverage and the cross-target job that had finished all passed. Red: MSRV, Clippy and audit, which commit 9 addresses, and the semver check, which stays red until the crate has a release on crates.io. The Windows and macOS Build+test jobs were still running when this was read.Third CI run (on 0caf7f8)
Everything passed, the Windows and macOS Build+test jobs, MSRV and audit included, except Clippy, which commit 10 addresses, and the semver check, which stays red until the crate has a release on crates.io.
After commit 10, locally: Clippy 1.96 over all twelve workspace members with their default features and all targets is clean (with
-A clippy::nonminimal_boolfor the two findings in upstream's server code that only this local version reports), and theringandring,brotli,zlibtests pass (1096 and 1106). The all-features variants need FIPS and were not run locally.Fourth CI run (on e27b66f)
Clippy, MSRV, audit, BoGo, Features and the Linux builds passed. Two jobs were not green, neither for the code: the semver check, which had no release to compare with (commit 11), and the macOS Build+test job, which GitHub cancelled after fifteen minutes without a runner, before any step ran; the same job had passed on 0caf7f8. Windows was still running when this was read.
The script of commit 11's new step was run locally: crates.io answers 404 for
shaped-rustlsand 200 forrustls.Verification
All local, with rustc 1.96 on macOS arm64. The first seven items were run on ca6bc0f; commit 9 touches no Rust source, and after it the formatting check, the
ring,brotli,zlibtests (1106 passed), Clippy for the provider-test package (the step that failed in CI, reproduced before the fix) and the publish dry run were repeated.cargo-denywas not run locally.cargo fmt --all -- --checkandcargo check --workspace --all-targets --locked: pass.cargo test --locked -p shaped-rustls --features ring: 1096 passed, 0 failed, 8 ignored.cargo test --locked -p shaped-rustls --features ring,brotli,zlib: 1106 passed, 0 failed, 8 ignored.cargo test --locked -p shaped-rustls --no-default-features --features tls12,std: 165 passed, 0 failed, 8 ignored.cargo clippy --locked --package shaped-rustls --features ring,brotli,zlib --all-targets -- --deny warningswith Clippy 1.96: clean in the fork's code; it reports two lints in upstream'sserver/hs.rsandserver/tls13.rs, which the CI's Clippy did not report and which are left alone.admin/check-clienthello-compat: the default ClientHello equals upstream 0.23.46's in all four cases (ring and aws-lc-rs, with and without TLS 1.2).cargo publish --locked -p shaped-rustls --dry-run: packages 121 files and builds the packaged crate.[patch]pointed at this tree (package name set back torustlsfor the run): the uTLS byte oracles and shaping tests pass unchanged (chrome_parrot 3, reality_clienthello 14, reality_rustls 12, shaped_rustls 1, utls_hello_retry 3, utls_tls_shaping 45) and so do the 787 library tests of xray-transport.Not run locally: the
fipsfeature (needs cmake), the BoGo and OpenSSL suites, the fuzz targets, Linux and Windows. This PR's CI covers them.After the merge
🤖 Generated with Claude Code