Repository navigation
Conversation
…sbx refuses its DNS lookup
Author
|
@HarshCasper - sorry for all the noise - Claude needed quite a bit of wrangling (and my first time playing with sbx) but I think I finally got it in a decent spot.. |
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.
Fixes #1.
Problem
sbx0.51.0 resolves a name only if a network rule allows it, and it refuses the DNS lookup of a name that a deny rule lists. Two kit rules then break LocalStack hostnames:The kit denies
localhost.localstack.cloudand**.localhost.localstack.cloud, so these names do not resolve in the sandbox.NO_PROXYdoes not help, because a client must resolve the name before it connects directly.The kit does not allow
localstack.cloud. LocalStack looks up this name to find an upstream DNS server. The lookup fails, so the LocalStack DNS server does not start, and the names do not resolve in the LocalStack container or in Lambda containers. The LocalStack log shows:The AWS client of the LocalStack MCP server runs
awslocalin the LocalStack container with the endpointlocalhost.localstack.cloud, so every call fails withCould not connect to the endpoint URL.I found no earlier note about this in the repo, its history, or its issues. The smoke check "LocalStack hostnames reach the sandbox emulator" expects the name to resolve, and the kit comments name
sbx0.45, so this looks like a change insbx.Change
The fix is in the network rules of
kits/localstack/localstack.yaml. No script changes.localhost.localstack.cloudand**.localhost.localstack.cloud, and remove them from the deny rules. They resolve to127.0.0.1, which is the sandbox for a direct connection.localstack.cloud:443, so that the LocalStack DNS server finds its upstream and starts.localhost,127.0.0.0/8,::1/128, andhost.docker.internal.The deny rules for the names existed to keep a client that ignores
NO_PROXYaway from a LocalStack on the host. That protection stays:sbx0.51 checks the address that a name resolves to against the CIDR rules, so the rule for127.0.0.0/8refuses the names at the proxy. See "Isolation test" below.Also in this PR:
scripts/smoke.shhas four new checks: a LocalStack subdomain resolves in the sandbox, the LocalStack DNS server resolves a subdomain in its container, the MCP AWS client reaches LocalStack, and the name answers after a sandbox restart.docs/security.md, a new section indocs/troubleshooting.md, and lessons inAGENTS.md.Earlier versions of this PR wrote the name to
/etc/hostsand setLOCALSTACK_DNS_SERVERin the lstk wrapper. Both are gone. The hosts file had no wildcards, so subdomains did not resolve in the sandbox.Isolation test
A listener ran on the host at
127.0.0.1:4555. From the sandbox,curl --noproxy ''sent requests through the proxy.**localhost.localstack.cloud:4555x.localhost.localstack.cloud:4555localhost:4555,127.0.0.1:4555,host.docker.internal:4555127.0.0.1.nip.io:4555The host listener got no request from the sandbox.
sbx policy logshows the reason for the LocalStack names:denied: rule "kit:...:deny" matched op(action=net:connect:tcp, resource=net:cidr:127.0.0.1).Limits
sbx0.51.docs/security.mdsays to usesbx0.51 or later. I did not test an earliersbx.sbxhelp says that behind an upstream proxy that resolves the name,sbxchecks the name only. I did not test that setup.localstack.cloudbrings the problem back. The troubleshooting section shows how to find the rule.Tests
Platform: Linux (Arch, x86_64, KVM),
sbx0.51.0, local sandboxes, Docker, agentclaudeonly. Codex and macOS are not tested.make lint: no findings.scripts/smoke.sh claude --registry docker.io --tag 0.1.0from the first version of this branch. 16 checks pass and 3 fail: "LocalStack hostnames reach the sandbox emulator" (an old check), the MCP AWS client check, and the hostname check after a restart.make smoke,make project-config, ormake e2eon the changed kit. They need the local registry and a trusted certificate, and I could not add the trust on this machine. I made sandboxes withsbx create docker.io/docker/sbx-kit-claude:2.1.278 --kit ./kits/localstackand ran the checks by hand. No hosts entry and noDNS_SERVERsetting was in place.localstack-pro:latest, kit configlocalstack-pro:2026.10.6, project configtest.localhost.localstack.cloudto 127.0.0.1localhost.localstack.cloud, and an S3 subdomain URLNo upstream dns server foundpypi.org; notexample.comlocalstack-aws-clientcalllstk restartsbx stopand a new sessionlstk startno longer printsCould not resolve localhost.localstack.cloud, falling back to 127.0.0.1.Please run
make smokefor both agents on macOS before the merge.