Description

A vulnerability in authentication bypass (CVE-2025-61928) had existed in the popular TypeScript auth library Better Auth. The flaw permitted unauthenticated actors to set or generate the API keys of any users, allowing complete account and app takeover. The exploit is simple: making a posting to the endpoint that creates API keys with the userId of a victim in the request body creates the proper key for the user in vulnerable builds. The vulnerability resolved with version 1.3.26. The flaw originates from flawed identity management within the API-key endpoints. Without an active session the code reverts to ctx.body.userId and assumes the request to be authenticated; since server-only validation occurs in the case of authRequired being true, the assaults can circumvent privileged-field validation as well as get their payload committed to the database unaltered. The same vulnerable pattern repeats with the update endpoint, allowing illegitimate updations of already existing keys that belong to different users. Mitigation steps: upgrade immediately to Better Auth 1.3.26 or newer and rotate any API keys created before the fix. Audit API-key routes and remove logic that treats client-supplied userId as authoritative; ensure authentication and server-side field validation always run regardless of request body contents. Add unit/integration tests for unauthenticated requests, review logs for suspicious create/update POSTs, and revoke any keys that show signs of compromise.