xnetworking: fail closed on cert verification errors and malformed pin metadata #76
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/77"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by certified-retart on 2026-11-23T01:22:00Z.
Summary
Hardens
XNetworkingVerifyServerCertificateandverify_thumbprintsincrates/xcl/src/hle/xgameruntime/networking.rsto fail closed on missing URLs/hostnames, zeroGetLastError()codes, plain-HTTP loopback with pins, and malformed pin metadata (addressing the certificate verification items indocs/xnetworking-rust-review.md).What changed
WINHTTP_OPTION_URLfailure, odd/empty/oversized byte counts, or empty extracted host now fail closed instead of proceeding with a nullserver_name(which disabled SSL hostname verification).CertGetCertificateChain(or null chain) and failedCertVerifyCertificateChainPolicynow mapGetLastError() == 0toE_FAILviawin32_failure_hrrather than turninghresult_from_win32(0)intoS_OK.status.errorvalues fromCertVerifyCertificateChainPolicyare converted viapolicy_status_hrso they never become positiveHRESULTs.validate_thumbprint_metadata/check_thumbprints):thumbprint_count > 0with nullthumbprintspointer (previously returnedtrue).thumbprint_count * size_of::<XNetworkingThumbprint>() > isize::MAX.XNetworkingThumbprintTypevalues (> 2) instead of falling back to matching any cert in the chain.CERT_E_UNTRUSTEDROOTon plain-HTTP loopback if the caller requires certificate pinning (pin_count > 0). (Unpinned plain-HTTP loopback andIssuerchain-index matching are left unchanged in this focused PR.)userinfo@hostand unclosed[IPv6 literals cleanly.Verification
rustc 1.100.0(x86_64-pc-windows-msvc), Windows 10 Pro10.0.19045.cargo test -p xcl --lib hle::xgameruntime::networking: 6 passed, 0 failed.thumbprint_count, non-20-byte SHA-1 length validation, and odd/oversizedWINHTTP_OPTION_URLbyte counts before opening.Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T10:29:31Z.
Merged. Tested on Windows 11 with an RX 9070 (RDNA4):
cargo test --workspacegreen with the retail samples (shader pack, console DLLs, texture archive), also withXCL_SPLIT_WAVE64=1(the 32-lane split path forced on RDNA). Unicorn Overlord and XDefiant run with this round merged. Thanks!