Operation negotiates authentication

Issue ID: v3-operation-securityrequirement-http-negotiate

Average severity: Medium

Description

API operation negotiates authentication with a remote Simple And Protected Negotiate (SPNEGO) -based system.

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:

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

Possible exploit scenario

The most common systems used in negotiating authentication are Kerberos and the now obsolete NTLM (New Technology LAN Manager). The severity of this risk heavily depends on the which system is used: while Kerberos is reasonably secure, NTLM is not.

Because your API cannot know which system it is negotiating with, the only safe option is to assume the worst and treat all negotiation as not being secure.

Remediation

Use a more secure authentication method, like OAuth 2.0. It uses access tokens with limited lifetime and authorizations (the scopes) granted that the resource owner grants from an authorization server.

An API operation can be consumed only if the request includes an access token and the scopes of the token match the scopes that the API operation requires. Even if attackers successfully retrieved access tokens, they can only use the token on a subset of the API operation and for a limited time.

{ 
    "servers": [
        {
            "url": "https://my.api.server.com/",
            "description": "API server"
        }
    ],
    // ...
    "components": {
        "securitySchemes": {
            "OAuth2": {
                "type": "oauth2",
                "flows": {
                    "authorizationCode": {
                        "scopes": {
                            "write": "modify objects in your account",
                            "read": "read objects in your account"
                        },
                        "authorizationUrl": "https://example.com/oauth/authorize",
                        "tokenUrl": "https://example.com/oauth/token" 
                    }
                }
            }
        }
    },
    // ...
    "paths": {
        "/pets": {
            "post": {
                "description": "Creates a new pet in the store",
                "operationId": "addPet",
                "security": [
                    {
                        "OAuth2": [
                            "write",
                            "read"
                        ]
                    }
                ]
                // ...
            }
        }
    }
}