Join our Newsletter — 33% off our NHI Course
Home› Guides› IAM Find the Flaw: Tokens, Conditional Access and…
Guide Identity & Access Management (IAM)

IAM Find the Flaw: Tokens, Conditional Access and Trust Policies

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 13 min read
On this page

Most identity misconfigurations look correct at a glance: the token is signed, the policy requires MFA, the role trusts a known identity provider, and the flaw sits in one missing line. These ten short exercises train the eye for that line. Each shows a fictional token validation rule, Conditional Access design or cloud trust policy, asks you to find the weakness, and then explains the flaw and the fix with the source that sets the rule. They cover JWT audience, issuer, algorithm and type checks, Conditional Access exclusions, and wildcard or over-broad principals in AWS, Google Cloud and Microsoft Azure federation. The page is for IAM and platform engineers, reviewers and learners; the protocol background is in the OAuth 2.0 and OpenID Connect Guide, which this page does not repeat.

Key takeaways

  • A valid signature is not a valid token. RFC 8725 requires the relying party to check that the signing keys belong to the issuer and that the audience is its own, and to reject the token otherwise.
  • Every Conditional Access exclusion is a hole. Microsoft limits its baseline MFA exclusions to emergency access, directory sync and service accounts, and any account excluded is not covered by the policy.
  • Federated trust needs a subject, not just an issuer. Public CI issuers such as GitHub serve every customer from one issuer URL, so a trust that checks only the issuer trusts strangers.
  • Wildcards belong in the narrowest field possible. AWS warns against a wildcard principal in role trust policies; Google Cloud requires an attribute condition for GitHub; Microsoft Entra federated credentials match subjects exactly.
  • Prefer immutable identifiers. Google Cloud recommends numeric GitHub owner and repository IDs over names, which can be re-registered.

How to use these exercises

Read each snippet and write down the flaw before opening the answer. Every snippet is fictional, uses placeholder domains and account numbers, and is deliberately short; real policies hide the same mistakes inside longer files. The cloud examples are listed alphabetically by provider (AWS, Google Cloud, Microsoft Azure), and order is not a ranking.

ExerciseAreaSkill testedDifficulty
1JWT validationAudience checkStarter
2JWT validationAlgorithm allowlistStarter
3JWT validationIssuer to key binding in multi-tenant appsIntermediate
4JWT validationToken type confusionIntermediate
5Conditional AccessExclusion sprawlStarter
6Conditional AccessService accounts and workload identitiesIntermediate
7Conditional AccessTrusted location bypassIntermediate
8AWS trust policyWildcard principal and broad subjectStarter
9Google Cloud workload identity federationAttribute condition and principalSet scopeIntermediate
10Microsoft Azure federated credentialSubject choice for productionIntermediate

For teams: run the set as a 45-minute review exercise, then take one real policy of each type from your own estate and review it the same way. Score the session by how many flaws each person found unaided, and track the real findings as tickets. For team leads, the useful measures are the share of reviewers who catch exercises 3, 6 and 9 (the least obvious), the number of real exclusions and wildcards removed after the session, and the time from finding to fix.

Exercises: tokens and claims

Exercise 1. An orders API accepts bearer tokens from the corporate identity provider, which also issues tokens for twenty other internal APIs.

1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.

Sample 1
validate(token):
  verify_signature(token, jwks_from("https://login.example.com/.well-known/jwks.json"))
  require token.iss == "https://login.example.com"
  require token.exp > now()
  accept

Exercise 2. A service validates tokens with a library call configured as follows.

Sample 1
decode(token,
       key = public_key,
       algorithms = token.header.alg)   # use whatever the token declares

Exercise 3. A multi-tenant SaaS app lets any customer organisation sign in through a shared identity platform endpoint whose signing keys are common to all tenants.

Sample 1
validate(token):
  verify_signature(token, jwks_from("https://idp.example.net/common/keys"))
  require token.aud == "api://saas-app"
  require token.exp > now()
  tenant = token.tid          # trusted for data access
  accept

Exercise 4. A mobile back end checks tokens like this. The same identity provider issues both ID tokens and access tokens for the app, signed with the same key.

Sample 1
validate(token):
  verify_signature(token, idp_keys)
  require token.iss == "https://login.example.com"
  require token.aud == "mobile-app-client-id"
  require token.exp > now()
  accept as API access

Exercises: conditional access

Exercise 5. A tenant's baseline policy, as documented by the identity team.

Sample 1
Policy: Require MFA for all users
  Users:      Include All users
              Exclude group "CA-Exclusions" (43 members: 2 break-glass,
                       1 sync account, 6 executives, 34 "app owners")
  Resources:  All resources
  Grant:      Require authentication strength: Multifactor authentication
  State:      On

Exercise 6. A design note on non-human accounts.

Sample 1
Service accounts are excluded from the MFA policy.
Service principals used by automation are covered because the
MFA policy targets All resources.

Exercise 7. An MFA policy with a network exception.

Sample 1
Network:  Include Any network or location
          Exclude All trusted networks and locations
Trusted named location "Corporate":
          head-office range, plus the full public egress range of the
          shared cloud region used by the company's VDI and partner VPN

Exercises: cloud trust policies

Exercise 8 (AWS). A deployment role in account 111122223333.

Sample 1
{
  "Version": "2012-10-17",
  "Statement": [
    { "Effect": "Allow",
      "Principal": { "AWS": "*" },
      "Action": "sts:AssumeRole" },
    { "Effect": "Allow",
      "Principal": { "Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com" },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
        "StringLike":   { "token.actions.githubusercontent.com:sub": "repo:example-org/*" } } }
  ]
}

Exercise 9 (Google Cloud). A workload identity pool provider for GitHub Actions and the binding that lets it impersonate a deployer service account.

Sample 1
Provider:  issuer https://token.actions.githubusercontent.com
           attribute mapping: google.subject=assertion.sub,
                              attribute.repository=assertion.repository
           attribute condition: assertion.repository.startsWith("example-org/")
Binding:   roles/iam.workloadIdentityUser on projects/PROJECT/serviceAccounts/deployer
           member principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/
                  locations/global/workloadIdentityPools/ci-pool/*

Exercise 10 (Microsoft Azure). A federated identity credential on the app registration that deploys to production.

Sample 1
{
  "name": "github-prod",
  "issuer": "https://token.actions.githubusercontent.com",
  "subject": "repo:example-org/payments-api:pull-request",
  "audiences": ["api://AzureADTokenExchange"]
}

Answers and explanations

ExerciseFlawFixRule source
1No audience checkRequire aud to equal the orders API identifierRFC 8725 s3.9; RFC 9700 s2.3; ASVS V9.2.3
2Algorithm taken from the tokenFixed allowlist per keyRFC 8725 s3.1, s3.2; ASVS V9.1.2
3Issuer and tenant not bound to the tokenValidate iss per tenant against an allowlist and bind tid to itRFC 8725 s3.8
4ID token accepted as access tokenSeparate audiences and explicit type checksRFC 8725 s3.11, s3.12; ASVS V9.2.2
5Exclusion group used as a bypass listExclude only break-glass and sync accounts; fix the restMicrosoft Learn baseline MFA policy
6Assumes user policies cover service principalsConditional Access for workload identities; managed identitiesMicrosoft Learn baseline MFA policy
7Trusted location covers shared egressTrust only addresses you exclusively controlMicrosoft Learn baseline MFA policy (network exception)
8Wildcard principal; org-wide subjectRemove the wildcard statement; pin the subjectAWS IAM principal and OIDC role docs
9Name-based condition; whole-pool bindingNumeric owner ID condition; bind a specific attribute setGoogle Cloud workload identity federation docs
10Pull request subject unlocks productionProtected environment subjectMicrosoft Learn federated credential docs

Token answers

  • Exercise 1: the API checks issuer, signature and expiry but not audience, so any token the corporate identity provider issued for any of the other twenty APIs is accepted here. RFC 8725 section 3.9 says the relying party "MUST validate the audience value" and must reject the token if the audience is missing or not its own. RFC 9700 section 2.3 adds that access tokens should be audience-restricted and that every resource server must check, on every request, that the token was meant for it. Fix: require token.aud == "api://orders". See the JWT Security Guide.
  • Exercise 2: the accepted algorithm comes from the token header, which the sender controls. RFC 8725 section 3.1 says libraries should let callers specify supported algorithms and reject all others, with each key bound to one algorithm, and section 3.2 limits none to tokens protected by other means. Fix: algorithms = ["RS256"] (or the one algorithm that key uses), configured in code, never read from the token.
  • Exercise 3: the common key set signs tokens for every tenant, so a valid signature proves only that some tenant's user signed in. The app then trusts tid for data access without checking that the issuer is an approved tenant. RFC 8725 section 3.8 requires the application to confirm the keys belong to the issuer in the token and to reject it otherwise. Fix: maintain an allowlist of onboarded tenant issuers, validate iss against it, check that tid matches the issuer, and map users to tenants server-side.
  • Exercise 4: the ID token's audience is the client ID, and so is the audience being checked, so an ID token (meant to tell the app who signed in) is accepted as API authorisation. RFC 8725 section 3.12 requires validation rules for different token kinds from one issuer to be mutually exclusive, using distinct typ, audience, claims or keys, and section 3.11 recommends explicit typing. Fix: issue access tokens for an API audience distinct from the client ID, and check token type (for example a typ header or a scope claim that only access tokens carry). See the JWT Validation Errors Troubleshooting Guide.

Conditional Access answers

  • Exercise 5: Microsoft's baseline "require MFA for all users" policy recommends excluding only emergency access accounts, directory synchronisation accounts and service accounts (with guests optional where a separate guest policy exists), and an excluded account is not covered by the policy. Executives and app owners are high-value targets, not exceptions. Fix: shrink the group to break-glass and sync accounts, alert on any membership change, and solve the app owners' underlying problem (often a legacy client or shared account). See the Break-Glass Account Guide.
  • Exercise 6: the same Microsoft page states that user-scoped Conditional Access policies do not block service principal calls; they need Conditional Access for workload identities. It also suggests replacing service accounts used by scripts with managed identities. Fix: inventory excluded service accounts, move them to managed identities or workload identities, and apply location or risk policies to those. See Conditional Access for Workload Identities.
  • Exercise 7: the network exception is a documented option, but this trusted location includes a shared cloud region's egress range, which other tenants of that cloud also use, plus a partner VPN. Anyone signing in from those addresses skips MFA. Fix: mark as trusted only address ranges your organisation exclusively controls, prefer device or authentication strength conditions to network ones, and review named locations in the same change process as policies. Test any change in report-only mode first, as Microsoft advises for new policies. See the Conditional Access Guide.

Trust policy answers

  • Exercise 8 (AWS): two flaws. The first statement lets any AWS principal call sts:AssumeRole; AWS documentation strongly recommends against a wildcard principal in role trust policies "because they allow other principals to become a principal in your account" and adds "Do not leave your role accessible to everyone!". The second statement allows every repository in the organisation, including test and personal-fork style repositories, to deploy. AWS recommends StringEquals with a specific sub wherever possible and keeping StringLike patterns as narrow as you can. Fix: delete the wildcard statement (or replace it with a named account principal plus conditions) and pin the subject, for example repo:example-org/payments-api:environment:production. See the AWS IAM Policies and Roles Guide and How to review AWS cross-account trust policies for confused deputy.
  • Exercise 9 (Google Cloud): Google Cloud requires an attribute condition restricting tokens to your GitHub organisation, because GitHub uses a single issuer for all organisations. This condition exists but relies on the repository name, and Google warns that name-based claims increase the chance of cybersquatting and typosquatting, recommending the numeric *_id claims, which cannot be reused. The binding also uses the /* principalSet, so every identity in the pool can impersonate the deployer. Fix: map and condition on assertion.repository_owner_id (and the ref where relevant), and bind roles/iam.workloadIdentityUser to a specific attribute. principalSet for the one repository that deploys. See the Google Cloud IAM and Service Accounts Guide.
  • Exercise 10 (Microsoft Azure): Microsoft Entra matches the issuer, subject and audience exactly, with one credential per branch or tag, which makes the subject the main control. The pull-request subject matches workflows running on pull requests, which typically run code that has not yet been reviewed, so it should not unlock a production deployer. Fix: use an environment subject such as repo:example-org/payments-api:environment:Production, protect that environment with required reviewers and deployment branch rules, and give pull request workflows a separate, read-only identity. See the Azure RBAC and Service Principals Guide and the GitHub Actions OIDC Federation Hardening Guide.

Detection and framework mapping

Each flaw has a matching signal: tokens accepted with an unexpected aud or typ (log both claims at the API gateway); Conditional Access exclusion group membership changes and sign-ins evaluated as "not applied"; AssumeRole or AssumeRoleWithWebIdentity events in AWS CloudTrail from unfamiliar accounts or subjects; Google Cloud STS token exchanges from unexpected subjects in Cloud Audit Logs; and Entra service principal sign-ins through federated credentials from unexpected subjects. Abuse of these flaws typically shows up as use of valid cloud accounts (ATT&CK T1078.004) or application access tokens (T1550.001).

FrameworkReferenceExercises
OWASP ASVS 5.0V9.1.1, V9.1.2, V9.2.2, V9.2.3, V10.3.11 to 4
NIST SP 800-53 Rev. 5IA-2, AC-31 to 7
NIST SP 800-53 Rev. 5AC-6 Least Privilege5, 8, 9, 10
NIST CSF 2.0PR.AA-01, PR.AA-05All
MITRE ATT&CKT1078.004 Cloud Accounts; T1550.001 Application Access Token3, 4, 8 to 10

Practitioner checklist

  • Check every API's token validation for issuer, audience, algorithm allowlist, expiry and token type, in code review and in automated tests that present wrong-audience and wrong-type tokens.
  • In multi-tenant apps, validate the issuer against an allowlist of onboarded tenants and bind tenant IDs server-side.
  • List every Conditional Access exclusion, its owner and reason; keep only break-glass and sync accounts in baseline exclusions and alert on changes.
  • Cover service principals with Conditional Access for workload identities or move them to managed identities.
  • Mark as trusted only network ranges you exclusively control, and test policy changes in report-only mode.
  • Search role trust policies for "AWS": "*" and for StringLike subjects ending in /*.
  • Require attribute conditions on immutable numeric IDs in Google Cloud workload identity providers and avoid whole-pool principalSet bindings.
  • Use protected environment subjects for production federated credentials and separate identities for pull request workflows.

Standards and references

Related NHI Mgmt Group resources: OAuth 2.0 and OpenID Connect Guide · OAuth 2.0 Security Best Current Practice (RFC 9700) Guide · JWT Security Guide · Cross-cloud workload identity federation

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.