Skip to content

Fix WireGuard verdict caching and TCP overlap handling - #913

Merged
kasnder merged 20 commits into
masterfrom
codex/fix-high-hotpath
Sep 6, 2026
Merged

Fix WireGuard verdict caching and TCP overlap handling#913
kasnder merged 20 commits into
masterfrom
codex/fix-high-hotpath

Conversation

@kasnder

@kasnder kasnder commented Sep 5, 2026

Copy link
Copy Markdown
Member

The remaining changes cache and revoke WireGuard flow verdicts and normalise overlapping TCP segments. DNS provenance, UDP lifetime, socket defence and other bounded fixes have already landed in master through #924#926.

Reconciled with master 5addee60 after the combined Pixel-tested batch #926. The remaining chain is #913#915#916#919; #912, #917 and #918 are superseded. These remaining layers are held for a separate combined validation and merge decision. Passing the bounded batch does not establish full readiness for TCP state-machine and WireGuard policy/recovery changes.

Reconciliation validation: the combined remaining tip passed GitHub JVM tests and a four-ABI GitHub debug build; native defensive UBSan suites passed on Pixel, and the DNS framing/real-parser suites passed host ASan/UBSan. The TCP half-close/real-epoll fixtures passed on Pixel after adapting their no-op DNS stubs to the merged replay API. Only #926's APK was installed on the Pixel; the held stack's APK was built, not installed. New CI runs are not being waited on. Older-Android, controlled tunnel faults, per-app TCP/QUIC revocation, battery and rollout coverage remain outstanding.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T13:16:34.898559Z c8e5e62 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8e5e625c8

ℹ️ 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".

Comment thread app/src/main/jni/netguard/policy.c Outdated
Comment on lines +377 to +378
route_flow_store(version, protocol, saddr, sport, daddr, dport,
route_default_is_tunnel(), 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the per-app route when storing TCP verdicts

When a TCP flow's per-app route differs from the global default, resolve_tunnel_uid() first stores the correct route, but this unconditional call overwrites it with route_default_is_tunnel() and also clears uid_known. On the next packet, selected-mode flows can fall back to direct forwarding and reset because no native session exists, while an app explicitly excluded from a default tunnel can instead be sent through WireGuard. Store the verdict on the existing entry without replacing its route metadata.

Useful? React with 👍 / 👎.

Comment on lines +350 to +354
if depth < MAX_CNAME_CHAIN_DEPTH {
if let Some(links) = cname_links.get(name) {
for link in links {
path.push(link.clone());
collect_chain(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bound total CNAME graph traversal work

A DNS response containing repeated or branching CNAME links can make this recursive loop perform exponentially many visits: visited prevents only cycles on the current path and is cleared on return, while output deduplication happens after each path has already been traversed. For example, ten duplicate links at each of eight levels fit easily in one DNS response but induce roughly 100 million recursive walks, allowing an attacker-controlled lookup response to stall the packet path and consume substantial CPU. Deduplicate edges and memoize completed nodes, or enforce a global traversal budget.

Useful? React with 👍 / 👎.

@kasnder
kasnder changed the base branch from codex/fix-easy-hotpath to master September 6, 2026 12:13
@kasnder kasnder changed the title Fix high-severity packet hotpath bugs Fix WireGuard verdict caching and TCP overlap handling Sep 6, 2026
@kasnder
kasnder merged commit 07bf3cf into master Sep 6, 2026
3 checks passed
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.

1 participant