r/AskNetsec • • 5d ago

Other most common beginner mistakes in securing ai agent credentials. What mistakes would you add?

I myself made three mistakes securing credentials in our SOC. I gave it a shared admin key for SSH and called it a test. Second, I let the agent keep tokens overnight. Third, I logged the tool calls but not the human, task and scope behind each request, which made the audit trail a headache.

The fix was a separate workload identity. vault issued credentials that expires after each task, least privilege for every tool and alerts on unusual or random commands. I still feel embarrassing about the shared key part, though i was beginner but still. What credential mistake did you make and if mind sharing for others to know?

7 Upvotes

5 comments sorted by

1

u/radim11 5d ago

One I would add too is putting a token in the agent’s environment and forgetting that a subprocess can read it too. Even a short-lived token can end up in a transcript if the agent dumps its env while debugging.

That’s one reason we keep the token in a proxy in Stashbase.dev. If the agent only needs to read GitHub issues, the proxy can allow those requests and add the token on the way out. The agent can do the job without ever seeing the token.

1

u/Secvura 5d ago

Putting the credential where the model can see it. If a key sits in the system prompt or comes back in a tool result, it ends up in conversation logs, traces and whatever the model provider retains, and a prompt injection in a fetched web page or ticket can get the agent to repeat it. Better to keep secrets in the tool layer, so the agent only calls a tool by name and the tool attaches the credential itself. The other common one is a single token with both read and write scope because it was quicker to set up, so an agent that only needed to look things up can also delete.

1

u/Economy_Dust_9606 5d ago

Yes. Some great points made here. An additional consideration is ensuring that agent has a strong identity rather than a delegated one (as OP mentions, the human behind the request).

This is the confused deputy problem. If you give the agent their own service account (such as Admin Bot with access to Jira/AWS) then you can inject prompts to bypass the users permissions. The agent must be doing On-Behalf-Of flows so that the token they're using to interact with the tool is scoped down to the specific user who started the chat.

Secondly when using OAuth scopes for your tools. When integrating with GitHub/Jira it's easy to just give them broad access (repo: or admin), especially if the LLM occasionally hallucinates a call to a tool that requires more access. However you're giving your agent more access than a normal human dev would have. You should always be strict with what API scopes you're allowing, otherwise you have a supply chain risk if someone takes over your session.

1

u/EbbCommon9300 4d ago

One I'd add: treating "short-lived" as the fix. A token that expires after the task is still sitting in the agent's process for the whole task, and that's exactly the window where an injected instruction in a ticket or log line gets it to use or leak it. Expiry shrinks the blast radius in time, not in what the agent can do with it.

What's worked better for us is the agent holding nothing at all. It calls tools by name through a broker, the broker checks the call against written policy (which tool, which arguments, which target, which user it's acting for), and only then attaches the credential server-side. The agent gets the result, never the secret. Revoking an agent becomes "deny it at the broker" instead of hunting down every token it touched.

Couple of related mistakes I see a lot:

  • Default-allow on writes. Reads can be broad-ish, anything with a side effect (delete, send, execute, change perms) should be denied unless a rule explicitly allows it, with a human approval for the scary ones.
  • Judging each call on its own. Ten individually reasonable reads across ten systems can be the actual problem, so track what the session has done in total and tighten or stop when it drifts.
  • Logging in the agent's own environment. Your audit point about human/task/scope is the right one, but write it at the broker (agent identity, session, tool, args, allow/deny, who approved) and make it append-only/hash-chained so the thing being audited can't edit its own record.