Conversation
Signed-off-by: Zafer Balkan <zafer@zaferbalkan.com>
Member
|
Thanks for the PR. Will check it soon in detail. |
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.
What?
Replaces
SequenceEqualwithCryptographicOperations.FixedTimeEqualsfor all three TSIG MAC verification checks inTechnitiumLibrary.Net/Dns/DnsDatagram.cs:VerifySignedRequest(line ~1434)VerifySignedResponse(line ~1689)No public API surface changed; method signatures, return values, and out-parameter semantics are identical.
Why?
SequenceEqualshort-circuits on the first mismatched byte, so its execution time leaks information about how many leading bytes of an attacker-supplied MAC are correct. Over enough requests, that timing signal can be used to forge a valid TSIG MAC byte-by-byte instead of brute-forcing it in one shot, defeating the purpose of TSIG authentication for zone transfers and dynamic updates.CryptographicOperations.FixedTimeEqualsis the BCL's constant-time comparison primitive designed for exactly this: comparing a computed secret/MAC against caller-supplied bytes without leaking timing.How?
Straight one-line swap at each of the three call sites, plus a short comment explaining why fixed-time comparison is used.
FixedTimeEqualsreturnsfalse(never throws) on unequal-length inputs, same asSequenceEqualwould; in practice this never triggers here sincecomputedMacis always computed withtsig.MAC.Lengthas the target length, so both arrays are guaranteed equal length going in -behavior for the existing code paths is unchanged, only the timing characteristic is.Testing?
dotnet buildof the fullTechnitiumLibrary.Netproject (Release): succeeds, 0 warnings/errors.grepacross the repo forSequenceEqualagainst MAC/tsig fields); the one other hit,DnsTSIGRecordData.Equals(), is a value-equality override unrelated to authentication and intentionally left as-is.VerifySignedRequestpublic method: builtDnsServerCore,DnsServerCore.HttpApi,DnsServerCore.ApplicationCommon, andDnsServerAppagainst the patched library, all succeed with 0 errors.Anything else?