Accept every c_rehash collision suffix, not just .0 #602
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #602"
general
weight: 0.35
Lukasa
_isRehashFormatrecognises only a one-digit collision suffix, soopenssl rehashlinks from.10upward are not seen as c_rehash links at all.The three barriers
On
mainthe name check is:Three things reject a valid link independently:
1.
lastPathComponent.count == 10— rejects any name longer thanHHHHHHHH.Dbefore the extension is examined at all.2.
fileExtension.count == 1— rejects any suffix of more than one digit.3.
fileExtension.first == UInt8(ascii: "0")— rejects every suffix that does not begin with0, which for the ids OpenSSL actually writes means everything except.0.Relaxing any one of them is not enough on its own.
Consequence
The filter lives in
loadVerifyLocations(_:context:sendCANames:), which calls_isRehashFormatover the directory contents whensendCANamesis set, loads each surviving link as a PEM certificate, and passes it toaddCACertificateNameToListso its CA name reaches the client CA list. (addRootCertificateis a different function; it adds a certificate to the trust store and does not walk the directory.)A CA that lost the hash race is therefore skipped, so its name is absent from the CertificateRequest, and a client holding a certificate from that CA has no reason to send it. The failure is quiet: nothing errors, the handshake just proceeds without the client certificate.
The change
fileExtension.allSatisfy({ $0.isDecimalDigit })replaces the== "0"comparison, mirroring theisHexDigitcheck on the line above.isDecimalDigitis added to the sameUTF8.CodeUnitextension asisHexDigit, in the same shape, reusing the existingasciiZero/asciiNineconstants.fileExtension.count == 1becomes!fileExtension.isEmpty. Emptiness still has to be excluded explicitly, becauseallSatisfyis vacuously true on an empty collection.lastPathComponent.count == 10is removed rather than relaxed to>= 10. It is redundant once the parts are checked:filenameParts.count == 2,filename.count == 8and a non-empty all-digits extension already pin the name to 8 + 1 + digits. A second, looser length check would only be another thing to keep in sync.omittingEmptySubsequences: false. This is load-bearing. With the default behaviourCollection.splitdiscards empty pieces, so.7f44456a.0,7f44456a..0and7f44456a.0.collapse to the same two parts as7f44456a.0. The removedcount == 10check had been rejecting exactly those three by accident; the explicit split replaces that accident with an intentional rule, and the reasoning is recorded at the call site.No upper bound on the number of digits is imposed. The reasoning, and the OpenSSL sources it rests on, are in a comment on this PR.
Tests
testRehashFormatalready asserts a non-digit extension (.z) is rejected;.ais added next to it, since a hex-but-not-decimal character is the case most likely to regress if someone reaches forisHexDigithere.testRehashFormatAcceptsCollisionSuffixescreates real symlinks and covers:.7f44456a.0,7f44456a..0,7f44456a.0.,7f44456a.,7f44456a.0.1and7f44456a.r0.Every assertion carries a message saying why that name is in the list. The rejected names are real symlinks to a real certificate, so the name check is the only thing that can reject them. Only the first three depend on the explicit split; the comment in the test says what rejects the other three, so nobody reads the split as decorative.
The existing
getRehashFilenamehelper is used unchanged. It formats with%08lx.%dand already produces.10,.123and.255correctly.One existing assertion changes meaning.
testRehashFormatbuilds7f44456a.1for its "in rehash format, but not a symlink" case, and onmainthat passes for the wrong reason: the name is rejected at the"0"comparison, before the symlink check it is meant to exercise. I confirmed this by passing a nonexistent path through the function, where reachinglstatis observable as a throw:| Source |
_isRehashFormat("/etc/ssl/certs/7f44456a.1")|| --- | --- |
|
main| returnsfalse, does not throw — rejected at the name check || this PR | throws — the name is accepted and execution reaches the symlink check |
After this change the assertion exercises what it was written for.
Verification
Run in
swift:6.2-noble, the image the Linux 6.2 leg of the shared matrix names (apple/swift-nio,scripts/generate_matrix.shline 78):| Run | Result |
| --- | --- |
|
apple:main(03827c1), unmodified |Executed 339 tests, with 0 failures (0 unexpected)|| PR head before this commit, unmodified |
Executed 340 tests, with 0 failures (0 unexpected)|| With this change |
Executed 340 tests, with 0 failures (0 unexpected)|| With this change, the matrix's 6.2 argument overrides |
Executed 340 tests, with 0 failures (0 unexpected)|| New test against
apple:mainsource | 5 failures:.1,.9,.10,.123,.255|| New test against this branch's first commit | 3 failures:
.10,.123,.255|| New test against a variant keeping the default split | 3 failures:
.7f44456a.0,7f44456a..0,7f44456a.0.|The last three are negative controls, showing the new assertions have teeth in both directions.
swift format lintreports only the pre-existingOrderedImportswarnings, unchanged from the baseline.The
.10case was reported by @stephenlclarke; I reproduced it here before changing anything.---
The code in this pull request was written with Claude Fable 5.1. The verification above and this description were written with Claude Opus 5. I have reviewed and tested the change, and I am responsible for its content.