fix(dns): validate enrtree-root fields and skip malformed records#12136
Conversation
|
Claude finished @AnkushinDaniil's task in 5m 23s —— View job Code Review
SummaryThe fix is correct and addresses a real reliability/security issue: a malformed DNS TXT record could throw One medium finding on the exception catch scope, and one low finding on test coverage. FindingsMedium
Low
Both fields share the same Informational (pre-existing, not introduced by this PR)
Critical: 0 | High: 0 | Medium: 1 | Low: 1 |
|
Addressed both: dropped |
25ae7ed to
980218d
Compare
980218d to
5406fd1
Compare
|
Claude finished @AnkushinDaniil's task in 1m 33s —— View job Code Review (follow-up)
SummaryBoth findings from the previous review are confirmed resolved. Medium — Low — missing No new issues found. The Pre-existing informational notes from the prior review remain unchanged (both pre-date this PR):
Critical: 0 | High: 0 | Medium: 0 | Low: 0 — ready to merge. |
Changes
EnrTreeParser.ParseEnrRootnow validates the presence and length of all four fields (e=,l=,seq=,sig=) in an untrusted DNS TXT record before slicing, and usesint.TryParsefor the sequence. Previously a malformed record (missing field, no space after theseq=value, truncatedsig=, non-numericseq=) threw an unhandledArgumentOutOfRangeException/FormatExceptionfrom the rawIndexOf/Substringcalls. Because this parsing happens before any ENR signature verification, a spoofed or malformed record could abort the entire DNS-discovery crawl.EnrTreeCrawler.SearchNodenow catches a parse failure for a single record (FormatException/NotSupportedException/ArgumentException), logs it at debug, and continues the crawl instead of aborting it.Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
New
Malformed_enrtree_root_throws_FormatExceptioncases fail before the change (unhandledArgumentOutOfRangeException) and pass after. FullNethermind.Network.Dns.Testsuite passes.Documentation
Requires documentation update
Requires explanation in Release Notes