+V10 OAuth and OIDC
---+V10.1 Generic OAuth and OIDC Security
------+V10.1.1 Verify that tokens are only sent to components that strictly need them. For example, when using a …
------+V10.1.2 Verify that the client only accepts values from the authorization server (such as the authorization …
---+V10.2 OAuth Client
------+V10.2.1 Verify that, if the code flow is used, the OAuth client has protection against browser-based …
------+V10.2.2 Verify that, if the OAuth client can interact with more than one authorization server, it has a …
------+V10.2.3 Verify that the OAuth client only requests the required scopes (or other authorization parameters) …
---+V10.3 OAuth Resource Server
------+V10.3.1 Verify that the resource server only accepts access tokens that are intended for use with that …
------+V10.3.2 Verify that the resource server enforces authorization decisions based on claims from the access …
------+V10.3.3 Verify that if an access control decision requires identifying a unique user from an access token …
------+V10.3.4 Verify that, if the resource server requires specific authentication strength, methods, or …
------+V10.3.5 Verify that the resource server prevents the use of stolen access tokens or replay of access tokens …
---+V10.4 OAuth Authorization Server
------+V10.4.1 Verify that the authorization server validates redirect URIs based on a client-specific allowlist …
------+V10.4.2 Verify that, if the authorization server returns the authorization code in the authorization …
------+V10.4.3 Verify that the authorization code is short-lived. The maximum lifetime can be up to 10 minutes for …
------+V10.4.4 Verify that for a given client, the authorization server only allows the usage of grants that this …
------+V10.4.5 Verify that the authorization server mitigates refresh token replay attacks for public clients …
------+V10.4.6 Verify that, if the code grant is used, the authorization server mitigates authorization code …
------+V10.4.7 Verify that if the authorization server supports unauthenticated dynamic client registration, it …
------+V10.4.8 Verify that refresh tokens have an absolute expiration, including if sliding refresh token …
------+V10.4.9 Verify that refresh tokens and reference access tokens can be revoked by an authorized user using …
------+V10.4.10 Verify that confidential client is authenticated for client-to-authorized server backchannel …
------+V10.4.11 Verify that the authorization server configuration only assigns the required scopes to the OAuth …
------+V10.4.12 Verify that for a given client, the authorization server only allows the 'response_mode' value that …
------+V10.4.13 Verify that grant type 'code' is always used together with pushed authorization requests (PAR).
------+V10.4.14 Verify that the authorization server issues only sender-constrained (Proof-of-Possession) access …
------+V10.4.15 Verify that, for a server-side client (which is not executed on the end-user device), the …
------+V10.4.16 Verify that the client is confidential and the authorization server requires the use of strong …
---+V10.5 OIDC Client
------+V10.5.1 Verify that the client (as the relying party) mitigates ID Token replay attacks. For example, by …
------+V10.5.2 Verify that the client uniquely identifies the user from ID Token claims, usually the 'sub' claim …
------+V10.5.3 Verify that the client rejects attempts by a malicious authorization server to impersonate another …
------+V10.5.4 Verify that the client validates that the ID Token is intended to be used for that client …
------+V10.5.5 Verify that, when using OIDC back-channel logout, the relying party mitigates denial of service …
---+V10.6 OpenID Provider
------+V10.6.1 Verify that the OpenID Provider only allows values 'code', 'ciba', 'id_token', or 'id_token code' …
------+V10.6.2 Verify that the OpenID Provider mitigates denial of service through forced logout. By obtaining …
---+V10.7 Consent Management
------+V10.7.1 Verify that the authorization server ensures that the user consents to each authorization request. …
------+V10.7.2 Verify that when the authorization server prompts for user consent, it presents sufficient and …
------+V10.7.3 Verify that the user can review, modify, and revoke consents which the user has granted through the …

V10 OAuth and OIDC

Control Objective

OAuth2 (referred to as OAuth in this chapter) is an industry-standard framework for delegated authorization. For example, using OAuth, a client application can obtain access to APIs (server resources) on a user's behalf, provided the user has authorized the client application to do so.

By itself, OAuth is not designed for user authentication. The OpenID Connect (OIDC) framework extends OAuth by adding a user identity layer on top of OAuth. OIDC provides support for features including standardized user information, Single Sign-On (SSO), and session management. As OIDC is an extension of OAuth, the OAuth requirements in this chapter also apply to OIDC.

The following roles are defined in OAuth:

  • The OAuth client is the application that attempts to obtain access to server resources (e.g., by calling an API using the issued access token). The OAuth client is often a server-side application.
  • A confidential client is a client capable of maintaining the confidentiality of the credentials it uses to authenticate itself with the authorization server.
  • A public client is not capable of maintaining the confidentiality of credentials for authenticating with the authorization server. Therefore, instead of authenticating itself (e.g., using 'client_id' and 'client_secret' parameters), it only identifies itself (using a 'client_id' parameter).
  • The OAuth resource server (RS) is the server API exposing resources to OAuth clients.
  • The OAuth authorization server (AS) is a server application that issues access tokens to OAuth clients. These access tokens allow OAuth clients to access RS resources, either on behalf of an end-user or on the OAuth client's own behalf. The AS is often a separate application, but (if appropriate) it may be integrated into a suitable RS.
  • The resource owner (RO) is the end-user who authorizes OAuth clients to obtain limited access to resources hosted on the resource server on their behalf. The resource owner consents to this delegated authorization by interacting with the authorization server.

The following roles are defined in OIDC:

  • The relying party (RP) is the client application requesting end-user authentication through the OpenID Provider. It assumes the role of an OAuth client.
  • The OpenID Provider (OP) is an OAuth AS that is capable of authenticating the end-user and provides OIDC claims to an RP. The OP may be the identity provider (IdP), but in federated scenarios, the OP and the identity provider (where the end-user authenticates) may be different server applications.

OAuth and OIDC were initially designed for third-party applications. Today, they are often used by first-party applications as well. However, when used in first-party scenarios, such as authentication and session management, the protocol adds some complexity, which may introduce new security challenges.

OAuth and OIDC can be used for many types of applications, but the focus for ASVS and the requirements in this chapter is on web applications and APIs.

Since OAuth and OIDC can be considered logic on top of web technologies, general requirements from other chapters always apply, and this chapter cannot be taken out of context.

This chapter addresses best current practices for OAuth2 and OIDC aligned with specifications found at https://oauth.net/2/ and https://openid.net/developers/specs/. Even if RFCs are considered mature, they are updated frequently. Thus, it is important to align with the latest versions when applying the requirements in this chapter. See the references section for more details.

Given the complexity of the area, it is vitally important for a secure OAuth or OIDC solution to use well-known industry-standard authorization servers and apply the recommended security configuration.

Terminology used in this chapter aligns with OAuth RFCs and OIDC specifications, but note that OIDC terminology is only used for OIDC-specific requirements; otherwise, OAuth terminology is used.

In the context of OAuth and OIDC, the term "token" in this chapter refers to:

  • Access tokens, which shall only be consumed by the RS and can either be reference tokens that are validated using introspection or self-contained tokens that are validated using some key material.
  • Refresh tokens, which shall only be consumed by the authorization server that issued the token.
  • OIDC ID Tokens, which shall only be consumed by the client that triggered the authorization flow.

The risk levels for some of the requirements in this chapter depend on whether the client is a confidential client or regarded as a public client. Since using strong client authentication mitigates many attack vectors, a few requirements might be relaxed when using a confidential client for L1 applications.

References

For more information on OAuth, please see:

For OAuth-related requirements in ASVS following published and in draft status RFC-s are used:

For more information on OpenID Connect, please see:

1. Pregled

Naslov Standard
V10.1 Generic OAuth and OIDC Security

This section covers generic architectural requirements that apply to all applications using OAuth or OIDC.

V10.2 OAuth Client

These requirements detail the responsibilities for OAuth client applications. The client can be, for example, a web server backend (often acting as a Backend For Frontend, BFF), a backend service integration, or a frontend Single Page Application (SPA, aka browser-based application).

In general, backend clients are regarded as confidential clients and frontend clients are regarded as public clients. However, native applications running on the end-user device can be regarded as confidential when using OAuth dynamic client registration.

V10.3 OAuth Resource Server

In the context of ASVS and this chapter, the resource server is an API. To provide secure access, the resource server must:

  • Validate the access token, according to the token format and relevant protocol specifications, e.g., JWT-validation or OAuth token introspection.
  • If valid, enforce authorization decisions based on the information from the access token and permissions which have been granted. For example, the resource server needs to verify that the client (acting on behalf of RO) is authorized to access the requested resource.

Therefore, the requirements listed here are OAuth or OIDC specific and should be performed after token validation and before performing authorization based on information from the token.

V10.4 OAuth Authorization Server

These requirements detail the responsibilities for OAuth authorization servers, including OpenID Providers.

For client authentication, the 'self_signed_tls_client_auth' method is allowed with the prerequisites required by section 2.2 of RFC 8705.

V10.5 OIDC Client

As the OIDC relying party acts as an OAuth client, the requirements from the section "OAuth Client" apply as well.

Note that the "Authentication with an Identity Provider" section in the "Authentication" chapter also contains relevant general requirements.

V10.6 OpenID Provider

As OpenID Providers act as OAuth authorization servers, the requirements from the section "OAuth Authorization Server" apply as well.

Note that if using the ID Token flow (not the code flow), no access tokens are issued, and many of the requirements for OAuth AS are not applicable.

V10.7 Consent Management

These requirements cover the verification of the user's consent by the authorization server. Without proper user consent verification, a malicious actor may obtain permissions on the user's behalf through spoofing or social-engineering.

1.1 Sklici

1.2 Ugotovljene zahteve

1.3 Povezani predpisi

2. Ugotovljene zahteve

Zahteve
Vir Zahteva

3. Povezani predpisi

Predpisi
Vir Regulativa
  • OWASP -

    EN: Publications of the OWASP Foundation, https://owasp.org/. OWASP® is a registered trademark of the OWASP Foundation, Inc.; GRCA is not affiliated with, nor endorsed by, the OWASP Foundation. Only the versions published by OWASP are authoritative.

    DE: Veröffentlichungen der OWASP Foundation, https://owasp.org/. OWASP® ist eine eingetragene Marke der OWASP Foundation, Inc.; GRCA steht in keiner Verbindung zur OWASP Foundation und wird von ihr nicht unterstützt. Maßgeblich sind allein die von OWASP veröffentlichten Fassungen.