Skip to content

WebTransport Swift 1.3.6

Choose a tag to compare

@Pummelchen Pummelchen released this 12 Sep 00:29
· 724 commits to main since this release

A defect-fix release. There are no wire-format changes and nothing is removed from
the public API; the additions are one new validation entry point and one new error
case. Every item was found by an adversarial audit of the codecs, the runtime and the
command-line tools, and each was reproduced before being changed. The 1.3 series code
audits were performed by Claude Opus 5.

Fixed:

  • A PKCS#12 bundle whose certificate carries explicit elliptic-curve parameters — which is what the macOS system openssl (LibreSSL 3.3.6) emits for an EC key — no longer terminates the process. SecPKCS12Import raises an Objective-C NSInvalidArgumentException in that case rather than returning a status, and because Swift cannot catch Objective-C exceptions the failure escaped every do/catch and aborted the host application. The import now runs behind an exception boundary in a new WebTransportSecurityShim target, so listen(on:) throws a WebTransportNetworkRuntimeError naming the cause instead of killing the process. Reported in issue #20. Named-curve EC identities and RSA identities are unaffected; a bundle that previously crashed now reports: regenerate the certificate against a named curve, or use RSA.

  • ServerIdentityResolver now refuses an identity whose private key cannot be read, with the reason attached, rather than handing it to Network.framework and deferring the failure to the first peer handshake.

  • .certificateChain(chainDER:privateKeyDER:keyKind:) reports why a private key was rejected. The parameter must hold the representation SecKeyCopyExternalRepresentation returns for the private key, not the DER that openssl writes and not the public point: 97 bytes for P-256, 145 for P-384, and 199 for P-521. The previous failure was a bare OSStatus -50 that said nothing about the encoding; the error now names the expected form and length. The required encoding is documented on the case and on makePrivateKey, with a worked example in the wiki (issue #21).

  • The PKCS#12 import error no longer repeats Security.framework's raw exception reason. It is a fixed framework string that carries nothing a caller can act on, and the project's trust rules keep framework-supplied text out of public errors. The exception name is still reported, because it is stable and useful.

  • makeFromPKCS12 reads the imported identity through a type-identifier check rather than a forced cast.
    Added:

  • The repository's first non-Swift target, WebTransportSecurityShim, which exists only to give SecPKCS12Import an Objective-C frame where its exception can be converted into a status code. It is an internal target and is not part of the public product surface.

  • Regression fixtures and tests for the PKCS#12 import path, using bundles generated by the macOS system openssl. See Swift/Tests/WebTransportNetworkRuntimeTests/Resources/README.md.

  • The CRYPTO reassembly ceiling now bounds bytes waiting for a gap rather than every byte the connection has carried. Consumed bytes are retained so a conflicting retransmission is still detected, and counting them against the ceiling made it a lifetime cap: a peer that completed a large handshake could no longer deliver a legitimate post-handshake message such as a NewSessionTicket or KeyUpdate, and was disconnected instead. The count is computed once per frame and incremented locally from there, so a large frame stays linear.

  • An accept that times out no longer consumes the next connection. acceptSession bounds its wait on the connection queue with a timeout, and a cancelled CheckedContinuation is never resumed, so the abandoned waiter stayed at the head of the queue and was handed the next accepted connection — which was then dropped. Reachable from the documented accept loop, while true { try await acceptSession() }, whose one-second default plants an abandoned waiter on every idle timeout; once connections arrive slower than that, every connection is lost. The queue now tags each waiter so a caller that stops waiting removes its own entry and resumes it, which lets the abandoned task unwind; dropping the continuation instead would leak it. A cancelled accept also releases a connection that arrives after it gave up.

  • Shutdown now wakes a parked accept with a shutdown error instead of leaving it to block for its full timeout. That timeout was how the abandoned waiters above were created, so the two defects compounded.

  • connectSession cancels its inbound handler task on every failure path, not only when the peer rejects the session. The handler strongly retains the connection and Network.framework exposes no cancel(), so a task left running kept the connection and its socket alive. acceptSession already did this.

  • DATAGRAM and PING frames are no longer classified as retransmittable. RFC 9221 section 5.2 states DATAGRAM frames are not retransmitted on loss detection, and RFC 9000 section 13.3 notes a lost PING needs no repair; a caller resending everything in retransmittableFrames re-sent an unreliable datagram and delivered it twice.

  • NEW_CONNECTION_ID rejects a zero-length connection ID. RFC 9000 section 19.15 makes anything outside 1...20 a FRAME_ENCODING_ERROR, and only the upper bound was checked, so an empty connection ID was accepted and stored as a usable identity. The encoder enforces the same range, so the library can no longer produce a frame it would refuse to read.

  • HKDF-Expand is capped at 255 * HashLen (8,160 bytes for SHA-256) as RFC 5869 section 2.3 requires. The guard allowed up to UInt16.max, so a larger request wrapped the block counter to zero and returned bytes that look well-formed but are not the RFC's stream.

  • An explicit maxConcurrentConnections now overrides a supplied admission policy instead of being silently ignored. The override was gated on admission == .default, so a caller passing both a policy and an explicit limit had the limit dropped with no diagnostic, and an out-of-range limit was neither applied nor refused. It is now tied to the default argument value and validated on the same terms as the policy's own field.

  • Long-header packets with a cleared Fixed Bit or non-zero reserved bits are rejected. RFC 9000 section 17.2 requires such packets be discarded and RFC 9001 section 5.4 requires the reserved bits to be zero; the short-header decoder enforced the Fixed Bit but the long-header path enforced neither. The Retry decoder, which is also a long header, now applies the same two checks and rejects a zero-length Retry token, which RFC 9000 section 17.2.5 requires a client to discard.

  • An oversized datagram is reported instead of being silently truncated. The UDP receive path used recvfrom, which on this platform returns a short payload with a valid source and no indication that anything was lost — a QUIC parser would then read a packet that was never sent. It now uses recvmsg and rejects the datagram when the kernel sets MSG_TRUNC, which is the only form that reports truncation here. Note that passing MSG_TRUNC to recvfrom does not work: macOS documents the flag as "data discarded before delivery", and it is set on output rather than honoured on input.

  • QUICTransportParameters.validated() enforces the value rules of RFC 9000 section 18.2, which nothing did before: max_udp_payload_size below 1200, ack_delay_exponent above 20, max_ack_delay at or above 2^14, active_connection_id_limit below 2, a stateless_reset_token that is not 16 bytes, and original_destination_connection_id outside 1...20 are now rejected. A zero-length initial_source_connection_id or retry_source_connection_id is accepted, because RFC 9000 section 7.3 defines that as the encoding for a selected zero-length connection ID, and an explicit zero max_datagram_frame_size is accepted because RFC 9221 section 3 defines it as the default. It is opt-in rather than folded into decode, because decode is also the TLS-extension parser and must keep accepting parameters this build does not model.

  • --max-sessions is bounded at 65,536. The value sizes an array of tasks, so --max-sessions=1000000 committed memory proportional to the request until the process was killed; the parser accepted any positive integer. The bound stops that abuse and is deliberately well clear of Swift/run-soak.sh, which passes CONNECTIONS + 10.

  • --listen exits non-zero when it served no sessions. It previously exited zero after every session attempt failed, which a script or CI job reads as success.

Verification

  • 294 package tests, up from 280 at 1.3.5.
  • Both 40-scenario conformance suites pass, from source and from the shipped
    binaries.
  • CI green on all three jobs: build, tests and conformance; the AddressSanitizer
    fuzz corpus; and the Thread Sanitizer suite.
  • Strict memory-safety, complete-concurrency and explicit-Sendable diagnostics;
    the formatter gate; and manifest agreement between the two package manifests.
  • Public API compatibility against the 1.3.0 surface.

Artifacts

Artifact Platform SHA-256
WebTransportClient macOS arm64 fa07a2a1d2c1350f3eac03507abf3fdc9e3db9bf55e00e84b61735d110965555
WebTransportServer macOS arm64 956b08f7547ef7049a823d9bdeb00f3294f35c9b81978d0dbffe4e02f2249af4
SHA256SUMS Checksum manifest Included with the release

Both are thin arm64 Mach-O and run natively on every Apple Silicon Mac. They are
ad-hoc signed rather than Developer ID signed and are not notarized, so Gatekeeper
quarantines them on first run: check the sums, then
xattr -d com.apple.quarantine WebTransportClient WebTransportServer.

The builds are reproducible. ./Swift/build-release-apple-silicon.sh performs two
clean builds and compares normalized Mach-O hashes, so these checksums can be
rebuilt from source.

Run the conformance suites from the repository root. Run from the artifact
directory, two source-tree scenarios fail because they read Package.swift and the
release script relative to the working directory.