Password grant flow used in OAuth2 authentication

Issue ID: global-securityrequirement-oauth2-password

Average severity: Minimal

Description

The API uses resource owner password credentials grant flow in OAuth2 authentication. This flow has been deprecated by OAuth Best Current Practice and must not be used.

For more details, see the OpenAPI Specification.

Example

The following is an example of how this type of risk could look in your API definition:

{
    "schemes": [
        "https"
    ],
    // ...
    "securityDefinitions": {
        "OAuth2": {
            "type": "oauth2",
            "flow": "password",
            "scopes": {
                "readOnly": "read objects in your account"
            },
            "tokenUrl": "https://example.com/oauth/token"
        }
    },
    // ...
    "security" : {
        "OAuth2": [ "readOnly" ]
    }
}

Possible exploit scenario

The resource owner password grant flow in OAuth2 is highly dangerous, because it exposes the credentials of the resource owner to the client. Even in the best case, this expands the attack surface and also normalizes insecure behavior (entering your credentials somewhere else than the authorization server).

Remediation

Do not use resource owner password credentials grant flow in OAuth2 authentication.

{
    "schemes": [
        "https"
    ],
    // ...
    "securityDefinitions": {
        "OAuth2": {
            "type": "oauth2",
            "flow": "accessCode",
            "scopes": {
                "read": "read objects in your account",
                "write": "modify objects in your account"
            },
            "authorizationUrl": "https://example.com/oauth/authorize",
            "tokenUrl": "https://example.com/oauth/token" 
        }
    },
    // ...
    "security" : {
        "OAuth2": [
            "write",
            "read"
        ]
    }
}