Consomme: Add timeout for UDP connections and DNS resolution support #2534
Closed
damanm24 wants to merge 36 commits intomicrosoft:mainfrom
Closed
Consomme: Add timeout for UDP connections and DNS resolution support #2534damanm24 wants to merge 36 commits intomicrosoft:mainfrom
damanm24 wants to merge 36 commits intomicrosoft:mainfrom
Conversation
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds two major features to the consomme network backend: DNS resolution support using Windows DNS Raw APIs (similar to WSL's implementation) and UDP connection timeout tracking per RFC 4787.
Key Changes:
- Implements DNS resolution by intercepting DNS queries to the gateway (10.0.0.1) and forwarding them to the host's DNS resolver via Windows DNS Raw APIs, with a Unix stub for future implementation
- Adds 5-minute UDP connection timeout tracking to prevent connection state leaks
- Refactors UDP packet construction into a reusable helper function
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/devices/net/net_consomme/consomme/src/dns_resolver_windows.rs | New Windows DNS resolver implementation using DNS Raw APIs with FFI bindings and async callback handling |
| vm/devices/net/net_consomme/consomme/src/dns_resolver_unix.rs | Unix stub for DNS resolver (not yet implemented, uses todo!()) |
| vm/devices/net/net_consomme/consomme/src/lib.rs | Integrates DNS resolver into Consomme, adds DnsResponse struct and DnsError variant, configures gateway as nameserver when DNS APIs available |
| vm/devices/net/net_consomme/consomme/src/udp.rs | Adds UDP timeout tracking with last_activity timestamp, implements DNS query/response handling for UDP, refactors packet building |
| vm/devices/net/net_consomme/consomme/src/tcp.rs | Implements DNS over TCP support with separate connection handling for DNS queries to gateway:53 |
| vm/devices/net/net_consomme/consomme/Cargo.toml | Adds dependencies: pal, winapi, and Windows DNS management features |
| vm/devices/net/net_consomme/src/lib.rs | Adds DnsError to drop reason handling |
| Cargo.lock | Updates resolv-conf dependency version and adds new dependencies |
Critical Issues Found:
- Memory safety bug in Windows DNS callback that creates dangling pointers
- Unix stub returns success but will panic on use
- Multiple buffer overflow vulnerabilities in DNS response handling
- DNS query processing bug that includes TCP framing in the query data
- Security issues with insufficient input validation that could enable DoS attacks
vm/devices/net/net_consomme/consomme/src/dns_resolver_windows.rs
Outdated
Show resolved
Hide resolved
vm/devices/net/net_consomme/consomme/src/dns_resolver_windows.rs
Outdated
Show resolved
Hide resolved
vm/devices/net/net_consomme/consomme/src/dns_resolver_windows.rs
Outdated
Show resolved
Hide resolved
vm/devices/net/net_consomme/consomme/src/dns_resolver_windows.rs
Outdated
Show resolved
Hide resolved
vm/devices/net/net_consomme/consomme/src/dns_resolver_windows.rs
Outdated
Show resolved
Hide resolved
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.
This PR addresses two features in the consomme feature backlog:
UDP connection timeout tracking has been addressed according to RFC 4787. Specifically, if no traffic is observed in a given connection for at least 5 minutes (by default this value is configurable), then the socket is closed.
DNS resolution has been implemented similarly to the WSL implementation which can be found: https://github.com/microsoft/WSL/blob/fdfe1eb8439370c9eb6780467abc1e3f08f90eb1/src/windows/service/exe/DnsResolver.cpp#L9.