Repository navigation
boringssl: restore is_safe_alt_name helper (main build break) - #36540
Conversation
#36252 removed the x509::is_safe_alt_name helper (its only caller was rewritten), then #36165 landed a new call to X509::is_safe_alt_name in the NameBytes Display impl, written against the pre-#36252 tree. main stopped compiling at ff512ea with E0433. Restore the helper as a local fn next to NameBytes. The sole caller passed utf8=false, so the utf8 branch is dropped; the body is otherwise a direct port of Node's IsSafeAltName (src/jsc/bindings/ncrypto.cpp). Covered by the existing Bun.connect altname-escaping tests and new unit tests in this crate.
There was a problem hiding this comment.
LGTM — straightforward build-break fix restoring a removed helper.
What was reviewed:
- Verified
is_safe_alt_namematches Node'sIsSafeAltNamenon-UTF8 branch inncrypto.cpp:753byte-for-byte (range' '..='~', four excluded chars). - Confirmed no other callers of the removed
X509::is_safe_alt_nameremain in the tree. - Unit tests cover the range boundaries (
\x1f,\x7f,\xe4) and all four excluded characters.
Extended reasoning...
Overview
This PR fixes a compile error on main caused by a merge-order race between #36252 (removed x509::is_safe_alt_name) and #36165 (added a new caller in NameBytes::fmt). The fix restores the helper as a private free function next to its sole caller, drops the unused utf8 parameter branch, and adds two unit tests.
Security risks
None. The helper is a pure byte-classification predicate used only to decide whether a certificate SAN entry needs JSON-style quoting in an error message. It does not participate in hostname verification, trust decisions, or any parsing of untrusted input beyond display formatting. The implementation was cross-checked against src/jsc/bindings/ncrypto.cpp:753 and matches the non-UTF8 branch exactly: printable ASCII 0x20..=0x7E minus ", \\, ,, '.
Level of scrutiny
Low. This is a build-break fix with main currently red on every lane. The change is a 4-line function plus tests; the function body is a direct port of code that was already in-tree until #36252 removed it. The only judgment call — dropping the utf8 parameter — is justified: the sole caller passed false, and NameBytes is documented as IA5/Latin-1.
Other factors
- Grep confirms no other references to
X509::is_safe_alt_nameor the removeduse x509 as X509alias remain. - The new unit tests exercise both range boundaries (
\x1fbelow,\x7fabove, non-ASCII\xe4) and every excluded character, plus the end-to-endNameBytesquoting output including the CVE-2021-44532-relevant comma-injection case. - PR description cites
cargo check/clippy/testand the integration test from #36165 all passing.
What
Fixes the E0433 compile error on main since ff512ea.
Why
Merge-order race: #36252 removed the
x509::is_safe_alt_namehelper and itsuse x509 as X509alias (the only caller had been rewritten), and #36165 then landed a new call toX509::is_safe_alt_namein theNameBytesDisplayimpl that was written against the pre-#36252 tree. Every lane on build 86151 fails with:Fix
Restore the helper as a private
fn is_safe_alt_name(name: &[u8]) -> boolnext toNameBytes. The sole caller passedutf8 = false, so the UTF-8 branch is dropped; the body is otherwise the same port of Node'sIsSafeAltName(src/jsc/bindings/ncrypto.cpp:753) that #36252 removed.Verification
cargo check -p bun_boringsslandcargo clippy -p bun_boringssl --testsare cleancargo test -p bun_boringssl --libruns the two new unit tests (safe_alt_name_matches_node,name_bytes_quoting)bun bd test test/js/node/tls/node-tls-connect-hostname-verification.test.ts -t "altname mismatch reason"passes all three escaping cases added in Robustness pass across install, css, ffi, crypto, spawn, shell, and node compat #36165