Description
In components.securitySchemes, type: http with scheme: basic defines Basic authentication. A security reference selects it. The server URL and connection settings determine whether traffic uses HTTPS.
Potential impact
Sending Basic credentials over HTTP can disclose a username and reusable password.
Remediation
Use HTTPS with certificate validation wherever clients send Basic credentials. If delegated user access is needed, configure OAuth2 authorization code with PKCE in the clients and authorization server and verify tokens and scopes at the API.
Examples
The Before excerpt defines Basic without requiring it. The After excerpt adds an HTTPS server and a global OAuth2 requirement. Limit each operation to the scopes it needs.
Before
{
"openapi": "3.0.0",
"servers": [
{
"url": "http://kicsapi.server.com/"
}
],
"components": {
"securitySchemes": {
"regularSecurity": {
"type": "http",
"scheme": "basic"
}
}
}
}
After
{
"openapi": "3.0.0",
"servers": [
{
"url": "https://kicsapi.server.com/"
}
],
"components": {
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://kicsapi.com/oauth/authorize",
"tokenUrl": "https://kicsapi.com/oauth/token",
"scopes": {
"write": "modify objects",
"read": "read objects"
}
}
}
}
}
},
"security": [
{
"OAuth2": [
"write",
"read"
]
}
]
}