DEV Community

Cover image for Your AI Agent Doesn't Need the Keys: A Beginner's Guide to Least Privilege
Tahami AK SERVICES
Tahami AK SERVICES

Posted on

Your AI Agent Doesn't Need the Keys: A Beginner's Guide to Least Privilege

Imagine building an AI coding assistant that can:

Read your project
Modify files
Run commands
Call APIs
Access Git
Interact with external tools

That's ...Read More

But from a security perspective, I immediately have another question:

What happens if the agent is manipulated?

This is where one of the oldest cybersecurity principles becomes extremely relevant:

Least privilege

Give a system only the permissions it ...Read More

Capability isn't authorization

An AI agent might be capable of deleting a file.

That doesn't mean it should have permission to delete every file.

It might be capable of calling an API.

That doesn't mean it needs administrator-level API access.

It might be capable of accessing a database.

That doesn't mean it ...Read More

This distinction is simple but important:

Capability ≠ authorization.

Why prompt injection makes this important

AI systems can process information from external sources.

That information might contain instructions that attempt to ...Read More

OWASP identifies prompt injection as a major AI security concern and recommends least-privilege access, human approval for high-risk operations and independent enforcement of...Read More

Consider two agents.

Agent A

Read-only access to one project.

Agent B

Read/write access to the entire machine + cloud credential ...Read More

If both encounter malicious instructions, the second architecture has a much larger potential blast radius.

That's why limiting permissions matters.

A simple security checklist

Before giving an AI agent a tool, ask:

  1. Does it actually need this tool?

If not, don't connect it.

  1. Does it need write access?

Maybe read-only access is enough.

  1. Does it need access to the whole system?

Probably not.

  1. Does the action require human approval?

If it can cause serious damage, consider ...Read More

  1. Are the actions logged?

If something goes wrong, you need visibility.

  1. Can the agent be isolated?

For coding agents and command execution, sandboxing can reduce the blast radius.

OWASP's current guidance for AI-agent security recommends least privilege, sandboxing/isolation where appropriate, monitoring, human oversight and ...Read More

The security mindset

When we talk about AI security, it's tempting to focus entirely on the model.

But secure AI is also about the architecture ...Read More

Model

↓

Application

↓

Authorization

↓

Tools

↓

Data

↓

External systems

Every connection creates another security boundary.

The model shouldn't be trusted with security decisions that the application can ...Read More

Final lesson

AI agents are becoming more capable.

That doesn't mean they should become more privileged.

In fact, the opposite may be true:

The more powerful the agent becomes, the more carefully we should control ...Read More

Build powerful agents.

Give them useful tools.

But don't give them every key.

What would you restrict first in an AI coding agent: file access, shell commands, API credentials, or network access?

ai #security #programming #devops #cybersecurity

Top comments (0)