Operation accepts bearer tokens from OAuth authorization flows transported as cleartext

Issue ID: v3-operation-securityrequirement-http-bearer-clear

Average severity: Critical

Description

The API operation accepts bearer tokens from OAuth 2.0 authorization flows transported in the clear over an unencrypted channel Attackers can easily intercept API calls and retrieve the unencrypted tokens. They can then use the tokens to make other API calls.

For more details, see the OpenAPI Specification.

Example

The following is an example of how this type of risk could look in your API definition:

{
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer"
            }
        }
    },
    // ...
    "paths": {
        "/pets": {
            "post": {
                "description": "Creates a new pet in the store",
                "operationId": "addPet",
                "servers": [
                    {
                        "url": "http://my.api.server.com/",
                        "description": "API server"
                    }
                ],
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
                // ...
            }
        }
    }
}

Possible exploit scenario

Attackers can intercept the access tokens simply by listening to the network traffic in a public WiFi network. They could also use a traffic logging tool on a smartphone, computer, or browser, or sniff the traffic in the network to get the tokens.

Remediation

Set all server objects to support HTTPS only so that all traffic is encrypted.

{
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer"
            }
        }
    },
    // ...
    "paths": {
        "/pets": {
            "post": {
                "description": "Creates a new pet in the store",
                "operationId": "addPet",
                "servers": [
                    {
                        "url": "https://my.api.server.com/",
                        "description": "API server"
                    }
                ],
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
                // ...
            }
        }
    }
}