DEV Community

OnaEiuspkz
OnaEiuspkz

Posted on

OAuth 2.0 Security BCP: Where Legacy Deployments Still Fail

OAuth 2.0 Security BCP: Where Legacy Deployments Still Fail

RFC 9700 collects the security practices that OAuth implementers should have adopted after years of code interception, redirect manipulation, token leakage and mix-up attacks. Its publication does not alter deployed clients or authorization servers. It gives engineering teams a concrete baseline for finding the compatibility gaps that remain.

The most visible change is exact redirect URI matching. RFC 9700 requires exact string comparison, with a narrow exception for localhost ports used by native applications. A server that still performs prefix matching or wildcard matching has a larger attack surface than its registration screen suggests. An attacker who can register a lookalike path or influence an open redirect may be able to collect an authorization code. Exact matching should therefore be verified against the stored registration, the comparison function and every reverse proxy that can rewrite the incoming URI.

The authorization code grant also needs transaction binding. Public clients must use PKCE, and confidential clients are strongly encouraged to use it. The verifier has to belong to the same browser transaction and the same client. A PKCE implementation that accepts a static challenge or stores verifiers in a shared cache provides little protection against code injection.

Remove grants that cannot meet the baseline

RFC 9700 deprecates the implicit grant and treats the resource owner password credentials grant as a legacy option that should be removed. Both patterns place secrets or tokens in places that modern clients and browsers cannot protect reliably. Some organizations keep them because an old mobile application, set-top box or partner integration depends on the flow. That dependency should be treated as a migration project with an owner, an inventory and a deadline.

Client authentication deserves the same inventory. RFC 9700 recommends asymmetric authentication where the authorization server can support it, such as private key JWT or mutual TLS. A client secret is still a secret. If it is embedded in a desktop binary, copied into a CI variable or shared by several integrations, the authorization server can authenticate the credential without knowing which workload used it.

The specification also asks authorization servers to support metadata, including the authorization server metadata document in RFC 8414. Automated discovery reduces the chance that a client is configured with an obsolete endpoint or the wrong issuer. Discovery does not validate the metadata by itself. Clients still need a pinned trust policy for the issuer and a clear rule for refusing unexpected endpoints.

Query the logs before changing the flow

A safe migration starts with authorization and token endpoint logs. Group traffic by client ID, grant type, redirect URI, response type, PKCE method and token audience. Look for implicit responses, password grants, wildcard redirects, repeated authorization codes, token requests from unexpected addresses and clients that use both confidential and public flows.

Do not treat a successful authentication as proof of a correct flow. The authorization server should record whether PKCE was present, whether the verifier matched and whether the requested scope was allowed after consent. Resource servers should record token issuer and audience failures. These fields are often discarded because they are not needed for routine operations, which leaves responders unable to tell a legacy client from an attack.

The final control is the token itself. Bearer tokens remain valid until expiry, so a leaked token can be replayed by anyone who holds it. Sender-constrained tokens, such as DPoP or certificate-bound tokens, reduce that risk when the resource server enforces the binding. A proof header that a gateway validates but does not bind to the access token can create the appearance of protection without the property.

A practical acceptance test

Test the production configuration as an external client. Confirm that a modified redirect URI is rejected, that a code is bound to the original PKCE verifier, that an implicit request cannot obtain a token, and that a token minted for one resource server is rejected by another. Repeat the tests after proxy, DNS and identity-provider changes. The most common regression is a configuration maintained in two places: the application registration says one thing, while a gateway rewrites the request to something else.

RFC 9700 is useful because it converts a broad concern about OAuth security into testable behavior. The work is not complete when a vendor adds a compliance checkbox. It is complete when old grants are removed, redirect rules are exact, transaction binding survives every proxy, and resource servers validate the tokens they receive.

References

Top comments (0)