Skip to content

install WFP filters for Windows sandbox setup#20101

Merged
iceweasel-oai merged 5 commits into
mainfrom
codex/windows-wfp-filters
Apr 30, 2026
Merged

install WFP filters for Windows sandbox setup#20101
iceweasel-oai merged 5 commits into
mainfrom
codex/windows-wfp-filters

Conversation

@iceweasel-oai

@iceweasel-oai iceweasel-oai commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR installs a first wave of WFP (Windows Filtering Platform) filters that reduce the surface area of network egress vulnerabilities for the Windows Sandbox.

  • Add persistent Windows Filtering Platform provider, sublayer, and filters for the Windows sandbox offline account.
  • Install WFP filters during elevated full setup, log failures non-fatally, and emit setup metrics when analytics are enabled.
  • Bump the Windows sandbox setup version so existing users rerun full setup and receive the new filters.

What WFP is

Windows Filtering Platform (WFP) is the low-level Windows networking policy engine underneath things like Windows Firewall. It lets privileged code install persistent filtering rules at specific network stack layers, with conditions like "only traffic from this Windows account" or "only this remote port," and an action like block.

In this change, we create a Codex-owned persistent WFP provider and sublayer, then install block filters scoped to the Windows sandbox's offline user account via ALE_USER_ID. That means the filters are targeted at sandboxed processes running as that account, rather than globally affecting the host.

Initial filter set

We are starting with 12 concrete WFP filters across a few high-value bypass surfaces. The table below describes the filter families rather than one filter per row:

Area Concrete filters Purpose
ICMP 4 filters: ICMP v4/v6 on ALE_AUTH_CONNECT and ALE_RESOURCE_ASSIGNMENT Block direct ping-style network reachability checks from the offline account.
DNS 2 filters: remote port 53 on ALE_AUTH_CONNECT_V4/V6 Block direct DNS queries that bypass our intended proxy/offline path.
DNS-over-TLS 2 filters: remote port 853 on ALE_AUTH_CONNECT_V4/V6 Block encrypted DNS attempts that could bypass ordinary DNS interception.
SMB / NetBIOS 4 filters: remote ports 445 and 139 on ALE_AUTH_CONNECT_V4/V6 Block Windows file-sharing/network share traffic from sandboxed processes.

For IPv4/IPv6 coverage, the port-based filters are installed on both ALE_AUTH_CONNECT_V4 and ALE_AUTH_CONNECT_V6. ICMP also gets both connect-layer and resource-assignment-layer coverage because ICMP traffic is shaped differently from ordinary TCP/UDP port traffic.

Validation

  • cargo fmt -p codex-windows-sandbox (completed with existing stable-rustfmt warnings about imports_granularity = Item)
  • cargo test -p codex-windows-sandbox wfp::tests
  • cargo test -p codex-windows-sandbox (fails in existing legacy PowerShell sandbox tests because Microsoft.PowerShell.Utility could not be loaded; WFP tests passed before that failure)

@iceweasel-oai iceweasel-oai changed the title [codex] install WFP filters for Windows sandbox setup install WFP filters for Windows sandbox setup Apr 28, 2026
@iceweasel-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown
Contributor

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: 3a320a8db5

ℹ️ 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 codex-rs/windows-sandbox-rs/src/wfp_setup.rs
@iceweasel-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown
Contributor

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: eb66c8fad6

ℹ️ 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 on lines +608 to +615
install_wfp_filters(
&payload.codex_home,
&payload.offline_username,
payload.otel.as_ref(),
|message| {
let _ = log_line(log, message);
},
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Fail setup when WFP filter installation fails

This call ignores WFP install failures, so full setup can succeed without any WFP rules applied. Since setup version/marker are persisted earlier during user provisioning, affected users are considered up-to-date and will not automatically rerun full setup to retry filter install. A transient WFP error can therefore leave the sandbox permanently missing the new egress protections.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this should hard-block setup, not just emit telemetry. The new filters are part of the offline sandbox boundary, and provision_sandbox_users has already written the v6 marker before this call, so treating WFP failure as non-fatal creates a sticky degraded state: future runs think setup is current and never retry full setup.

Suggested fix: make install_wfp_filters(...) return Result<usize> or a typed setup result, propagate failure from run_setup_full, add a HelperWfpFilterInstallFailed setup error code, and add a regression test/marker proof that a WFP install failure prevents a successful setup marker. If we intentionally want a degraded mode, the marker needs to record wfp_filters_installed=false and force full setup retry before offline sandbox use; but for this PR I would fail closed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I'm just paranoid about it, especially after the recent bug to Windows Firewall rules that caused the setup to fail for all users. Combined with the fact that we can't do a statsig rollout in the CLI.

My thought was to have it fail silently at first and then make it a hard failure later. If there is a bug for some users, it will move them from "working elevated setup" to some state where they need to re-run the elevated setup and it fails every time. I think it would break codex for them, because we don't have the right UX for this kind of "marker driven re-run of setup"

Lemme think about it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

for now I'm going to leave it like this. I'm planning some improvements to the whole "setup marker" system and if I see that this is failing for users, I will build it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sg!

@iceweasel-oai iceweasel-oai marked this pull request as ready for review April 29, 2026 19:40
Comment thread codex-rs/windows-sandbox-rs/src/wfp_filter_specs.rs

@evawong-oai evawong-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved.

@iceweasel-oai iceweasel-oai merged commit 8121710 into main Apr 30, 2026
25 checks passed
@iceweasel-oai iceweasel-oai deleted the codex/windows-wfp-filters branch April 30, 2026 19:39
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants