Skip to content

bounds-check dns response parsing against packet end#1628

Open
rootvector2 wants to merge 1 commit into
Moddable-OpenSource:publicfrom
rootvector2:dns-parser-packet-bounds
Open

bounds-check dns response parsing against packet end#1628
rootvector2 wants to merge 1 commit into
Moddable-OpenSource:publicfrom
rootvector2:dns-parser-packet-bounds

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

parseQname follows a compression pointer and copies label bytes with no packet-end check, and the TXT loop in parseQuestionOrAnswer underflows rdlength when a sub-string length exceeds it, so a malformed DNS response read from the resolver's UDP socket reads past the packet buffer.

@rootvector2

Copy link
Copy Markdown
Contributor Author

@phoddie

@phoddie

phoddie commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the PR.

  • It identifies some memory safety issues. That's great.
  • It missed some others - most notably the xs_dnspacket_get_* functions don't validate that the header is fully present.
  • Some of the changes to optimize refresh of the packet pointer will break, because packet can move during certain operations
  • Some of fixes are more invasive / complicate than strictly necessary.

I drafted an alternative solution. You can see that as a comparison with the current Moddable SDK version in this gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants