Operation uses implicit grant flow in OAuth2 authentication
Issue ID: v3-operation-securityrequirement-oauth2-implicit
Average severity: Minimal
Description
The API operation uses implicit grant flow in OAuth2 authentication. This flow has been deprecated by OAuth Best Current Practice.
OAuth2 implicit grant flow uses long-lived access tokens, does not support refresh tokens, and the technical limitations that used to justify using the flow are gone.
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": {
"implicit": {
"scopes": {
"write": "modify objects in your account",
"read": "read objects in your account"
},
"authorizationUrl": "https://example.com/oauth/authorize"
}
}
}
}
},
// ...
"paths": {
"/pets": {
"post": {
"description": "Creates a new pet in the store",
"operationId": "addPet",
"security": [
{
"OAuth2": [
"write",
"read"
]
}
]
// ...
}
}
}
}
Possible exploit scenario
Implicit grant flow can leak access tokens and is vulnerable to access token replay. The long-lived access tokens and lack of refresh tokens provide extended opportunity for exploits.
Remediation
Do not use implicit grant flow in OAuth 2 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"
}
}
}
}
},
// ...
"paths": {
"/pets": {
"post": {
"description": "Creates a new pet in the store",
"operationId": "addPet",
"security": [
{
"OAuth2": [
"write",
"read"
]
}
]
// ...
}
}
}
}