Description
If an operation references an implicit scheme in security, its client receives an access token in the redirect response.
Potential impact
A leaked token can expose its permissions. Accepting the wrong token can put a request under the wrong account.
Remediation
Configure the client and authorization server for authorization code with PKCE. Change the flow in securityDefinitions to accessCode and supply the provider’s HTTPS endpoints. Require only the scopes the operation needs.
Examples
GET / keeps its petstore_auth reference and requires only read:api.
Before
json
{
"swagger": "2.0",
"paths": {
"/": {
"get": {
"security": [
{
"petstore_auth": []
}
]
}
}
},
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"flow": "implicit",
"authorizationUrl": "https://api.my.company.com/oauth/authorize",
"scopes": {
"read:api": "read your apis"
}
}
}
}
After
json
{
"swagger": "2.0",
"paths": {
"/": {
"get": {
"security": [
{
"petstore_auth": [
"read:api"
]
}
]
}
}
},
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"flow": "accessCode",
"authorizationUrl": "https://api.my.company.com/oauth/authorize",
"tokenUrl": "https://api.my.company.com/oauth/token",
"scopes": {
"write:api": "modify apis in your account",
"read:api": "read your apis"
}
}
}
}