fix(sandbox): allow DNS resolution and direct TCP from sandbox netns#675
Closed
kosaku-sim wants to merge 4 commits intoNVIDIA:mainfrom
Closed
fix(sandbox): allow DNS resolution and direct TCP from sandbox netns#675kosaku-sim wants to merge 4 commits intoNVIDIA:mainfrom
kosaku-sim wants to merge 4 commits intoNVIDIA:mainfrom
Conversation
The sandbox iptables rules unconditionally REJECT all UDP traffic, which blocks DNS resolution for libraries that bypass HTTP_PROXY (e.g. Node.js ws used by @slack/socket-mode). Add an ACCEPT rule for UDP port 53 to the nameserver from /etc/resolv.conf (or OPENSHELL_DNS_SERVER env override) before the blanket UDP REJECT, so sandboxed processes can resolve external hostnames without opening a broad UDP hole. Fixes: NVIDIA/NemoClaw#409 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The DNS ACCEPT iptables rule alone is insufficient because the sandbox netns routes everything via 10.200.0.1 (host veth). DNS UDP packets reach the host side but the pod network cannot route responses back to 10.200.0.2 (sandbox IP). Enable IP forwarding on the host veth and add MASQUERADE so DNS packets appear to come from the pod IP, allowing CoreDNS to respond correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Landlock WARN log is emitted to stderr with ANSI color codes on every kubectl exec invocation. When SSH or kubectl exec pipes stdin to sandbox commands, the ANSI output corrupts file contents (e.g., openclaw.json config). Downgrading to debug prevents this pollution in default log levels while keeping the diagnostic available with RUST_LOG=debug. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Libraries like Node.js ws (used by @slack/socket-mode) resolve DNS then connect directly to the resolved IP on TCP 443, ignoring HTTP_PROXY. The sandbox iptables REJECT all bypass TCP, breaking these connections even after DNS resolution succeeds. Add OPENSHELL_DIRECT_TCP_HOSTS env var (comma-separated hostnames). At sandbox netns setup, resolve these hosts and install: - iptables ACCEPT for TCP 443 to resolved IPs (sandbox side) - MASQUERADE + FORWARD rules (host side) for return routing This pairs with the DNS ACCEPT rule from the previous commit to provide full direct connectivity for proxy-unaware libraries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thank you for your interest in contributing to OpenShell, @kosaku-sim. This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer. To get vouched:
See CONTRIBUTING.md for details. |
|
Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text: I have read the DCO document and I hereby sign the DCO. You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sandbox processes that bypass
HTTP_PROXY(e.g., Node.jswslibrary used by@slack/socket-mode) fail withgetaddrinfo EAI_AGAINbecause:10.200.0.1), but no IP forwarding or NAT is configured for non-proxy trafficThis PR fixes all three layers.
Changes
1. UDP DNS ACCEPT rule (
netns.rs)Insert an iptables ACCEPT rule for UDP port 53 to the cluster nameserver (read from
/etc/resolv.conforOPENSHELL_DNS_SERVERenv var) before the blanket UDP REJECT rule.2. IP forwarding + MASQUERADE (
netns.rs)Enable IP forwarding on the host-side veth interface and add MASQUERADE rules so that:
10.200.0.2) appear to come from the pod IP when reaching CoreDNS3. Direct TCP 443 via
OPENSHELL_DIRECT_TCP_HOSTS(netns.rs)New environment variable
OPENSHELL_DIRECT_TCP_HOSTS(comma-separated hostnames). At sandbox netns setup:This provides direct connectivity for proxy-unaware libraries while keeping the default deny-all policy intact for unlisted destinations.
4. Landlock warning log level (
landlock.rs)Downgrade the "Landlock filesystem sandbox is UNAVAILABLE" message from
warn!todebug!. The ANSI-colored warning is emitted on everykubectl execinvocation, and when piped through SSH or kubectl stdin, corrupts file contents with\x1bescape codes (e.g., JSON config files become unparseable).Security considerations
/32) on UDP port 53 onlyTesting
Tested on NemoClaw (OpenClaw on AWS) with:
@slack/socket-mode(Node.jswslibrary)Related issues
Signed-off-by: Kazuya Kosaku kosaku@simount.com