This article discusses the "Confused Deputy" architectural flaw prevalent in enterprise agent deployments, particularly with AI agents. It highlights how agents, granted broad access, can inadvertently over-share sensitive data if authorization is solely dependent on prompt engineering. The solution proposed is to implement identity propagation using OAuth 2.0 on-behalf-of flow (RFC 8693), where the agent borrows the user's authority for each tool call, ensuring downstream systems enforce authorization against the actual user's identity and permissions.
Read original on Dev.to #architectureThe "Confused Deputy" is a security vulnerability where a legitimate program (the "deputy") with excessive privileges is tricked by a less privileged entity into misusing its authority, often to access or manipulate resources it shouldn't. In the context of AI agents, this typically occurs when an agent is granted a broad service principal with wide read/write access to backend systems (e.g., an HR system). When a user requests sensitive information, the agent, acting on its extensive permissions, might retrieve and expose data that the requesting user themselves is not authorized to see, simply because the agent's credentials allow it.
The Danger of Over-privileged Agents
Relying on an AI model to "decide not to" over-share data effectively turns an authorization problem into a prompt-engineering problem. This is a critical architectural flaw because attackers can influence prompt engineering, bypassing intended security controls. The agent should *never* hold a credential that could allow it to over-share in the first place.
This mechanism ensures that the agent cannot over-share because it never possesses a credential that grants it more access than the requesting user. Authorization responsibility shifts from the agent to the data-owning service, which already has robust authorization capabilities. This directly addresses OWASP ASI03 (Identity and Privilege Abuse) and ASI07 (Privilege Escalation across agents in multi-agent systems).
While effective, this pattern introduces trade-offs. It adds latency due to the token exchange per tool call and creates a hard dependency on the IdP. Caching can mitigate latency, but careful invalidation is needed for revocation. Additionally, long-running agent sessions might outlive their tokens, requiring re-authentication or token refreshing, which could expose changes in user entitlements. It is also crucial to leverage existing IdP solutions (e.g., Entra ID, Okta, Auth0) for token exchange rather than implementing a custom solution, which is prone to security vulnerabilities.