app-entwickeln-lassen.de LogoApp entwickeln lassen

Agentic Coding

Running Coding Agents Securely: Sandboxing, Permissions, Approvals

app-entwickeln-lassen.de editorial team 6 min read
Contents
  1. Why coding agents need their own security concept
  2. Sandboxing: isolate the execution environment
  3. Permissions: the principle of least privilege
  4. Approvals: involve humans at the right moments
  5. Protecting secrets and credentials
  6. Checklist for secure operation
  7. Conclusion
  8. Frequently Asked Questions

Running coding agents securely means deliberately limiting what they can do: through an isolated execution environment (sandbox), fine-grained permissions and human approval for critical actions. An agent that is allowed to execute commands has, in principle, the same capabilities as the person whose account it runs under.

Why coding agents need their own security concept

A code assistant that only makes suggestions is manageable from a security perspective. An agent, however, reads files, writes code, runs shell commands, installs packages and may access the network. If it runs directly on a developer's laptop, it potentially has access to SSH keys, cloud credentials, browser sessions and every local repository.

On top of that come risks that do not exist in this form in traditional development:

  • Prompt injection: the agent reads content from issues, web pages, documentation or dependencies. If these contain hidden instructions, it may mistake them for its assignment.
  • Mistakes: a misunderstood task can lead to destructive commands, such as deleting files or resetting a branch.
  • Data exfiltration: with network access, a manipulated agent could send secrets or code to external addresses.
  • Supply chain: agents install packages and suggest dependencies – in the worst case including non-existent or malicious ones.

The fundamental risks of AI-generated code are covered in our article on security risks of AI code. This article focuses on the agent's operating environment itself.

Sandboxing: isolate the execution environment

A sandbox limits what the agent can technically access – regardless of what it "wants". Common options:

OptionIsolationSuitable for
Built-in tool sandbox (file system and network restrictions at OS level)MediumLocal work on developer machines
Dev container / Docker containerMedium to highTeams with a standardised development environment
Virtual machine or cloud development environmentHighAutonomous runs, sensitive projects
Ephemeral CI runnersHighAgents in pipelines, automated pull requests

Key principles regardless of the option:

  • File system: write access only to the project directory, no mounting of the home directory.
  • Network: blocked by default or limited to an allowlist (e.g. package registry, internal Git instance).
  • Short-lived: discard environments after the run instead of reusing them indefinitely.
  • No production access: neither database credentials nor deploy keys inside the sandbox.

Permissions: the principle of least privilege

Most coding agents offer configurable permission levels. Instead of allowing everything, define which actions are automatic, require confirmation or are forbidden. A proven model:

  1. Always allowed: reading project files, searching code, running tests and linters.
  2. With confirmation: editing files, installing new packages, creating Git commits.
  3. Manual only, by humans: pushing to protected branches, deleting outside the working directory, accessing secrets, deployments.

Store these rules centrally in the repository so they apply to all team members, and add explicit deny lists for particularly dangerous commands. Make sure allow rules are not too broad – permitting "all shell commands starting with npm" also includes scripts that can execute arbitrary code.

Approvals: involve humans at the right moments

Approvals only work if they are given consciously. Anyone who clicks "yes" a hundred times a day eventually stops checking. The goal is therefore to focus approvals on the truly critical moments:

  • before changes to dependencies, CI configuration or security settings,
  • before any action with effects outside the sandbox (push, deployment, external API calls),
  • when merging a pull request – here through regular code review.

A pattern that works well: the agent operates largely freely inside the sandbox, but its output only leaves the sandbox as a pull request. Branch protection rules ensure that nobody – not even an agent – writes to the main branch without review.

Protecting secrets and credentials

Secrets never belong in an agent's context. Concrete measures:

  • Exclude .env files and key files from reading via configuration.
  • Use only dummy credentials or dedicated test accounts with minimal rights for tests.
  • Enable secret scanning in pre-commit hooks and CI.
  • Issue agent tokens with short lifetimes and tightly limited scopes.

You will find more in our article on agentic coding and data security. When agents are connected to further tools via interfaces such as the Model Context Protocol (MCP), the same principle applies: every connected server widens the attack surface and should come from a trusted source and have minimal permissions.

Checklist for secure operation

  1. The agent runs in a sandbox, container or isolated cloud environment.
  2. Network access is blocked by default or restricted via allowlist.
  3. Permission rules are versioned in the repository and binding for everyone.
  4. Secrets are neither readable nor reachable via environment variables.
  5. Protected branches prevent merges without human review.
  6. New dependencies are checked before installation.
  7. Connected tool servers are inventoried and minimally privileged.
  8. Agent activity is logged and traceable.

We also train the practical implementation of these points in workshops: we place AI developers from real-world practice as trainers, from €799 net. Read more in our article on the security workshop for working safely with coding agents.

Planning an app? Request a free fixed-price quote in 2 minutes

Conclusion

Security with coding agents does not come from trusting the model, but from architecture. A sandbox limits potential damage, tiered permissions prevent mistakes, and targeted approvals keep humans accountable where it matters. Teams that combine these three layers can use agents productively without putting production systems or credentials at risk.

Frequently Asked Questions

Is it dangerous to run a coding agent directly on my own machine?

It is possible, but riskier than necessary, because the agent basically has your user account's rights. At a minimum, use the tool's built-in sandbox or a dev container.

What is prompt injection in the context of coding agents?

Content the agent reads, such as an issue or a web page, contains hidden instructions. The agent may wrongly follow them, which is why sandboxing and restricted network access matter so much.

Should an agent be allowed to push to the main branch on its own?

No. Agent output should arrive as a pull request and go through human review before merging, enforced by branch protection rules.

How do I prevent an agent from reading secrets?

Exclude secret files via configuration, keep production credentials out of the environment and use secret scanning in hooks and CI.

This article was written by the editorial team of app-entwickeln-lassen.de – the app and AI development service of jocapps GmbH, based in Freiburg, Germany, and building apps since 2014. The content is for general information and does not replace individual (legal) advice.

You might also like

Agentic CodingThe Best Agentic Coding Workflows for Web and App Projects

Agentic coding workflows for web and app projects: six proven approaches from spec-first to UI iteration – with use cases, limits and concrete steps.

6 min read
Agentic CodingMulti-Agent Systems in Software Development: When They Pay Off

Multi-agent systems in software development: which patterns exist, when several agents are genuinely faster and when a single agent remains the better choice.

5 min read
Agentic CodingIntroducing Agentic Coding in Your Company: A 90-Day Plan

Introducing agentic coding in your company: a practical 90-day plan with pilot phase, guardrails and metrics – turning experiments into measurable value.

6 min read
Agentic CodingAgentic Coding and Test-Driven Development: A Powerful Pair

Combining agentic coding and test-driven development: how TDD gives coding agents objective feedback, which pitfalls to avoid and what the workflow looks like.

5 min read
Agentic CodingHow Coding Agents Work: Plan, Execute, Verify

How coding agents work: the agent loop of planning, executing and verifying explained clearly – with a practical example, limits and tips for better results.

7 min read
Agentic CodingCoding Agents in CI/CD: Automated Pull Requests and Reviews

Using coding agents in your CI/CD pipeline: automated pull requests, AI reviews and failure analysis – with proven use cases, guardrails and cost control.

6 min read