OIDC Aud Claim

Published
Length
3 min read

Luis Felipe Dias

All posts

The oidc aud claim tells a target app that an identity token is meant for it. Your app must check this value before it lets a user or service log in. Teams often set up one shared client ID for many internal tools at once. This broad setup makes token reuse easy across tools that need separate rules. When a token works everywhere, one weak app puts your whole system at risk. A leaked token from a test tool can open doors to production data. How the oidc aud claim works in login flows OpenID C

K8s OIDC Authentication: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

The oidc aud claim tells a target app that an identity token is meant for it. Your app must check this value before it lets a user or service log in. Teams often set up one shared client ID for many internal tools at once. This broad setup makes token reuse easy across tools that need separate rules. When a token works everywhere, one weak app puts your whole system at risk. A leaked token from a test tool can open doors to production data.

How the oidc aud claim works in login flows

OpenID Connect uses JSON Web Tokens to prove who a user is during login. When a user logs in, the identity provider creates and signs an ID token. This token holds several fields called claims that describe the login event. The audience field holds one identifier or a short list of identifiers. Each identifier matches a specific app or API that should accept the token.

When the token arrives, your app reads the signature and checks the claims. Your app compares the token audience against its own unique client identifier. If the values match, the app trusts that the token belongs there. If the values do not match, the app rejects the login attempt right away. This simple check stops an attacker from taking a token to a different app. Without this check, a token meant for a read-only app could manage admin tools.

Setting up audience checks across internal tools

Platform teams must register each internal app with their main identity provider first. The identity provider gives each registered app a unique client identifier string. When a user asks to log in, the app sends this string along. The identity provider stamps that exact string into the audience field of the token.

Some teams group multiple backend services under one single audience value to save time. This shortcut creates a wide blast radius if one service has a flaw. Good security requires unique audience values for databases, clusters, and internal admin apps. Teams must also check that every backend tool validates the audience field on every login. Skipping this step leaves the door open to confused deputy attacks across your network.

K8s OIDC Authentication: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What audience validation solves and what it misses

Checking the audience field proves that a token reached the right target service. It pairs with issuer and expiration checks to build a strong login gate. These checks stop bad tokens before a user session can even start. They also help teams map which identity provider groups can reach which apps.

Still, the audience check only happens at the start of a user session. It decides who can log in, not what commands they run after that. Once a developer or automated agent passes the check, the token work ends. The app then trusts the session based on the broad role assigned at login. Native token checks cannot see individual SQL queries or shell commands in flight. They cannot stop a valid user from dropping a table by mistake. They also cannot rewrite sensitive fields like emails or card numbers in query results. Teams still need a way to control and log actions after login succeeds.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can an OIDC token have more than one audience value?

Yes, the audience field can hold a single string or a list of strings. If it holds a list, the token must also include an authorized party claim. Each receiving app must still check that its own identifier is in that list.

What happens if an app skips the audience check?

An attacker can take a valid token from another app that uses the same provider. They can send that token to your app and log in as that user. Always check the audience value on your backend server to block this attack.

Is the audience claim the same in OIDC and OAuth2?

Both standards use the same claim name, but the target is different. In an OIDC ID token, the audience is the client app that asked for login. In an OAuth2 token, the audience is usually the backend API that holds data.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.