Skip to content

Consomme: Add timeout for UDP connections and DNS resolution support #2534

Closed
damanm24 wants to merge 36 commits intomicrosoft:mainfrom
damanm24:udp_timeout_v3
Closed

Consomme: Add timeout for UDP connections and DNS resolution support #2534
damanm24 wants to merge 36 commits intomicrosoft:mainfrom
damanm24:udp_timeout_v3

Conversation

@damanm24
Copy link
Contributor

@damanm24 damanm24 commented Dec 4, 2025

This PR addresses two features in the consomme feature backlog:

  1. UDP - leaking of connection state
  2. DNS resolution support similar to how WSL resolves DNS requests with Win32 APIs.

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.

Copilot AI review requested due to automatic review settings December 4, 2025 00:10
@damanm24 damanm24 requested review from a team as code owners December 4, 2025 00:10
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

@damanm24 damanm24 marked this pull request as draft December 12, 2025 21:50
@damanm24 damanm24 closed this Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants