Resource owner password grant flow in OAuth2 authentication allowed
Issue ID: v3-global-securityscheme-oauth2-ropg
Average severity: Minimal
Description
One or more global security schemes in the API allows to set security requirements that use resource owner password grant flow in OAuth2 authentication. This flow has been deprecated by OAuth Best Current Practice and must not be used.
This is a potential risk, because the definition is in security schemes. However, it easily turns into an actual risk when the unsafe method is used in a security requirement.
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:
{
"servers": [
{
"url": "https://my.api.server.com/",
"description": "API server"
}
],
// ...
"components": {
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"flows": {
"password": {
"scopes": {
"write": "modify objects in your account",
"read": "read objects in your account"
},
"tokenUrl": "https://example.com/oauth/token"
}
}
}
}
}
}
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 grant flow in OAuth2 authentication.
{
"servers": [
{
"url": "https://my.api.server.com/",
"description": "API server"
}
],
// ...
"components": {
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"scopes": {
"write": "modify objects in your account",
"read": "read objects in your account"
},
"authorizationUrl": "https://example.com/oauth/authorize",
"tokenUrl": "https://example.com/oauth/token"
}
}
}
}
},
// ...
"security": [
{
"OAuth2": [
"write",
"read"
]
}
]
}