Description
In OpenAPI 3.0, flows such as authorizationCode use tokenUrl for token requests. The implicit flow does not use a token endpoint.
Potential impact
A wrong destination can prevent token issuance or disclose credentials.
Remediation
In the flow under components.securitySchemes, set tokenUrl to the provider’s official HTTPS token endpoint. Exclude URL fragments beginning with #. Verify the client’s destination and certificate validation.
Examples
The example corrects the token endpoint for authorizationCode. The sign-in endpoint stays in authorizationUrl.
Before
yaml
openapi: 3.0.0
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://api.my.company.com/oauth/authorize
tokenUrl: http://example.com#@evil.com/
scopes:
read:api: read your apis
After
yaml
openapi: 3.0.0
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://api.my.company.com/oauth/authorize
tokenUrl: https://api.my.company.com/oauth/token
scopes:
read:api: read your apis