Agentic Coding Tools

Security Risks of Coding Agents: Prompt Injection, Secrets, Permissions

Coding agents can read files, run commands and call external tools, which makes them powerful and creates real security risks. The main threats are prompt injection through untrusted content, exposure of secrets, overly broad permissions, risky dependencies and unvetted MCP servers. Each can be managed with clear configuration, isolation and review habits.

neooutput editorial team 4 min read Auf Deutsch lesen

Why coding agents change the threat model

A coding agent acts with the permissions of the developer who runs it, and it can be influenced by any text it reads.

Traditional tools do exactly what they are told. Agents interpret instructions and content, decide which actions to take and execute them. If the agent reads malicious instructions hidden in a file, an issue or a web page, or if it has access to credentials it does not need, the consequences can reach well beyond a bad code suggestion. Security for agents is therefore about limiting what they can access and do, and about treating their inputs with suspicion.

This is not a reason to avoid agents. It is a reason to configure them deliberately, the same way you would configure access for a new contractor: clear scope, minimal permissions and review of their work.

Prompt injection

Prompt injection happens when content the agent processes contains instructions that try to make it do something the user did not intend.

Sources include issue descriptions, pull requests from external contributors, documentation pages, README files of dependencies, error messages and tool outputs from MCP servers. An injected instruction might ask the agent to send environment variables somewhere, modify CI configuration or add a malicious dependency. No model is fully immune, so defenses must be structural: restrict network access and dangerous commands, require approval for sensitive actions and review changes before they are merged.

Secrets and credentials

Anything an agent can read may end up in its context, and therefore potentially in logs, outputs or transmitted data.

Keep production credentials out of development environments altogether. Use environment-specific, short-lived and narrowly scoped tokens. Configure the agent to ignore files like local environment files where your tool supports it, and use secret scanning in pre-commit hooks and CI to catch accidental commits. Never paste credentials into prompts, and be careful with logs, database dumps and configuration exports that agents might read.

Permissions and execution

Overly broad permissions turn small mistakes into incidents, so default to least privilege.

  • Avoid blanket auto-approval of all shell commands, especially in unfamiliar repositories.
  • Use allow-lists for routine commands like tests and linting, and require confirmation for others.
  • Deny destructive or sensitive operations such as force pushes, deployments and infrastructure changes.
  • Run high-autonomy sessions in sandboxes, containers or cloud environments without production access.
  • Commit shared permission settings so the whole team uses reviewed defaults.

Supply chain and dependency risks

Agents readily add packages, and they can suggest packages that are outdated, vulnerable or even non-existent.

Attackers exploit this by publishing malicious packages with names that models tend to hallucinate or that resemble popular libraries. Require review of every new dependency, use lockfiles, enable dependency scanning in CI and consider an internal registry or allow-list for critical projects. Add a rule to your context file that the agent must not add dependencies without explicit approval.

MCP servers and external tools

Each MCP server extends the agent's capabilities and its attack surface, so treat servers like any other third-party software.

  1. Use servers from trusted sources and review what tools they expose.
  2. Grant minimal scopes, starting read-only where possible.
  3. Keep tool-call approval on for actions with side effects.
  4. Maintain an approved list of servers for the team or organization.
  5. Review and update servers regularly, and remove unused ones.

Building a secure agent setup

Security for coding agents works best as a combination of configuration, isolation, CI controls and trained people.

jocapps GmbH, the company behind neooutput, is ISO 27001 certified, and our AI Code Engineers apply these practices in daily client work. We cover agent security hands-on in our workshops, including permission configuration, secret handling and prompt injection awareness, and we review agent setups for teams. A short call is a good way to assess where your current setup stands.

Frequently asked questions

Can prompt injection be fully prevented?

Not reliably at the model level. Effective defense limits what an agent can do if it is manipulated: restricted permissions, no unnecessary credentials, sandboxing, network restrictions and human review before merge.

Is it safe to let an agent run commands automatically?

For a reviewed allow-list of routine commands like tests and linters, generally yes. Broad auto-approval is risky, especially in unfamiliar repositories or with untrusted content.

How do we keep secrets away from coding agents?

Keep production secrets out of development environments, use short-lived scoped tokens, exclude secret files from agent access where possible and enforce secret scanning in hooks and CI.

Are MCP servers a security risk?

They can be. Use trusted servers, minimal scopes and approval for side-effecting actions, and maintain an approved list for your team.

All insights