Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
skyrpex
left a comment
There was a problem hiding this comment.
Although I would've done something different, the proposal looks good to me.
What I'd do though is just ignore or forbid the use of --profile and let any --endpoint-url to work, as it's an explicit parameter. Profile is really of no use for lstk aws as it's only reason to exist is to interact with LocalStack instances easily.
but we do create a profile called localstack during lstk setup, I think that's still relevant usecase? I only allow for --profile localstack (albeit without validation of the setup, that will be different ticket). My vision for later is that we ship a proxy that prevents those calls out to the aws hostanames. That way we can apply across emulators, but for now I decided on this guardrail instead of more complex setup. WDYT? |
|
Right, we do actually create that profile, and I didn't mean not to use it but to forbid the |
Motivation
lstk awsadds--endpoint-urlfor LocalStack, but a caller's own options can still send the call to real AWS, signed with real credentials:lstk aws sqs list-queues --endpoint-url https://sqs.us-east-1.amazonaws.com: the caller's--endpoint-urloverrides lstk's.lstk aws sqs list-queues --profile prod: signs withprod's credentials and runs itscredential_process, SSO refresh or STS AssumeRole against real AWS.The AWS CLI accepts abbreviations (
--endp,--e=…,--pro,--p=…). Today both are allowed on purpose (external-endpointandaws-proxyspecs). The MCP server blocks them itself; doing it in lstk covers every caller.Solution
Before starting the AWS CLI, on every path including help,
lstk awsrefuses:--endpoint-urlwhose host is an AWS partition domain or a subdomain of one (amazonaws.com,amazonaws.com.cn,api.aws,amazonaws.eu, isolated partitions);--endpoint-urlthat is an IP address without a port (a bare IP could be AWS; an emulator always has a port);--profileother thanlocalstack, the profilelstk setup awswrites. That one adds no new trust: lstk already selects it throughAWS_PROFILEtoday.Any
--prefix of either name counts, in both--opt valueand--opt=valueforms, anywhere in the arguments. That matches what AWS CLI 2.42.3 resolves: its global options win when abbreviated, so--pis--profileeven ins3api list-objects-v2, which has--prefix.Any other
--endpoint-url(another hostname, an IP with a port) still passes through, because people run LocalStack under their own hostnames. The refusal needs neither Docker nor an emulator:This is a guardrail, not a guarantee. A local proxy that refuses non-emulator traffic was measured and left to a follow-up: the cheap variant misses URL rewrites like MRAP, the complete one has to forward all emulator traffic, and both override a corporate
HTTPS_PROXY. Details are indesign.md.Tests:
TestAWSCommandRefusesRealAWSEndpointAndProfile(13 cases, all failed before) andTestAWSCommandAllowsNonAWSEndpoints(8 cases, including--profile localstack), plusTestFindRealAWSOption. Values the AWS CLI rejects itself (no scheme, empty) are left to it;TestAWSCommandSchemelessEndpointIsRejectedByTheCLIruns the real CLI to prove they never reach the emulator or AWS.Spec:
openspec/changes/refuse-real-aws-options/. One wart: openspec won't drop an existing scenario, so "A user-supplied profile flag wins and disables account selection" keeps its name while its WHEN/THEN now describe the refusal.Docs
Nothing to document:
lstk aws --helpstates the rule.Review
Human review advised: changes user-facing behavior that was previously specified (any
--profileand an AWS-pointing--endpoint-urlwere allowed), which breaks anyone relying on them.Closes DEVX-1345
🤖 Generated with Claude Code