Description
OpenAPI 3.0 resolves a relative server URL from the location of the OpenAPI document.
Potential impact
A path starting with a single / stays on the document’s host, even if the path looks like a hostname.
Remediation
Resolve the URL from the location where you serve the document. If clients should always call a particular host, specify its full HTTPS URL.
Examples
In the Link example, /development.gigantic-server.com/v1 is a path on the document host. https://development.gigantic-server.com/v1 selects a separate host. Supply the Link’s target operationId or operationRef.
Before
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"summary": "List API versions",
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
},
"links": {
"address": {
"server": {
"url": "/development.gigantic-server.com/v1"
}
}
}
}
},
"operationId": "listVersionsv2"
}
}
}
}
After
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"summary": "List API versions",
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
},
"links": {
"address": {
"server": {
"url": "https://development.gigantic-server.com/v1"
}
}
}
}
},
"operationId": "listVersionsv2"
}
}
}
}