Skip to content
Pwnversity
AUD-AMPLIFYintermediate · 12 min · upd. 2026-11

Auditing AWS Amplify and Cognito

AWS AmplifyCognitoAppSync

AWS Amplify is AWS’s kit for building the backend of a web or mobile app: authentication with Amazon Cognito, data with AppSync (GraphQL) and DynamoDB, files in S3, and hosting. In Amplify Gen 2 everything is defined in TypeScript under amplify/. On deploy, Amplify generates amplify_outputs.json, which the frontend loads and anyone can read:

  • the Cognito user pool, its client id and the identity pool;
  • the AppSync URL and, if there is public API key access, the API key itself.

As in Firebase, those values are not secrets. What protects the data is the authorization rules and the Cognito configuration, and both have defaults worth reviewing.

Amplify Gen 1 (the amplify CLI with schema.graphql) is in maintenance mode, with end of support announced for May 1, 2027. This card uses Gen 2 syntax.

AWS runs Cognito, AppSync, DynamoDB and S3. The customer decides:

  • which authorization rules each data model has;
  • whether the user pool allows open sign-up and which attributes users can change themselves;
  • whether the identity pool hands AWS credentials to visitors without a session, and with which IAM role;
  • what the backend uses to identify the user: sub or an editable attribute.
flowchart LR
    N["Browser<br/>amplify_outputs.json"] -->|"SignUp / login"| UP["Cognito user pool<br/>JWT tokens"]
    N -->|"no session"| IP["Cognito identity pool<br/>guest role"]
    N -->|"API key"| AS["AppSync<br/>allow.* rules"]
    UP -->|"token"| AS
    IP -->|"IAM credentials"| AS
    IP -->|"IAM credentials"| S3["S3 / other services"]
    AS --> D["DynamoDB"]

Each model carries its list of allow.* rules in amplify/data/resource.ts:

Rule Who gets access Mechanism
allow.publicApiKey() Anyone with the API key AppSync API key, published in amplify_outputs.json
allow.guest() Visitors without a session Identity pool guest role
allow.authenticated() Any signed-in user User pool (or OIDC / identity pool)
allow.owner() The owner of each record User pool; owner field on the record
allow.group("Admin") Members of a Cognito group User pool

Amplify’s own documentation describes publicApiKey as access for anyone holding the key, and recommends guest for public access in production. A model with allow.publicApiKey() without .to(["read"]) lets any visitor create, update and delete.

amplify/data/resource.ts
const schema = a.schema({
Order: a.model({ total: a.float(), status: a.string() })
.authorization((allow) => [allow.publicApiKey()]), // ❌ CRUD for anyone
Product: a.model({ name: a.string(), price: a.float() })
.authorization((allow) => [allow.publicApiKey().to(["read"]), // ✅ read-only catalog
allow.group("Admin")]),
Profile: a.model({ name: a.string() })
.authorization((allow) => [allow.owner()]), // ✅ each user, their own
});

Amplify’s documentation says it explicitly: Gen 2 enables guest access by default. The identity pool hands temporary AWS credentials to any visitor, with the guest IAM role. If the app doesn’t need it, turn it off in amplify/backend.ts:

const { cfnIdentityPool } = backend.auth.resources.cfnResources;
cfnIdentityPool.allowUnauthenticatedIdentities = false;

If it stays, review the guest role like any other IAM role (see cloud IAM): which buckets, tables or functions it can reach.

Cognito: open sign-up and writable attributes

Section titled “Cognito: open sign-up and writable attributes”

These are the most repeated Cognito flaws in audits and bug bounty programs:

  • Open sign-up. If AllowAdminCreateUserOnly is false, anyone with the client id (which is in amplify_outputs.json) can call SignUp directly against the Cognito API, even if the website has no sign-up form.
  • Writable attributes. With their own access token, users call UpdateUserAttributes. If the client’s WriteAttributes includes custom:role or a tenant identifier, users promote themselves. According to the AWS API model, if WriteAttributes is not set, the client can write the standard attributes (not the custom: ones). That includes email.
  • Unverified email. If email is not in AttributesRequireVerificationBeforeUpdate (Keep original attribute value active when an update is pending), the change takes effect before the new address is confirmed. If the backend identifies users by email instead of sub, changing the address to someone else’s may be enough to get into their account.

Both calls with the AWS CLI (documentation only; in an audit, always against the authorized environment):

Ventana de terminal
aws cognito-idp sign-up --client-id <client-id> --username test@example.test \
--password '<password>' --region <region>
aws cognito-idp update-user-attributes --access-token <access-token> --region <region> \
--user-attributes Name="custom:role",Value="admin"

The script walks an account’s user pools, their clients and the identity pools, and flags the issues above. It only reads: it uses describe_* and list_*.

import os, boto3
kw = dict(region_name=os.environ.get("AWS_REGION", "eu-west-1"))
if os.environ.get("ENDPOINT"): # lab only (moto)
kw.update(endpoint_url=os.environ["ENDPOINT"], aws_access_key_id="lab", aws_secret_access_key="lab")
idp = boto3.client("cognito-idp", **kw)
ci = boto3.client("cognito-identity", **kw)
for p in idp.list_user_pools(MaxResults=60)["UserPools"]:
up = idp.describe_user_pool(UserPoolId=p["Id"])["UserPool"]
print(f"== user pool {up['Name']} ({up['Id']})")
if not up.get("AdminCreateUserConfig", {}).get("AllowAdminCreateUserOnly", False):
print(" [!] open sign-up: anyone with the client id can call SignUp")
print(" MFA:", up.get("MfaConfiguration", "OFF"))
if "email" not in up.get("UserAttributeUpdateSettings", {}).get("AttributesRequireVerificationBeforeUpdate", []):
print(" [!] an email change takes effect before it is verified")
for c in idp.list_user_pool_clients(UserPoolId=up["Id"], MaxResults=60)["UserPoolClients"]:
cl = idp.describe_user_pool_client(UserPoolId=up["Id"], ClientId=c["ClientId"])["UserPoolClient"]
w = cl.get("WriteAttributes") # unset: standard attributes only
print(f" client {cl['ClientName']}: secret={'yes' if cl.get('ClientSecret') else 'no'}"
f" | flows={','.join(cl.get('ExplicitAuthFlows', []))}")
if w is None:
print(" [i] WriteAttributes unset: users can change standard attributes, email included")
else:
risky = [a for a in w if a.startswith("custom:") or a == "email"]
if risky:
print(f" [!] users can modify: {', '.join(risky)}")
for ip in ci.list_identity_pools(MaxResults=60)["IdentityPools"]:
d = ci.describe_identity_pool(IdentityPoolId=ip["IdentityPoolId"])
if d.get("AllowUnauthenticatedIdentities"):
print(f"== identity pool {d['IdentityPoolName']}: [!] unauthenticated identities allowed (guest role)")

Real output against an environment simulated with moto 5.2.5 (boto3 1.44.9). Pool A has open sign-up and a writable custom:role; pool B only allows admin-created users:

== user pool Pool A (eu-west-1_217cffdcc54746cda1141f783aceaf6e)
[!] open sign-up: anyone with the client id can call SignUp
MFA: OFF
[!] an email change takes effect before it is verified
client web: secret=no | flows=ALLOW_USER_PASSWORD_AUTH,ALLOW_REFRESH_TOKEN_AUTH
[!] users can modify: email, custom:role
== user pool Pool B (eu-west-1_9204979d0c6b45a1b28f44120eb641cb)
MFA: OPTIONAL
[!] an email change takes effect before it is verified
client web: secret=no | flows=ALLOW_USER_SRP_AUTH,ALLOW_REFRESH_TOKEN_AUTH
== identity pool amplify_guest: [!] unauthenticated identities allowed (guest role)
  • Download amplify_outputs.json (or look for aws_user_pools_web_client_id, aws_appsync_apiKey in the JavaScript of Gen 1 apps) and note the user pool, client id, identity pool and API key.
  • With the API key, request the AppSync schema if introspection is on and try write operations on each model.
  • Try SignUp with the client id even if the website offers no sign-up.
  • With your own account, read its attributes (get-user) and try to modify email and the custom:* ones.
  • Request guest credentials from the identity pool and check what the role allows.
  • Flickr (2021). Lauritz Holtmann reported on HackerOne an account takeover on Flickr using the Cognito API directly: with his own account’s access token he modified the email attribute and bypassed the restriction enforced by the website.
  • Writable tenant attribute. Securitum describes an audit where the attacker modified custom:m_id, the attribute linking the account to a merchant. After signing in again, they could access another merchant’s resources.
  • Amplify IAM roles assumable by anyone (CVE-2024-28056). Datadog Security Labs found in 2024 that IAM roles of Amplify projects became assumable by anyone in two cases: projects created with the CLI between July 2018 and August 2019, and projects whose authentication component had been removed with the CLI or Amplify Studio between August 2019 and January 2024. AWS released a CLI fix the same day it was notified.
  • Talks on Cognito. Yassine Aboukir presented at HITB 2023 a methodology to find these flaws: open sign-up, writable attributes and email changes before verification.
  • No model with allow.publicApiKey() without .to(["read"]); API key expiration reviewed
  • allow.authenticated() only if sign-up is closed or the data is fine for any user
  • Guest access off if unused; guest role with minimal permissions
  • AllowAdminCreateUserOnly on if the app has no public sign-up
  • Explicit WriteAttributes on every client, without role or tenant custom:* attributes
  • email in AttributesRequireVerificationBeforeUpdate
  • The backend identifies users by sub, never by email or editable attributes
  • MFA on; user pool threat protection if the plan includes it