GHSA-Q7MC-WH43-5H8X
Prototype Pollution via Delta Context/Path in DeltaCache
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-Q7MC-WH43-5H8X divulgada · CVSS 3.1 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Remediación | Parche 2.31.0 | signalk-server · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
A delta whose context (or context and path) is `__proto__` reaches `Object.prototype` through two independent code paths in `DeltaCache`, letting an authenticated, non-admin `readwrite` user set an arbitrary property on the shared global object — visible to every other request, vessel, and plugin in the same server process, not just the sender's own data. With the default ACL configuration, a `readwrite` principal can already write any value to any path; reaching the JavaScript prototype chain is a different kind of access, outside any data scope a `readwrite` grant reaches even with ACLs disabled. Concretely, this lets the same principal cause a disabled plugin to be silently started (real code execution, via a plugin-configuration check that reads a property without checking it's the object's own) or to appear enabled in the webapp list.
Details
`handleMessage` https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/index.ts#L487-L499 only rewrites `context` when it is `undefined` or exactly `'vessels.self'`; any other string passes through unchanged. `isValidUpdate` https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/index.ts#L1064-L1084 only requires `values[].path` to be a string. The WebSocket write path gates on `shouldAllowWrite` https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/interfaces/ws.ts#L963 before forwarding to `handleMessage` — an authenticated `readwrite`, non-admin principal reaches both sinks below.
`getLeafObject` https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/deltacache.ts#L1591-L1611 walks `current[p]` for each context/path segment. When `p` is `'__proto__'`, `current[p]` is already defined — it's the live `Object.prototype` every plain object inherits — so the walk re-points `current` to it without creating anything. The next segment is then undefined there, and gets written directly onto the real `Object.prototype`.
`getContextAndPathParts`'s cache write https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/deltacache.ts#L212-L230 is a second, independent path: `this.cachedContextPaths['__proto__']` always reads back truthy for the same reason, so the "create if missing" guard never fires, and `this.cachedContextPaths['__proto__'][msg.path] = ...` writes straight onto `Object.prototype` — context alone needs to be `'__proto__'`, no second path segment required.
Not the same root cause as `GHSA-qh3j-mrg8-f234` (prototype *read* via the `from` field bypass in `/signalk/v1/applicationData`) — that endpoint's own guard (`DANGEROUS_PATH_SEGMENTS`/`isPrototypePollutionPath`, `applicationData.js#L53-L65` https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/interfaces/applicationData.js#L53-L65) is a different code path and isn't applied to delta ingestion. Also related: `306a64ef` ("fix(server-api): drop delta paths with prototype keys") fixed the same bug class in a sibling cache — `addValue` in `packages/server-api/src/fullsignalk.ts` — reachable from the same kind of delta. That fix doesn't cover `DeltaCache`, which is a separate tree with its own walk logic.
PoC
Against the real, unmodified `DeltaCache.ingestDelta`, the function `index.ts#L341` https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/index.ts#L341 calls for every delta:
cache.ingestDelta({
context: '__proto__',
updates: [{
$source: 'poc',
values: [{ path: 'pocPollutedFlag', value: 'pwned' }]
}]
})
const unrelatedObject = {}
// .pocPollutedFlag is now defined on it.Output:
✔ a single delta from an authenticated non-admin principal pollutes Object.prototype server-wide
1 passing (2ms)Evaluating the exact expressions from `plugins.ts` and `webapps.ts` against a bare `{}` (what `getPluginOptions` returns for any never-configured plugin) before and after the same `ingestDelta` call above:
const before = JSON.parse('{}')
if (before.enabled) { /* plugins.ts:1063 */ } // does not fire
cache.ingestDelta({
context: '__proto__',
updates: [{ $source: 'poc', values: [{ path: 'enabled', value: true }] }]
})
const after = JSON.parse('{}') // a different, unrelated plugin's options
if (after.enabled) { /* plugins.ts:1063 */ } // fires
after?.enabled ?? false // webapps.ts:70 -- also truthyOutput:
✔ flips a never-configured plugin's options.enabled from absent to truthy
✔ flips webapps.ts's isPluginEnabled check the same way
2 passing (3ms)Impact
An authenticated, non-admin `readwrite` principal can set arbitrary properties on `Object.prototype`, affecting every other request, every other vessel's data, and every plugin loaded in the same process. Reachable via two independent code paths, either alone sufficient. Two real places in the codebase turn that write into concrete behaviour:
- `getPluginOptions`
https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/interfaces/plugins.ts#L332-L347returns `JSON.parse('{}')` — an object with no own properties — for any plugin that has never had its configuration saved. That object is read at `plugins.ts#L1063`https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/interfaces/plugins.ts#L1063: `if (options.enabled) { doPluginStart(...) }`, which calls the plugin's real `start()` function with full server privileges. Pollute `enabled` and the next time an admin saves configuration for *any* never-configured plugin, a *different*, deliberately dormant plugin silently starts. - `isPluginEnabled`
https://github.com/SignalK/signalk-server/blob/8dbc27e2b4bb2f32ad112acd8b89efaf77f9af99/src/interfaces/webapps.ts#L61-L70reads the same kind of options object with `options?.enabled ?? false` — `??` only falls back for `null`/`undefined`, so a polluted value passes through. This feeds `GET /webapps`, which needs only an authenticated principal, not admin — the same `readwrite` attacker can trigger it directly, no admin action required, and get a disabled plugin's webapp listed as available.
Suggested fix
+const DANGEROUS_PATH_SEGMENTS = ['__proto__', 'constructor', 'prototype']
+
function getLeafObject(start, contextAndPathParts, createIfMissing = false, returnLast = false) {
for (...) {
const p = contextAndPathParts[i]
+ if (DANGEROUS_PATH_SEGMENTS.includes(p)) return null
... getContextAndPathParts(msg) {
let result
if (this.cachedContextPaths[msg.context] && (result = ...)) {
return result // unchanged: cache-hit fast path
}
let contextAndPathParts = ...
+ if (contextAndPathParts.some((p) => DANGEROUS_PATH_SEGMENTS.includes(p))) {
+ return contextAndPathParts // uncached; getLeafObject rejects it too
+ }
...Plus null-checks at the two call sites that assumed a truthy result. The diff is above — it matches the guard already used in `src/interfaces/applicationData.js` and in `306a64ef`, applied here where it's currently missing.
Notes
Found via automated static analysis, manually reproduced and verified with the working PoC above. Happy to help with anything else, including code review of a fix.
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 |
|---|---|---|---|---|
npmsignalk-server |
Corregida | 2.31.0 | 0 d | 2.37.0 no afectada |
2.31.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/SignalK/signalk-server/security/advisories/GHSA-q7mc-wh43-5h8xLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
