The vulnerability lies in the insecure default configurations of the oidcProvider and mcp plugins in better-auth. Specifically, two main issues were identified. First, the discovery endpoints for both plugins advertised alg=none as a supported algorithm for token signing. This could allow a malicious relying party to trick the system into accepting unsigned tokens, completely bypassing cryptographic verification. The functions getMetadata, getMCPProviderMetadata, and getMCPProtectedResourceMetadata were responsible for generating this metadata.
Second, the authorization endpoints for both plugins accepted the plain method for Proof Key for Code Exchange (PKCE) by default. The authorize and authorizeMCPOAuth functions would even silently default to plain if the code_challenge_method parameter was omitted from the request. This is a significant security risk, as the plain method offers no protection against authorization code interception. If an attacker could gain access to the authorization code (e.g., through a compromised browser or proxy logs), they could use it to obtain an access token and impersonate the user. The oidcProvider and mcp functions set these insecure defaults.
The patch addresses these issues by removing none from the list of supported algorithms in the metadata and by changing the default behavior to disallow the plain PKCE method unless explicitly enabled. It also adds stricter checks to the authorization endpoints to reject requests that are inconsistent or insecure.