Non OAuth2 Security Requirement Defining OAuth2 Scopes
- Query id: ba239cb9-f342-4c20-812d-7b5a2aa6969e
- Query name: Non OAuth2 Security Requirement Defining OAuth2 Scopes
- Platform: OpenAPI
- Severity: High
- Category: Structure and Semantics
- URL: Github
Description¶
If the security scheme is not of type 'oauth2', the array value must be empty
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"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
},
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "object"
}
}
]
}
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"securityDefinitions": {
"petstore_auth": {
"type": "basic"
}
}
}
Postitive test num. 2 - yaml file
swagger: "2.0"
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
"200":
description: 200 response
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: object
security:
- petstore_auth:
- write:pets
- read:pets
securityDefinitions:
petstore_auth:
type: basic
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
},
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "object"
}
}
]
}
}
},
"security": [
{
"petstore_auth": []
}
],
"securityDefinitions": {
"petstore_auth": {
"type": "basic"
}
}
}
Negative test num. 2 - yaml file
swagger: "2.0"
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
"200":
description: 200 response
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: object
security:
- petstore_auth: []
securityDefinitions:
petstore_auth:
type: basic