Description
An OpenAPI 3.0 operation that uses Basic authentication sends a Base64-encoded username and password. Protect the connection with HTTPS.
Potential impact
Sending these credentials over HTTP can disclose a reusable password.
Remediation
Set the operation’s server URL to HTTPS and enable certificate validation in the client. If you move to OAuth2 for delegated access, configure authorization code with PKCE in the client and authorization server, and have the API verify tokens and required scopes.
Examples
The revised GET / uses HTTPS and requires only the OAuth2 read scope.
Before
json
{
"openapi": "3.0.0",
"components": {
"securitySchemes": {
"regularSecurity": {
"type": "http",
"scheme": "basic"
}
}
},
"paths": {
"/": {
"get": {
"servers": [
{
"url": "http://myapi.com/"
}
],
"security": [
{
"regularSecurity": []
}
]
}
}
}
}
After
json
{
"openapi": "3.0.0",
"components": {
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://myapi.com/oauth/authorize",
"tokenUrl": "https://myapi.com/oauth/token",
"scopes": {
"write": "modify objects",
"read": "read objects"
}
}
}
}
}
},
"paths": {
"/": {
"get": {
"servers": [
{
"url": "https://myapi.com/"
}
],
"security": [
{
"OAuth2": [
"read"
]
}
]
}
}
}
}