Repository navigation
Conversation
The AWS client tool and the deployer's create-stack/delete-stack actions ran awslocal inside the LocalStack container. They now run the official AWS CLI v2 through `lstk aws` where the server runs, like Terraform, CDK and SAM. - Docker image: AWS CLI v2 copied from amazon/aws-cli (trimmed), Dependabot-managed - CI host-tools action exports the same CLI - Command checks keep every command on LocalStack (help tokens, option prefixes, stack names); the CLI gets no stdin - Tool tests, plus a live create/delete-stack test Towards DEVX-1330 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…workdir - Run lstk aws with an allow-listed environment and a private HOME: no user ~/.aws (profiles, credential_process, plugins, aliases, history), no AWS_* or LSTK_* from the server's environment - Route every request through the egress guard, which relays plain HTTP to LocalStack and refuses other hosts; disable Multi-Region Access Points - Hold local paths (s3 cp, file://, --body, outfiles) to LOCALSTACK_AWS_WORKDIR - Refuse commands that act on this machine (update, login, sso login, history, ssm start-session, codeartifact login, cloudformation package, ...) - Render help with mandoc in the image; strip overstrike - 30-day cooldown for the Dockerfile images; unique live-test names Towards DEVX-1330 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 4 found `--file-path`, `--priv-launch-key` and `--private-key` exempt as name options. The path rule now lists the options that take local files from the AWS CLI v2 source (customizations and streaming blobs), checks a name-like option's value when it names an existing file, and checks every file:// inside a value (shorthand `key@=fileb://…`). Refuses `wizard`, `logs start-live-tail` and `logs tail --follow`. Towards DEVX-1330 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t global options Round 5 found that a quoted `..` passed the raw-string traversal check and that relative positional paths were never resolved, so `s3 cp '../x'` read and wrote outside the workdir (and, without one, could write an alias into the private HOME). It also found that a global option before the operation (`cloudformation --no-cli-pager package`) shifted the deny list's word positions. - Check `..` on the parsed argv - Resolve every value but a name or URL, relative ones too, against the directory the CLI runs in, following symlinks; never allow the private HOME - Match a denied operation at any word after the service - Refuse lstk's own --config; add --no-follow-symlinks to s3 cp/mv/sync - Live test: the AWS client reaches the LocalStack the server started Towards DEVX-1330 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 6 found that option names prove nothing (the CLI accepts abbreviations: `--public-key` is `--public-key-outfile`), that the CLI expands `$VARS` in paths, and more commands that act on the machine. - Judge every value by its shape: relative ones resolve inside the directory the CLI runs in; absolute and ~ ones must be inside the workdir unless their first directory does not exist (a name such as /aws/lambda/f); file:// is always a path. Drops the PATH/NAME option lists and the over-blocking of values such as /start or /index.html - Refuse a leading $VAR, and / or the home directory as LOCALSTACK_AWS_WORKDIR - Deny deploy push, gamelift upload-build, lambda-web, lightsail push-container-image and cli-dev; catch abbreviations of --follow - Require AWS CLI 2.37.7+, whose downloads honor --no-follow-symlinks Towards DEVX-1330 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Linear: DEVX-1330 · related: DEVX-1331 (lstk fix this PR works around)
Summary
localstack-aws-clientand the deployer'screate-stack/delete-stackranawslocalinside the LocalStack container. They now run the official AWS CLI v2 throughlstk awswhere the server runs: on the user's machine with npx, or in the server's Docker image. The deployer already runs Terraform, CDK and SAM through lstk the same way.awslocalis AWS CLI v1 (1.46.3) that the LocalStack image happens to install, and the image's Dockerfile has a TODO to remove it.Decision: confine the CLI with rules (option B)
Inside the LocalStack container,
awslocalcould not see the user's files, AWS credentials,~/.awsconfig or programs. Run where the server runs, the CLI can. So an agent's command could, without these rules, reach real AWS with real credentials, read~/.aws/credentials, overwrite~/.zshrc, or startssh.We chose to keep the CLI where the server runs and confine it with a minimal set of rules, accepting that the rules on files and commands are a model of the CLI's behavior rather than a hard boundary.
lstk awsin a container that mounts only the workdir, read-only root, no docker.sock, network only to LocalStacks3 ls/cp/mv/rm/sync/mb/rb/presign); local files only throughfile://and outfilesawslocalhad; files and programs confined without modeling the CLI$VARS, shorthand)The network side is structural and has held since review round 4: the private HOME and env mean the CLI never sees real credentials or the user's AWS config, and the egress guard refuses every host but LocalStack, whatever route the CLI takes.
The rules
child-env.ts). Built from an allow-list. HOME is private, so there's no user~/.aws: no profiles,credential_process, plugins, aliases or history.AWS_*andLSTK_*are dropped. The endpoint, test credentials and region are pinned,AWS_IGNORE_CONFIGURED_ENDPOINT_URLS=false, and Multi-Region Access Points are off.egress-guard.ts, shared with the Azure tool). Every request goes through it as the HTTP(S) proxy. It relays plain HTTP to the LocalStack host and its subdomains on the LocalStack port, and refuses every other host. A refusal fails the tool call.NO_PROXY: botocore picks a client's proxy from its configured endpoint, so a request rewritten to another host would bypass the guard.aws-cli-sanitizer.ts, on the parsed argv)....--endpoint-url/--profileor their abbreviations, and no lstk--config.helponly as the end of a pure help request (lstk bug, DEVX-1331).update, logins,ssh/sessions/tunnels,codeartifact login,eks update-kubeconfig,cloudformation package,deploy push,gamelift upload-build,lambda-web,lightsail push-container-image,history,wizard,cli-dev, and streams that never end.local-paths.ts). The CLI runs inLOCALSTACK_AWS_WORKDIR. It defaults to the server's directory, with none in the Docker image or when the server runs in/or the home directory. Every value is judged by its shape, not its option name, because the CLI accepts abbreviated option names:~values must be inside the workdir, unless their first directory doesn't exist on the machine (a name such as/aws/lambda/f).file://values and shorthand@=loads are always paths.$VARis refused, because the CLI expands it in paths.s3 cp/mv/syncget--no-follow-symlinks, which needs AWS CLI ≥ 2.37.7.Evidence
yarn test: 564 passed, including:lstk/aws.lstkthat reads stdin and sends requests through the guard. It shows the private HOME, the droppedAWS_PROFILE/AWS_ENDPOINT_URL_S3/LSTK_ENDPOINT_URL, relays to LocalStack subdomains with the Host header kept, and a blockeds3.amazonaws.com.lstk1.4.5 andaws2.40.4 against a fake LocalStack, on the host and in the image built from this branch (aws-cli/2.39.3,lstk 1.4.4). Every exploit from the six review rounds is refused, everyday commands work, andhelprenders.tests/mcp/tools.spec.mjs:lstk aws.update.LOCALSTACK_AUTH_TOKEN.tsc --noEmitclean.Merge Danger
Door: two-way
Blast Radius: every AWS CLI call an agent makes through the server, and the image size
lstkand AWS CLI ≥ 2.37.7 on the PATH.LOCALSTACK_AWS_WORKDIR, which defaults to the server's directory. In the Docker image there is none unless it's set.aws_completerare trimmed). TheFROMimages now wait 30 days for updates, because the AWS CLI releases almost daily.TODO
yarn test:mcp:toolsandtests/docker/validate-image.mjswith an auth token.create-stackreadstemplatePathfrom anywhere, as before this PR (the deployer works on any project directory).src/core/command-runner.tsnever fires, becausechild.killedis already true after SIGTERM. lstk does stop aws on SIGTERM.🤖 Generated with Claude Code