Reject foreign DHCP replies before policy fallback - #196
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bc5a21904
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| let Ok(udp_pkt) = UdpPacket::new_checked(ipv4_pkt.payload()) else { | ||
| return false; | ||
| return DhcpResponseDisposition::NotDhcp; |
There was a problem hiding this comment.
Reject fragmented DHCP replies instead of falling through
When a BOOTP reply is IPv4-fragmented, the first fragment's UDP length describes the complete datagram, so UdpPacket::new_checked rejects the shorter fragment; later fragments contain no UDP header. Returning NotDhcp here sends every fragment through generic policy, which unconditionally permits them when flows is None, allowing the guest to reassemble a foreign DHCP reply and bypass the new client-MAC check. Fragmented gateway UDP traffic must be rejected or reassembled before deciding that it is not DHCP.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Let's handle this separately in #197, seems out-of-scope because this PR doesn't introduce this issue.
In #192, additional filtering for DHCP messages coming from the host side was added.
However, foreign DHCP replies were not explicitly rejected and could still fall through to normal host → VM policy and be forwarded to the VM.
Add an enum to properly distinguish between non-DHCP traffic, allowed DHCP replies, and rejected DHCP replies.
/cc @genforAI