Project: KICS (Provisioning / Security & Compliance)
File: 9aa6e95c-d964-4239-a3a8-9f37a3c5a31f.md

title: Undefined Scope 'securityDefinition' On Global 'security' Field hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 9aa6e95c-d964-4239-a3a8-9f37a3c5a31f Query name: Undefined Scope 'securityDefinition' On Global 'security' Field Platform: OpenAPI Severity: <span style="color:#edd57e">Low</span> Category: Access Control URL: Using an scope on global security field that is undefined on 'securityDefinitions' can be defined by an attacker<br> ```yaml title="Positive test num. 1 - yaml file" hl_lines="23" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 paths: /: get: operationId: listVersionsv2 summary: List API versions responses: "200": description: Success securityDefinitions: oAuth2AuthCodeNeg2: type: oauth2 description: For more information, see https://api.my.company.com/docs/oauth flow: authorizationCode authorizationUrl: https://api.my.company.com/oauth/authorize tokenUrl: https://api.my.company.com/oauth/token scopes: read:api: read your apis security: oAuth2AuthCodeNeg2: read:api error:api ``` ```json title="Positive test num. 2 - json file" hl_lines="33" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "Success" } } } } }, "securityDefinitions": { "oAuth2AuthCodeNeg2": { "type": "oauth2", "description": "For more information, see https://api.my.company.com/docs/oauth", "flow": "authorizationCode", "authorizationUrl": "https://api.my.company.com/oauth/authorize", "tokenUrl": "https://api.my.company.com/oauth/token", "scopes": { "read:api": "read your apis" } } }, "security": { "oAuth2AuthCodeNeg2": [ "read:api", "error:api" ] } } ``` ```yaml title="Negative test num. 1 - 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: Success securityDefinitions: oAuth2AuthCodeNeg2: type: oauth2 description: For more information, see https://api.my.company.com/docs/oauth flow: authorizationCode authorizationUrl: https://api.my.company.com/oauth/authorize tokenUrl: https://api.my.company.com/oauth/token scopes: read:api: read your apis security: oAuth2AuthCodeNeg2: read:api ``` ```json title="Negative test num. 2 - 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": "Success" } } } } }, "securityDefinitions": { "oAuth2AuthCodeNeg2": { "type": "oauth2", "description": "For more information, see https://api.my.company.com/docs/oauth", "flow": "authorizationCode", "authorizationUrl": "https://api.my.company.com/oauth/authorize", "tokenUrl": "https://api.my.company.com/oauth/token", "scopes": { "read:api": "read your apis" } } }, "security": { "oAuth2AuthCodeNeg2": [ "read:api" ] } } ```