Auth0Carla Urrea StabileExplainer
Auth0 Metadata Explained: user_metadata vs app_metadata
Summary
Auth0’s user_metadata and app_metadata define a security boundary: user_metadata is writable by users through the update:current_user_metadata scope, while app_metadata requires privileged scopes available only to confidential clients via the client credentials grant. Post-login Actions reading authorization data like subscription plans or feature flags from user_metadata allow users to escalate privileges by modifying their own metadata, for example setting plan to enterprise and beta_access to true. Writing to app_metadata demands a server-side M2M application with update:users_app_metadata scope, which no public client or user token can obtain. The correct practice is to store access-control data such as roles, tenant membership, and IP allowlists in app_metadata, and non-sensitive preferences like theme or language in user_metadata. A third field, client_metadata, holds application-level properties readable via event.client.metadata in Actions.
Takeaways
user_metadata can be modified by users via the update:current_user_metadata scope obtained by public clients; app_metadata cannot, as its write scopes (update:users, update:users_app_metadata) require the client credentials grant reserved for confidential clients.
Storing authorization data such as subscription plans, feature flags, or IP allowlists in user_metadata enables privilege escalation because users can update their own metadata without server-side approval.
The correct architecture places access-control data in app_metadata, updated only by server-side M2M applications, and non-sensitive user preferences in user_metadata for user self-service.
FAQ
How can users modify their own metadata?
Users obtain a Management API token with the update:current_user_metadata scope, which Auth0 grants to public clients like SPAs or mobile apps. They then send a PATCH request to the /api/v2/users/{user_id} endpoint with new user_metadata values.
Why shouldn't I store plan or feature flags in user_metadata?
Because user_metadata is writable by users. A user can change their plan to 'enterprise' or enable beta_access themselves, and if your post-login Action reads from user_metadata, the access token will include those elevated claims.
How do I update app_metadata from my backend?
Use a ManagementClient with client credentials from a server-side M2M application. The call requires the update:users or update:users_app_metadata scope, which is only available through the client credentials grant, not from user tokens.
Source and freshness
- Source
- auth0.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.