Critical Account Takeover via Unauthenticated API Key Creati... #1513
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
What: Critical authn/authz logic flaw in better-auth’s API keys plugin lets unauthenticated clients mint or modify API keys for arbitrary users (CVE-2025-61928, advisory GHSA-99h5-pjcv-gr6v). Affects all versions that include the plugin up to 1.3.25; fixed in 1.3.26. Library has ~300,000 weekly npm downloads and is used by organizations including Equinor.
Where: API keys plugin routes:
-
/api/auth/api-key/create<...🔧 Technical DetailsBody-controlled identity to bypass auth: Treating the presence of
userIdin the request body as a reason to disable auth (authRequired = ... && !ctx.body.userId) lets attackers forgeuser = { id: ctx.body.userId }without a session, binding operations to arbitrary accounts via a single unauthenticated POST.Privilege shaping through server-only fields: Once in the unauthenticated branch, server-side guards don’t run; attackers can directly set
permissions,rateLimitMax,refillAmount, andremainingto grant expansive capabilities to newly minted keys.Logic reuse across routes: Reusing the same flawed
authRequiredpredicate in both create and update routes generalizes the technique to key modification, not just creation, broadening abuse from initial compromise to persistent capability escalation.🤖 Agent Actions
I analyzed the blog and repository, explored existing relevant content, and updated HackTricks accordingly.
What I looked for in HackTricks
Decision
Changes made
Technical highlights added
const authRequired = (ctx.request || ctx.headers) && !ctx.body.userId;
const user = session?.user ?? (authRequired ? null : { id: ctx.body.userId });
References used
No new file was needed; the update integrates with existing structure and style.
This PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.