Restrict Cloud Pod identity reuse to local emulators - #416
Conversation
0646975 to
4826956
Compare
|
I'm a little bit concerned about the security aspects of this PR. Are we saying that an |
Co-Authored-By: Claude <noreply@anthropic.com>
4826956 to
6f2831c
Compare
|
Good callout. The intent is to remove repeated authentication friction for a locally managed, single-user emulator, not to make network access equivalent to authorization. ✔️ I’ve narrowed the PR so startup-identity reuse now applies only to an lstk-managed local emulator. External targets require caller authentication from the environment or keychain before any Cloud Pod load, save, remove, or dry-run operation. S3 remotes remain separate because they use the caller’s AWS credentials. I think that’s the right boundary for this PR. Separately, we could harden the emulator so privileged endpoints authenticate every request, ideally with a scoped instance credential rather than the container’s platform token. Could you take another look at this new approach? |
Summary
lstk startpassesLOCALSTACK_AUTH_TOKENto the emulator without persisting an environment-provided secret. A later command against that same locally managed emulator can therefore have no caller token even though the emulator already has a valid startup identity.This change lets emulator-backed Cloud Pod operations reuse that identity only for an lstk-managed local emulator. When the caller supplies a token, lstk continues to send it as the
Authorizationheader, overriding the startup identity.External endpoints do not get this fallback.
snapshot load,save,remove, andload --dry-runrequire a token from the environment or keychain before lstk calls a protected pod endpoint. Network access to an external emulator is therefore not treated as permission to use its startup identity.Platform-direct
snapshot list,show, andversionscontinue to require caller authentication. S3 remotes are unchanged because they use the caller's AWS credentials instead of a LocalStack platform token.Error handling
When a locally managed emulator cannot use either the caller token or its startup identity, 401/403 responses are mapped to
snapshot.ErrAuthRequiredand rendered as an actionable authentication error. Pod/version not-found and unavailable-feature classifications keep precedence over the generic auth mapping.This change limits lstk's client behavior; it does not add request authentication to the emulator itself. Per-request protection of privileged emulator endpoints remains a separate server-side hardening concern.
Verification
go test ./cmd ./internal/emulator/aws ./internal/snapshotmake test-integration RUN=TestExternalPodOperationsRequireCallerAuthenticationmake test-integration RUN=TestSnapshotLoadPodVersiongo vet ./...in the root and integration-test modulesThe full unit run passed 1,516 of 1,517 tests. The remaining port-sensitive test could not bind because an existing
localstack-snowflakecontainer already owned port 4510.Review: advisable — this changes the authentication boundary for emulator-backed Cloud Pod operations.
Co-Authored-By: Claude noreply@anthropic.com
Closes DEVX-1022