Skip to content

AAK-MCP-BETTERAUTH-CVE-2026-53512-001: Better Auth OAuth/MCP plugin flaw cluster — token bypass, code replay, weak crypto, open redirect (below 1.6.13)

Severity
HIGH
Category
Supply Chain (supply-chain)
Scanner
agent_audit_kit/scanners/mcp_cve_pins_2026_07.py
Auto-fixable
No.
SARIF name
BetterAuthOauthTokenEndpointBypass

What it detects

Better Auth before 1.6.13 ships a cluster of OAuth flaws reachable through the mcp and legacy oidcProvider plugins (and @better-auth/oauth-provider from 1.6.0): the refresh_token grant authenticates only possession of the refreshToken row + matching client_id and never verifies the confidential client's client_secret, letting an attacker with a refresh token mint access/refresh tokens (CVE-2026-53512); the authorization_code grant redeems a single-use code via a non-atomic find-then-delete, so two concurrent requests both mint tokens (code replay, CVE-2026-53518); insecure cryptographic defaults advertise the none algorithm and accept plain PKCE by default (CVE-2026-67336, fixed 1.6.11); and registered redirect_uris are not scheme-validated, so a javascript: redirect URI executes in the authorization-server origin → session theft / account takeover (CVE-2026-67333, fixed 1.6.13). Treat < 1.6.13 (and unpinned) as exposed.

How to fix

Upgrade better-auth / @better-auth/oauth-provider to >= 1.6.13 and pin it. Verify client_secret on confidential-client refresh grants, redeem authorization codes atomically (single-use, delete-on-read under a lock), reject non-http(s) redirect_uri schemes, and disable the none algorithm / plain PKCE in the OIDC/MCP provider config.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-MCP-BETTERAUTH-CVE-2026-53512-001

Limitations

Reads better-auth and @better-auth/oauth-provider in requirements*.txt at any depth and, at the project root only, in pyproject.toml, Pipfile, package.json, .mcp.json, mcp.json, claude_desktop_config.json and the Pipfile.lock, poetry.lock, uv.lock, package-lock.json, pnpm-lock.yaml and yarn.lock lockfiles, taking the lowest version a range allows and reporting a reference that states no version. The dependency is not read when it is declared in a sub-directory manifest (packages/app/package.json) or in a lockfile format the reader does not parse (a Yarn 2+ yarn.lock). A file over 2 MB, or a lockfile over 32 MiB, is not read. A declaration nested more than 64 levels deep in package.json, a TOML manifest or an MCP config (an MCP server more than 62) is still judged, and reported without a line; a lockfile entry keeps its line at any depth.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-MCP-BETTERAUTH-CVE-2026-53512-001.md: the page then shows that text, with the registry reference appended under it.