Implicit Flow in OAuth2 (v2)
- Query id: e9817ad8-a8c9-4038-8a2f-db0e6e7b284b
- Query name: Implicit Flow in OAuth2 (v2)
- Platform: OpenAPI
- Severity: Medium
- Category: Access Control
- URL: Github
Description¶
There is a 'securityDefinition' using implicit flow on OAuth2, which is deprecated
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Postitive test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"schemes": [
"https"
],
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"securityDefinitions": {
"oAuth2AuthCodeNeg2": {
"type": "oauth2",
"description": "For more information, see https://api.my.company.com/docs/oauth",
"flow": "implicit",
"authorizationUrl": "https://api.my.company.com/oauth/authorize",
"scopes": {
"write:api": "modify apis in your account",
"read:api": "read your apis"
}
}
}
}
Postitive test num. 2 - yaml file
swagger: "2.0"
info:
title: Simple API overview
version: 1.0.0
schemes:
- https
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
"200":
description: 200 response
securityDefinitions:
oAuth2AuthCodeNeg2:
type: oauth2
description: For more information, see https://api.my.company.com/docs/oauth
flow: implicit
authorizationUrl: https://api.my.company.com/oauth/authorize
scopes:
write:api: modify apis in your account
read:api: read your apis
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"schemes": [
"https"
],
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"securityDefinitions": {
"oAuth2AuthCodeNeg2": {
"type": "oauth2",
"description": "For more information, see https://api.my.company.com/docs/oauth",
"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"
}
}
}
}
Negative test num. 2 - yaml file
swagger: "2.0"
info:
title: Simple API overview
version: 1.0.0
schemes:
- https
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
"200":
description: 200 response
securityDefinitions:
oAuth2AuthCodeNeg2:
type: oauth2
description: For more information, see https://api.my.company.com/docs/oauth
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