{"slug": "your-agent-has-shell-access-so-does-everything-in-aws", "title": "Your agent has shell access. So does everything in ~/.aws.", "summary": "A developer who builds the GAL agent runtime described how standard coding-agent sandboxes restrict where commands may write but leave reads unrestricted, allowing credentials in files like ~/.aws/credentials, ~/.npmrc and inherited shell environments to leak into conversation transcripts and logs. The developer recommends keeping secrets off the agent's filesystem, attaching scoped credentials only at tool-call time, avoiding exported environment secrets, and auditing by hash rather than value so the audit log does not become a second copy of the secret.", "body_md": "*A sandbox decides where the agent may write. It says nothing about what it may read — and the reading is where the damage happens.*\n\nThe first time I gave a coding agent a shell, I did the responsible thing. I turned on its sandbox. I pointed it at one project directory. I told myself the agent could only touch what I had given it.\n\nThen I watched it run a build.\n\nThe build read `~/.npmrc`. It read the package manager's cache. It touched a socket under `/tmp`. It printed a path that started with `/home/me/.ssh` — not because the agent was curious, but because a tool it invoked had that path baked into its own defaults.\n\nNone of that was the agent misbehaving. All of it was ordinary. And a sandbox that draws a line around \"your project\" has almost nothing to say about any of it, because the line was never the whole story.\n\nNearly every agent sandbox I have used is honest about this in its own documentation, and almost nobody reads that part: the boundary is about **where a command may write**. Reads are treated as harmless. Reads are how you *inspect* things. Reads are safe.\n\nReads are also how credentials leave.\n\nAn `env` dump is a read. `cat ~/.aws/credentials` is a read. A subprocess that inherits the shell's environment has read your entire secret store without executing a single line that mentions it. The agent does not need to be malicious or even confused. It needs to run one command whose output happens to contain a token, and then that token is in the conversation transcript, in the log, and in whatever context gets summarised and re-sent on the next turn.\n\nI have had exactly this happen with a config file. Not because the agent went looking — because it asked a reasonable question and the answer was the config.\n\nAfter a few of these, I stopped trying to make the sandbox smarter and started asking a narrower question: **can the process read the credential at all?**\n\n**1. The credential should not be on the filesystem the agent can see.**\n\nThe strongest version of this is not a permission rule — it is absence. If the secret is not in the container's filesystem, no read reaches it, no matter what the agent invents. Anything short of absence is a policy, and policies have defaults you did not choose.\n\n**2. If it must be reachable, make it reachable only at call time, and only for one call.**\n\nAttach the secret to the specific tool call that needs it, and let it expire with that call. This turns \"the agent has my AWS key for the whole session\" into \"one command had a scoped token for four seconds.\" It also makes the audit question answerable later: which call used which credential.\n\n**3. Inherited environment is the leak nobody logs.**\n\nA subprocess does not need permission to see `os.environ`. Whatever you export into the parent shell is available to everything downstream, including the tool you forgot about. The fix is boring and effective: do not export secrets into the shell that runs the agent, and if you must, mask them at the point of use rather than storing them in the ambient environment.\n\n**4. Audit by hash, not by value.**\n\nHere is the trap I walked into: the audit log is itself a read surface. If it records \"the agent read the config, here are the contents\", you have built a second copy of the secret and given it a longer retention period. Record the fact and the fingerprint — path, time, hash before, hash after — and keep the contents out of it. The log should be able to tell you \"this changed\" without being able to tell you what it changed to.\n\nI build a runtime called GAL, so I am not a neutral party here — but the design constraint is the one I would hold any tool to: **scope every call, log the hash, keep the secret out of the process that does not need it, and make the first irreversible write leave a checkpoint behind it.**\n\nThat last part matters more than it sounds. The moment an agent has both read access and write access, the interesting failure is not \"it deleted a file.\" It is \"it deleted a file, and the reason is buried in a transcript that was summarised three times since.\"\n\nIf you are wiring an agent to a shell this week, the question worth answering before you start is not *which sandbox* — it is *what can this process read, and would I be comfortable if it read it out loud*.\n\nIf the answer is \"the AWS credentials,\" you have found your first task.", "url": "https://wpnews.pro/news/your-agent-has-shell-access-so-does-everything-in-aws", "canonical_source": "https://dev.to/galagent/your-agent-has-shell-access-so-does-everything-in-aws-44e5", "published_at": "2026-12-04 17:35:33+00:00", "updated_at": "2026-12-04 17:44:31.746057+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools", "developer-tools"], "entities": ["GAL"], "also_reported_by": [], "takeaway": "Sandboxes that only restrict writes still let agents read credentials via env dumps, ~/.aws/credentials and inherited subprocess environments, so scope secrets to single tool calls, keep them off the agent's filesystem, and log hashes instead of values.", "recommendation": {"advice": "Keep credentials off the agent's filesystem and out of exported shell environments, attach scoped tokens only to the specific tool call that needs them, and audit by path and hash rather than recording secret contents.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/your-agent-has-shell-access-so-does-everything-in-aws", "markdown": "https://wpnews.pro/news/your-agent-has-shell-access-so-does-everything-in-aws.md", "text": "https://wpnews.pro/news/your-agent-has-shell-access-so-does-everything-in-aws.txt", "jsonld": "https://wpnews.pro/news/your-agent-has-shell-access-so-does-everything-in-aws.jsonld"}}