Project: KICS (Provisioning / Security & Compliance)
File: 274f910a-0665-4f08-b66d-7058fe927dba.md

title: Invalid OAuth2 Token URL (v2) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 274f910a-0665-4f08-b66d-7058fe927dba Query name: Invalid OAuth2 Token URL (v2) Platform: OpenAPI Severity: <span style="color:#ff7213">Medium</span> Category: Access Control URL: OAuth2 security definition flow requires a valid URL in the tokenUrl field<br> ```yaml title="Positive test num. 1 - yaml file" hl_lines="22" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 license: name: "Apache 2.0" url: "https://www.apache.org/licenses/LICENSE-2.0.html" paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response securityDefinitions: oAuth2AuthCodeNeg3: 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: http://example.com#@evil.com/ scopes: read:api: read your apis ``` ```json title="Positive test num. 2 - json file" hl_lines="30" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response" } } } } }, "securityDefinitions": { "oAuth2AuthCodeNeg3": { "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": "http://example.com#@evil.com/", "scopes": { "read:api": "read your apis" } } } } ``` ```yaml title="Negative test num. 1 - yaml file" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 license: name: "Apache 2.0" url: "https://www.apache.org/licenses/LICENSE-2.0.html" paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response securityDefinitions: oAuth2AuthCodeNeg3: 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: read:api: read your apis ``` ```json title="Negative test num. 2 - json file" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response" } } } } }, "securityDefinitions": { "oAuth2AuthCodeNeg3": { "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": { "read:api": "read your apis" } } } } ```