{
  "id": 23326088,
  "title": "How I harden my AI coding agent",
  "url": "https://urgent.news/2026/12/03/how-i-harden-my-ai-coding-agent",
  "topic": "ai",
  "section": "AI",
  "published": "2026-12-03T20:01:10.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/codehunter-py/how-i-harden-my-ai-coding-agent-3pl9"
  },
  "original_language": null,
  "account": "How I configure my AI coding assistant\n\nI remember once instructing an AI agent to remove a project's cache folder. It executed rm -rf on the entire project directory. This occurred on my personal laptop, and the agent possessed extensive access to my file system. Fortunately, I maintain daily backups, so I salvaged the project within a few minutes. Subsequently, I noticed agents opening ports that should have remained closed and executing commands they were not authorized to run. This experience prompted me to reevaluate my approach to AI agents. Now, I regard them as any other process I do not fully trust. Since the agent operates with my permissions, any mistakes it makes are ultimately my responsibility. Here are the guidelines I now follow:\n\n1. Every change requires approval. While the agent can freely read files, any write, installation, or command with side effects necessitates my explicit consent. At times, this can be cumbersome. In such cases, I provide the agent with a concise list of permissible commands it can execute without further authorization. All other actions still require my approval. I refrain from enabling auto-accept or skip-permission modes.\n\n2. No unauthorized installations on my Mac. I do not wish the agent to execute malicious Python scripts directly on my Mac. Consequently, the agent's tools, runtimes, and packages reside within a Lima VM accompanied by rootless Docker. All operations occur within containers. If any malicious activity arises, it remains confined within the VM, isolated from my system. The VM has sole access to a shared folder and no other components of my home directory. Containers are discarded after each execution. Mounts are read-only unless a test necessitates writing, and network access is disabled unless downloading is required. The agent never accesses secrets without explicit permission. It can verify a secret file's existence but never reads, prints, or commits the secret's value. When assessing a credential's validity, the agent examines the result rather than the value itself. If a secret were ever committed, I would rotate it, regardless of whether it resides in a private repository. Deleting it from the file does not eliminate it from Git history.\n\n3. Agents do not learn secrets. The agent may confirm the presence of a secret file but never reads, displays, or records the secret's content. To ascertain a credential's effectiveness, the agent inspects the output rather than the secret value. If a secret were ever committed, I would rotate it, even within a private repository. Erasing it from the file does not eradicate it from Git history.\n\n4. Branches, pull requests, and manual merging. The agent operates on a separate branch and never pushes changes without my authorization. Each modification undergoes a pull request with automated checks, and I review the differences before merging. When multiple agents collaborate on the same repository, one is responsible for development, while the other reviews. Only I have the authority to merge changes.\n\n5. Every agent receives a written scope. A written scope defines the agent's specific task, akin to a harness. Review agents are granted read-only tools. My security agent conducts code, dependency, and public endpoint audits from an isolated container, operating in read-only mode by default. Active tests require my approval for each target and technique. The agent can propose changes to its scope, but they only take effect upon my approval. I would not endorse anyone operating an agent with unrestricted access. An agent with full access poses a significant risk, capable of compromising your server at any time.\n\n6. On production servers, commands are executed by me. In production environments, the agent presents me with commands instead of executing them directly. Prior to any irreversible action, I create a snapshot. This serves as my backup protocol, stemming from the initial guidelines in this article, now formalized as a rule.\n\n7. Skills are third-party code. A skill represents a set of instructions the agent will adhere to, necessitating thorough vetting. I scrutinize each skill like any dependency, pinning it to a specific commit and examining the code for prompt injection and data exfiltration vulnerabilities before integration. This is also why skills operate within the VM rather than on my Mac.",
  "summary": "I once asked an AI agent to delete a project's cache folder. It ran rm -rf on the whole project folder. This was on my laptop, and the agent had almost full access to my file system. Luckily I had daily backups, so I restored the project in a couple of minutes. Another time, agents opened ports that should have stayed closed and ran commands they shouldn't have run. That's when I stopped treating…",
  "summary_source": "publisher",
  "key_points": [
    "Every change requires approval; agent cannot auto-accept or skip permissions.",
    "Agent operates within Lima VM and Docker containers; no unauthorized installations on Mac.",
    "Agents do not learn secrets; can only verify existence, not read or commit secret values."
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "outlets_capped": false,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}