Cloud concept · Updated

Token Validation - Token validation is the process of checking that a presented security token is authentic, acceptable for its intended recipient and purpose, and valid at the time of use.

In short

Cloud applications and identity systems validate tokens before trusting the identities or claims they contain. Correct validation prevents forged, expired, misdirected, or inappropriate tokens from being accepted, while separating authentication failures from authorization problems.

Cloud Concepts Hub →

6 key aspects of Token Validation

Reliable token validation combines trusted cryptography, recipient and purpose checks, lifetime enforcement, format-aware processing, and diagnostics that distinguish authentication from authorization.

01
Trusted issuer and cryptographic integrity

Verify signatures with trusted keys and explicitly allowed algorithms before trusting token claims. Configure issuer trust independently of the token and handle signing-key rotation through controlled key retrieval and caching.

02
Recipient and purpose binding

Check that the token targets the expected recipient or application client and is the correct token type for the operation. A valid signature does not make an ID token an acceptable API access token.

03
Lifetime and revocation handling

Enforce expiration and applicable not-before constraints with a bounded clock-skew allowance. Understand whether the validation method checks current revocation state or simply accepts an otherwise valid token until expiration.

04
Format-specific validation

Use validation mechanisms appropriate to JWTs, opaque tokens, SAML assertions, Kerberos tickets, or temporary cloud credentials. Do not attempt to decode an AWS session token as a JWT or treat it as a standalone bearer credential.

05
Authentication and authorization separation

First establish whether the credential is acceptable, then evaluate scopes, roles, policies, and resource permissions. Successful sign-in does not establish that an IAM Identity Center permission set grants the requested action.

06
Boundary-focused diagnostics

Correlate issuer, gateway, application, directory, and audit evidence to locate where authentication fails. Record safe metadata and error categories without exposing reusable tokens or secrets.

Cloud services for Token Validation

Amazon Cognito can issue application tokens that Amazon API Gateway validates before forwarding requests to a backend. AWS STS handles supported federation exchanges into temporary AWS credentials, while IAM Identity Center supports workforce access and permission-set-based account access. AWS Directory Service may supply the underlying directory authentication, making directory health relevant when sessions cannot be established. CloudTrail provides evidence for supported identity and API activity; gateway and application logs fill other diagnostic gaps. Together, these services help engineers separate issuance failures, token rejection, expired credentials, and authorization denials without assuming that every access failure has the same cause.

Amazon CognitoAmazon Cognito

Amazon Cognito user pools issue ID and access tokens that applications must validate before trusting their claims. Troubleshooting includes checking the user pool issuer, signing key, token_use, expiration, and token-specific audience or client binding.

Amazon API GatewayAmazon API Gateway

HTTP API JWT authorizers validate JWTs against configured issuers and audiences and can enforce route authorization scopes. Gateway access logs help distinguish authorizer rejection from errors returned by the backend integration.

AWS Directory ServiceAWS Directory Service

AWS Directory Service can provide or connect to the directory used in an authentication path. Account state, DNS, connectivity, trust, and clock synchronization can affect authentication before downstream tokens or sessions are issued.

AWS CloudTrailAWS CloudTrail

CloudTrail records supported AWS API and identity events that help trace federation, credential issuance, and subsequent credential use. It supports investigation rather than performing token validation, and it does not capture every rejected token or application authentication attempt.

Token Validation exam questions

Real practice exam questions on Token Validation, with the correct answer and its explanation. Answer them with every option in the exam simulator.

DVA-C02

A company uses an Amazon API Gateway REST API with a Lambda authorizer. Clients send JWT bearer access tokens issued by an external identity provider. The authorizer reads the token's jku header, downloads the signing keys from that URL, and verifies the signature, issuer, audience, expiration, and required scope. A security review finds that an attacker can create a token with the expected claims and have it accepted by hosting a signing key at an attacker-controlled URL. The identity provider routinely rotates its signing keys. Which change should the developer make to prevent this attack while continuing to support key rotation?

Show answerCORRECT ANSWER

Configure the authorizer with the identity provider's trusted JWKS endpoint instead of using the token's jku URL. Select the verification key by kid, refresh cached keys when an unfamiliar kid is encountered, and enforce an allowed signing algorithm along with the existing claim checks.

The verification keys must come from a configured, trusted source rather than a location selected by the token presenter. Using the trusted provider's JWKS endpoint and refreshing keys for an unfamiliar key ID supports signing-key rotation. Algorithm restrictions and the existing claim checks remain necessary.

SAP-C03

A company uses an Amazon Cognito user pool to authenticate users of a distributed application. Multiple backend services independently validate JWT access tokens. Each service currently has one public signing key embedded in its deployment package. A signing-key rotation caused authentication failures until all services were redeployed.

The company requires signing-key rotation to work without redeployment. When a service encounters a token with an unfamiliar signing-key identifier, it must attempt to obtain the matching key from the trusted endpoint before rejecting the request. If that key is available and the token passes validation, the service must accept that same request rather than wait for a scheduled refresh. During brief endpoint outages, services must continue accepting otherwise valid tokens whose keys are already in an unexpired local cache. Tokens without a trusted matching key must be rejected. Requests with cached keys must not require a network call to the identity provider.

All proposed solutions enforce RS256 and validate the configured issuer, expiration, token_use, allowed client_id, and required scopes. The company permits a bounded local signing-key cache.

Which signing-key management strategy meets these requirements?

Show answerCORRECT ANSWER

Cache keys from the configured user pool's JWKS endpoint and select them by kid. Refresh periodically and attempt a rate-limited refresh on an unknown kid before deciding the request. Accept the request if the retrieved key establishes a valid signature and all claims pass validation. Use unexpired cached keys during endpoint outages, and reject tokens if a trusted matching key remains unavailable.

The configured user pool's JWKS endpoint provides the trusted signing keys, and kid identifies the appropriate key. Refreshing on a cache miss allows the same request to succeed after rotation when the matching key is available. Cached keys avoid network calls for normal requests and support brief outages. Rejecting tokens without a trusted matching key preserves fail-closed behavior, while rate limiting reduces abuse of the refresh path.

SCS-C03

A company uses one Amazon Cognito user pool for two applications: a customer portal and an internal support application. Each application has a separate app client. Some employees have access to both applications through the same user-pool identity.

The customer portal API must accept access tokens issued only to the portal app client. During testing, a security engineer discovers that the API also accepts access tokens issued to the support app client. The API's custom validator verifies the JWT signature against the configured user pool's JWKS and checks issuer, expiration, token_use, and the required portal/read scope.

The engineer confirms that tokens from both clients have the same issuer and can contain portal/read. The tested access tokens contain client_id but no aud claim. Legitimate portal clients must continue using their existing access tokens without changes to the sign-in flow or scope configuration.

Which change should the engineer make to enforce the API's app-client restriction?

Show answerCORRECT ANSWER

Require the verified token's client_id claim to equal the portal app client ID, while retaining signature, issuer, expiration, token_use, and scope validation.

For Cognito user-pool access tokens, client_id identifies the app client that obtained the token. Checking this signed claim against the API's explicitly allowed client ID rejects support-client tokens while preserving existing legitimate portal access tokens. Signature, token-purpose, lifetime, issuer, and scope checks remain necessary.

Practice Token Validation in a full exam

Questions on Token Validation in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Token Validation

3 min read

Token validation establishes whether a security token can be trusted in a particular request context. Tokens can represent a user, workload, delegated permission, or authenticated session. They include signed JSON Web Tokens (JWTs), opaque access tokens, SAML assertions, and Kerberos tickets. These formats require different validation mechanisms, but the underlying questions are consistent: who issued the token, has it been altered, is it still valid, and was it intended for this recipient and purpose?

For a signed JWT, decoding the header and payload is not validation. A resource server must verify the signature using a trusted issuer's key and an explicitly permitted algorithm. It must also check the expected issuer, intended audience or client binding as defined by the token type, expiration, and applicable not-before restrictions. A small, bounded allowance for clock skew can accommodate normal timing differences. The validator should obtain signing keys from a configured, trusted location rather than following arbitrary key URLs supplied in an untrusted token.

Token purpose matters as much as cryptographic integrity. An OpenID Connect ID token describes an authentication event for a client; an OAuth access token is intended for access to protected resources. An API should not accept an ID token merely because its signature is valid. With Amazon Cognito user pools, validators should check the token_use claim and apply the appropriate client-binding checks: ID tokens contain aud, while access tokens identify the application client through client_id. Required API scopes must also be enforced.

Validation can be local or involve an authorization server. Local signature verification reduces latency and avoids a network dependency on every request, but a token may remain acceptable until expiration unless the application implements additional revocation or session-state checks. Opaque tokens generally require a server-side lookup or supported introspection mechanism. Short token lifetimes reduce the exposure from stolen credentials but increase refresh traffic and dependence on the identity system. Signing-key caches must accommodate key rotation without accepting untrusted keys.

Troubleshooting should follow the authentication path rather than treating every denied request as an invalid token. Check whether credentials were issued successfully, whether the client sent the correct token, and whether the receiving service rejected its signature, issuer, audience, purpose, or time limits. For example, a token from a development user pool should fail against an API configured to trust the production pool. A newly rotated signing key can also cause failures when a validator's key cache is stale.

A valid token does not guarantee authorization. A workforce user can authenticate successfully through IAM Identity Center yet lack an AWS account assignment or the permissions granted by a provisioned permission set. Similarly, AWS temporary security credentials include an access key, secret key, and session token; they are not JWTs. Requests must use the matching credential set and request signing, and failures can result from an expired session, an omitted session token, or credentials mixed across sessions.

Use AWS CloudTrail to investigate supported identity and API events, including relevant federation and credential-issuance activity. Correlate event times, identities, request identifiers, and error details with application or gateway logs. CloudTrail is not a universal token-validation log, and a request rejected before a recorded service operation might not produce the event an engineer expects. Never log complete bearer tokens or secret keys when collecting diagnostic evidence.

Directory-backed authentication adds another layer. When AWS Directory Service supports the identity path, investigate account status, directory connectivity, DNS, trust relationships, and time synchronization. Kerberos ticket processing is not JWT validation, and a directory sign-in failure can prevent token or session issuance altogether. Identifying the failing boundary avoids changing API validation rules to compensate for an unrelated directory or authorization problem.

Learn Token Validation in lessons

2 short lessons on Token Validation in 2 certification courses.

Open the lessons