Skip to content

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Nov 13, 2025

Note

Centralizes sandbox network helpers, refactors firewall to predefined/user allow/deny sets with 0.0.0.0/0 handling, validates maskRequestHost, and returns slots on network config failure with expanded integration tests and deps updates.

  • API:
    • Validate network.maskRequestHost (IDNA/ASCII, optional port) and surface clear 400 errors.
    • Build network config using shared helpers; use AllInternetTrafficCIDR when allowInternetAccess=false.
    • Replace secure token error logging with telemetry.
  • Orchestrator:
    • Return network slot to pool when internet configuration fails in Pool.Get.
    • Refactor firewall:
      • Separate predefined allow/deny vs user allow/deny sets; enforce rule order (allow→deny).
      • Reset functions renamed to ResetAllSets, ResetAllowedSets, ResetDeniedSets.
      • Proper handling of 0.0.0.0/0 and incremental set updates.
    • Use shared CIDR conversion and AllInternetTrafficCIDR in server create path and instance builder.
  • Shared:
    • New sandbox-network package with AllInternetTrafficCIDR, default denied ranges, and address→CIDR helpers.
  • Tests:
    • Add/extend egress firewall integration tests (allow/block IPs & CIDRs, precedence, persistence, 0.0.0.0/0 cases).
    • Add unit tests for CIDR helper; remove obsolete firewall allow validation test.
  • Dependencies:
    • Add/update networking and logging libs (e.g., ngrok/firewall_toolkit, google/nftables, mdlayher/*, zerolog) in api/shared modules.

Written by Cursor Bugbot for commit 73a2bd2. This will update automatically on new commits. Configure here.

@dobrac dobrac added the bug Something isn't working label Nov 13, 2025
Copy link

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

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.

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

@dobrac dobrac force-pushed the fix-slot-return-on-network-fail-and-improve-network-validation branch 2 times, most recently from 2f85109 to ebe407f Compare November 13, 2025 19:41
@dobrac dobrac force-pushed the fix-slot-return-on-network-fail-and-improve-network-validation branch from ebe407f to 453c7ae Compare November 13, 2025 19:45
@dobrac dobrac assigned jakubno and unassigned sitole Nov 13, 2025
@dobrac dobrac force-pushed the fix-slot-return-on-network-fail-and-improve-network-validation branch from f4ca868 to 1d4ecd2 Compare November 13, 2025 21:29
@dobrac dobrac force-pushed the fix-slot-return-on-network-fail-and-improve-network-validation branch 3 times, most recently from 6111213 to 1f9e84e Compare November 14, 2025 09:45
@dobrac dobrac force-pushed the fix-slot-return-on-network-fail-and-improve-network-validation branch from 1f9e84e to 2b23561 Compare November 14, 2025 09:46
@dobrac dobrac requested a review from jakubno November 14, 2025 09:55
@dobrac dobrac force-pushed the fix-slot-return-on-network-fail-and-improve-network-validation branch from 083a4a8 to 4338833 Compare November 14, 2025 13:22
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Premature Flag Corrupts Firewall State

The firewallCustomRules flag is set to true before the firewall configuration is actually applied. If any error occurs after setting the flag (such as failing to get the network namespace or failing to add firewall rules), the function returns an error but leaves the flag set to true. When the slot is later returned to the pool and ResetInternet is called, it will attempt to reset firewall rules that were never successfully applied, potentially causing firewall state corruption or unexpected behavior.

packages/orchestrator/internal/sandbox/network/slot.go#L262-L290

s.firewallCustomRules.Store(true)
n, err := ns.GetNS(filepath.Join(netNamespacesDir, s.NamespaceID()))
if err != nil {
return fmt.Errorf("failed to get slot network namespace '%s': %w", s.NamespaceID(), err)
}
defer n.Close()
err = n.Do(func(_ ns.NetNS) error {
for _, cidr := range network.GetEgress().GetAllowedCidrs() {
err = s.Firewall.AddAllowedCIDR(cidr)
if err != nil {
return fmt.Errorf("error setting firewall rules: %w", err)
}
}
for _, cidr := range network.GetEgress().GetDeniedCidrs() {
err = s.Firewall.AddDeniedCIDR(cidr)
if err != nil {
return fmt.Errorf("error setting firewall rules: %w", err)
}
}
return nil
})
if err != nil {
return fmt.Errorf("failed execution in network namespace '%s': %w", s.NamespaceID(), err)
}

Fix in Cursor Fix in Web


@dobrac dobrac enabled auto-merge (squash) November 14, 2025 14:10
@dobrac dobrac merged commit c10493c into main Nov 14, 2025
27 checks passed
@dobrac dobrac deleted the fix-slot-return-on-network-fail-and-improve-network-validation branch November 14, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants