← AWS Security Specialty: evidence-based security
21 / 25 · 110 MIN

Application identity and authorization

Follow identity from login to an authorized operation, including tokens, caching, and permissions evidence.

1. Choose the right identity

In a fictional operations portal, separate three needs: authenticating a person, obtaining credentials for AWS services, and authorizing an application action. A Cognito user pool supplies the directory and OIDC tokens; an identity pool can supply temporary AWS credentials associated with roles.

Do not introduce AWS credentials into the browser if the design only requires calling your API with a token. For a batch without human interaction using the token endpoint, consider client credentials and custom scopes with a protected secret.

That flow represents the machine, not an operator. Project inventory should identify who issues each credential, where it is validated, who manages its lifetime, and which operations it permits. Answering these questions avoids treating all tokens as equivalent.

2. Interpret claims in the correct context

An identity-pool role needs to restrict origin through aud. In that context, aud is the identity pool ID; amr distinguishes authenticated from unauthenticated and sub identifies that pool identity. The original user-pool sub is not interchangeable.

A guest role with private writes remains dangerous even with short sessions. For user-pool JWTs, verify signatures before trusting groups and other claims. Check issuer, recipient, validity, and token_use according to the contract.

In ID tokens, aud identifies the app client; in access tokens without resource binding, check client_id. Keep a fictional example of each context in the runbook and clearly identify which verifier processes it. Trust workshop: use fictional aliases P for the pool and I9 for Ana’s identity; the IdP identifies her as U7.

Evaluate T1=(P, authenticated, I9), T2=(P, unauthenticated, G2) and T3=(Q, authenticated, I9) against aud=P, amr containing authenticated and sub=I9. Answer: only T1 satisfies all three conditions. Correcting U7 to I9 does not require removing aud or amr.

Add a fourth request from another authenticated person in P: it must fail sub. These aliases are not valid IDs to copy into an AWS policy.

3. Handle rotation and revocation

Decoding a JWT reveals content but does not establish integrity. Use a suitable verification library and keys obtained from the trusted source. An unfamiliar kid can reflect legitimate rotation: refresh the expected pool JWKS cache and verify again without accepting the token merely because issuer text looks correct.

A valid signature and future expiration also do not independently detect later revocation. Define the access-cutoff deadline and the mechanism supporting it; do not promise immediate cutoff with exclusively offline checks. For authorization code with PKCE, preserve the original verifier until code exchange.

Generating another verifier then breaks its relationship with the submitted challenge. Never use real tokens in shared incident-meeting examples. Timeline workshop: an API requires cutoff within 120 s.

In the proposed model, revocation reaches all replicas within 30 s, but a stale replica can create an Allow with another 60 s of cache. Calculate the worst bound: 30+60=90 s, leaving 30 s margin. If TTL rises to 120 s, the bound becomes 150 s and fails.

These numbers are fictional trial assumptions, not a Cognito SLA. Measure actual propagation, test warm caches and define denial when state cannot be verified. Planned-rotation variant: both signing keys are published at 12:00.

Policy requires two hours of overlap and retaining old tokens valid until 14:30. The minimum deadline is max(14:00,14:30)=14:30. A new-key canary at 12:05 demonstrates only that path, not every cache.

Distinguish overlap guidance for caching, documented as up to two hours on a best-effort basis, from the additional token-validity requirement imposed by the plan.

4. Express the API rule

In an HTTP API JWT authorizer, aud takes precedence over client_id when both exist. That authorizer does not universally distinguish ID from access tokens; appropriate scopes or exclusive issuer/audience values help express the contract. An authorizationScopes list accepts at least one listed scope rather than requiring all of them.

If a release rule requires two simultaneous conditions, that list is insufficient. Do not infer permissions from GET and POST names without configuration. For IdP key rotation, account for API Gateway public-key caching and a validity overlap.

Rehearse tokens with the wrong recipient, insufficient scope, and wrong purpose alongside the permitted case. Negative testing demonstrates the restriction the sponsor actually approved. Scope workshop: R has only read, W only write and RW both; signature, recipient and dates are correct.

With both scopes in the route list, all pass. If business rules require both, enforce that conjunction before the operation and demonstrate R/W denied and RW allowed. Reversing list order does not change the result.

Also vary recipient: a token with matching client_id but wrong aud fails audience even with all scopes. A lone positive trial does not distinguish these defects. Route matrix: T1 is an ID token without scopes, T2 an access token with payments/read and T3 an access token with read/write; all pass cryptographic and time checks.

Require read on GET and write on POST: T1 fails both, T2 only passes GET and T3 passes both. Listing read/write as POST alternatives would improperly admit T2. The result depends on this issuer contract, not a universal rule classifying every JWT.

5. Scope cached decisions

An HTTP API Lambda authorizer can reuse results through identity sources. With simple responses, a cached boolean applies to requests matching the same key. If reading and release require different rules, add routeKey to the key and evaluate the route, or use a suitable granular policy.

Reducing TTL limits failure duration but does not repair inappropriate sharing across routes. A missing required header produces 401 before invocation; a 500 with an invocation-permission error points to authorizer integration. The exercise below demonstrates collisions in a fictional cache; it neither validates JWTs nor implements a production-ready authorizer.

For revocation, also consider how long an old decision can continue being reused. Acceptance workshop: release Allow created at 10:00 has TTL 300 s. Permission is removed at 10:00:30, with cutoff required within 60 s.

Without invalidation or another control, Allow can last until 10:05: 270 s after removal and 210 s past the deadline. Adding routeKey fixes cross-route sharing but not this window. The seconds-based model below exposes both defects and exact expiration.

It models neither distributed propagation, network latency nor the AWS service. Diagnosis: A omits Authorization and receives 401 without invocation; B sends the header but receives 500 with an invocation-permission error; C reaches the function and has a recorded Deny.

Repair A’s request, B’s integration and investigate C’s authorization without inferring one cause from codes. For revocation, a 10:00 Allow expires at 10:05; the table changed at 10:01 and cutoff is due at 10:02. Deny at 10:01:20 with another key does not prove the original client’s cutoff.

The residual window is four minutes, three beyond deadline: demonstrate cutoff on the warm path with the same identity source.

6. Reduce permissions with sufficient evidence

Absence from a report does not always mean the same thing. Unused access follows a configured window and permission age; a recent permission may not yet be evaluated. Service last accessed includes denied attempts, and action last accessed does not cover data-plane events.

To conclude that reading occurred, find relevant events and their outcomes. To remove access, combine observation with actual cycles, including quarterly closing and incident recovery. A policy generated from CloudTrail has limits too: iam:PassRole is not included.

Treat it as a candidate for review and rehearsal. A reduction plan should identify each exception owner, the basis for its dependency, and when that justification will be reassessed. Reduction workshop: A is GetObject on close/, outside action last accessed and needed for closing outside the observed 30 days.

B is 12 days old in an analyzer with a 90-day window. C was removed with owner confirmation, successful representative rehearsal and denial of C. Answer: proceed with C under change control; for A/B confirm dependencies, time-limit exceptions and obtain missing trials.

Do not retain C merely because A/B still need investigation, or interpret no finding for B as evidence of use. Permission triage: with a 90-day window, A is twelve days old without a finding, B is 120 days old with an unused finding and C is 120 days old with a required operation yesterday.

A is not old enough; B needs owner review and rehearsal; C does not become dispensable through rarity. For policies, retaining GetObject but widening reports/team-a/* to reports/* and removing E1 expands two dimensions. Compare exact documents with CheckNoNewAccess and retain the result when run; fixing only the prefix or only E1 leaves another expansion.

Local semantic analysis alone does not demonstrate effective environment access.

7. Hand over a demonstrable control

ValidatePolicy helps find grammar and best-practice issues. CheckNoNewAccess compares a proposed policy with a reference to look for additional access. Neither replaces every functional test in the context of actual policies and conditions.

A usage-plan API key also does not replace authentication and authorization; quotas are best effort rather than a hard cost guarantee. In the APS summary, connect each requirement to proof: login, permitted operation, denied operation, behavior after permissions change, and error diagnosis.

Retain records without secrets and identify IdP, gateway, and application owners. This lesson produces authorization bounded by identity, operation, and time, with evidence that restrictions remain valid when caches or keys change. Acceptance variant: A must read the approved prefix through E1; B uses another prefix and C operates outside E1, so both must fail.

ValidatePolicy passes, but A is denied by SCP and B/C remain untested. Address the SCP exception within approved scope and repeat the entire matrix with final policies. A control denying everything does not establish authorized operation; removing the whole SCP to make A pass can remove restrictions outside the change.

# Original fictional cache-key model, not a JWT verifier or AWS authorizer.
# No credentials, network calls, or AWS changes.
def key(identity, route, per_route):
    return (identity, route) if per_route else (identity,)
def allowed(route):
    return route == "GET /status"
cache = {key("demo-user", "GET /status", False): True}
assert cache[key("demo-user", "POST /release", False)] is True
scoped = {key("demo-user", "GET /status", True): True}
assert key("demo-user", "POST /release", True) not in scoped
assert allowed("GET /status") is True
assert allowed("POST /release") is False
assert key("other-user", "GET /status", True) not in scoped
print("five cache-scope cases passed; no token was verified")

# Extension: fictional session labels, already-validated identity assumed.
# TTL is a model input, not an AWS latency or revocation guarantee.
import math

def decide(label, route, now, ttl, permissions, cache, per_route=True):
    if not isinstance(label, str) or not label.strip():
        return False
    if not isinstance(route, str) or not route.strip():
        raise ValueError("route is required")
    if type(per_route) is not bool:
        raise ValueError("per_route must be boolean")
    if any(type(v) not in (int, float) or not math.isfinite(v) or v < 0
           for v in (now, ttl)):
        raise ValueError("finite nonnegative time and TTL required")
    if not isinstance(permissions, dict) or any(type(v) is not bool for v in permissions.values()):
        raise ValueError("permission decisions must be boolean")
    cache_key = key(label, route, per_route)
    if cache_key in cache:
        created, expiry, result = cache[cache_key]
        if now < created:
            raise ValueError("clock moved backwards")
        if now < expiry:
            return result
    result = permissions.get((label, route), False)
    cache[cache_key] = (now, now + ttl, result)
    return result

reader = {("reader", "GET /status"): True}
unsafe = {}
assert decide("reader", "GET /status", 0, 300, reader, unsafe, False)
assert decide("reader", "POST /release", 1, 300, reader, unsafe, False)
scoped_cache = {}
assert not decide("reader", "POST /release", 0, 300, reader, scoped_cache)
assert decide("reader", "GET /status", 1, 300, reader, scoped_cache)
release_cache = {}
assert decide("releaser", "POST /release", 0, 300,
              {("releaser", "POST /release"): True}, release_cache)
assert decide("releaser", "POST /release", 90, 300, {}, release_cache)
assert not decide("releaser", "POST /release", 300, 300, {}, release_cache)
assert not decide("", "GET /status", 1, 300, reader, scoped_cache)
print("route separation and revocation are separate acceptance checks; fictional inputs only")
IN PRACTICE

A read fills the cache and incorrectly permits a release. Per-route rehearsal reveals the difference between valid login and authorized operation.

Common pitfalls

aud out of context; decoding as verification; scopes as AND; missing tracking as proven disuse.

Related topics: Identity and data · Acceptance and continuity

Take this idea with you

Authenticate identity and demonstrate operation authorization in the intended context and period.

Create account

References

AWS is a trademark of Amazon.com, Inc. or its affiliates. bigsavant.com is an independent preparation platform and is not affiliated with, associated with, sponsored, authorised or endorsed by AWS. Content and questions are original, are not official exam questions, and completing our tests does not award or guarantee any certification. Names are used only to identify the subject. All other trademarks belong to their respective owners.