GHSA-3FG6-2672-62JF
Server-Side Prototype Pollution (process-wide DoS) via unguarded conditional-widget field walk in @apostrophecms/form
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-3FG6-2672-62JF divulgada · CVSS 5.5 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Remediación | Parche 1.5.7 | @apostrophecms/form · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
## Summary
`@apostrophecms/form`'s conditional-widget processor builds a nested tracking object (`conditionals`) keyed directly by attacker-controlled strings `widget.conditionName` / `widget.conditionValue`, with no `{__proto__, constructor, prototype}` denylist and no own-property (`Object.hasOwn`) traversal. An authenticated form editor can plant a `@apostrophecms/form-conditional` widget with `conditionName = "__proto__"`; a subsequent anonymous form submission then mutates the global `Object.prototype` — removing `Object.prototype.toString` (process-wide denial of service) or injecting an arbitrary inherited property (prototype pollution). This is the same CWE-1321 class fixed in `@apostrophecms/db-connect` (CVE-2026-113666), but in a different package (`@apostrophecms/form`), different file (`lib/processor.js`), and different, unguarded sink (`trackConditionals`).
## Root Cause
`packages/form/lib/processor.js:184-206` (`trackConditionals`):
trackConditionals(conditionals = {}, widget) {
const conditionName = widget.conditionName;
const conditionValue = widget.conditionValue;
if (!widget || !widget.contents || !widget.contents.items) { return; }
conditionals[conditionName] = conditionals[conditionName] || {};
conditionals[conditionName][conditionValue] =
conditionals[conditionName][conditionValue] || [];
widget.contents.items.forEach(item => {
conditionals[conditionName][conditionValue].push(item.fieldName);
});
if (conditionals[conditionName][conditionValue].length === 0) {
delete conditionals[conditionName][conditionValue];
}
}`conditionals` is a plain `{}`. `conditionals["__proto__"]` resolves via the inherited `__proto__` accessor to the shared `Object.prototype`. There is no key filtering and no `Object.create(null)` / `Object.hasOwn` guard — unlike the hardened `@apostrophecms/db-connect` `shared.js` which uses `const unsafePathSegments = new Set(['__proto__','constructor','prototype'])`.
## Impact
- Process-wide DoS (A:H): With `conditionName="__proto__"`, `conditionValue="toString"` and an empty conditional `contents` area, the empty-items branch executes `delete Object.prototype.toString`. Runtime-verified: afterward `typeof Object.prototype.toString === 'undefined'` and any object-to-primitive coercion throws `TypeError: Cannot convert object to primitive value` across the entire Node process until restart. Because the payload is stored in the published form, the process re-crashes on the next submit after restart until the malicious widget is deleted.
- Prototype pollution (I:L): With non-empty conditional items, `Object.prototype[conditionValue]` is set to an array on every object in the process (verified: `({}).polluted === ["x"]`).
`constructor`/`prototype` as `conditionName` do not reach `Object.prototype` (they create own-props on the plain object); the confirmed trigger is literally `__proto__`.
## Proof of Concept
1. As an authenticated form editor, create/edit a form, add an `@apostrophecms/form-conditional` widget, and store (verbatim):
{ "type": "@apostrophecms/form-conditional",
"conditionName": "__proto__", "conditionValue": "toString",
"contents": { "metaType": "area", "items": [] } }Publish the form.
2. As any anonymous visitor (logged out), trigger detonation:
POST /api/v1/@apostrophecms/form/submit
Content-Type: application/json
{"data":"{\"_id\":\"<formId>\"}"}- `submitForm` walks the stored `contents`, calls `trackConditionals` on the conditional widget → `delete Object.prototype.toString` → process-wide `TypeError` on subsequent coercion.
## Attack Chain
1. Entry (plant): Authenticated form editor stores a `@apostrophecms/form-conditional` widget with `conditionName="__proto__"`, `conditionValue="toString"`, empty `contents` (`packages/form/modules/@apostrophecms/form-conditional-widget/index.js:19-30`).
- Guard: `conditionName`/`conditionValue` are `type:'string'`, `required:true`, no `pattern`; string `convert` → `apos.launder.string`.
- Bypass proof: `apos.launder.string` (`packages/launder/index.js:71-85`) and the string `convert` (`packages/schema/lib/addFieldTypes.js:327-350`) perform only type-coercion/trim/length — no `{__proto__,constructor,prototype}` key filter. `"__proto__"` is the *value* of the property, so no storage sanitizer treats it as a dangerous key. Stored verbatim.
2. Entry (detonate): Anonymous `POST /api/v1/@apostrophecms/form/submit` (`packages/form/index.js:362-391`, `apiRoutes().post.submit`).
- Guard: none — `routeWrappers.apiRoutes` calls `fn(req)` with no permission middleware; `submitForm` (`processor.js:3`) performs no `req.user` check. reCAPTCHA runs only if `form.enableRecaptcha`.
- Bypass proof: `enableRecaptcha` is `type:'boolean'` with no `def:true` (`packages/form/lib/fields.js:103-107`) → OFF by default; and the attacker is the editor of the malicious form and leaves it off. Published forms are anonymously readable.
3. Processing: `self.apos.area.walk({contents: form.contents})` (`processor.js:71`) surfaces the stored conditional widget; `trackConditionals(conditionals, widget)` is invoked unconditionally (`processor.js:88-90`).
- Guard: `if (!widget || !widget.contents || !widget.contents.items) return;` (`processor.js:188`).
- Bypass proof: empty area has `items: []`, which is truthy → guard passes.
4. Sink: `conditionals["__proto__"]` resolves to `Object.prototype`; `conditionals["__proto__"]["toString"] || []` reads native `toString` (truthy, not overwritten); empty `forEach`; `.length === 0` reads native `toString.length` (`0`) → `delete conditionals["__proto__"]["toString"]` = `delete Object.prototype.toString` (`processor.js:192-204`).
5. Impact: `Object.prototype.toString` removed process-wide → every subsequent coercion/`JSON`/templating path throws until restart; persistent (re-crashes after restart until the widget is deleted).
## Bypass Evidence
Executing the exact `trackConditionals` body in Node:
- Empty-items + `conditionName="__proto__"`, `conditionValue="toString"` → `typeof Object.prototype.toString === "undefined"`; `({}).toString()` throws `TypeError`; coercion throws `Cannot convert object to primitive value`.
- Non-empty items → `({}).polluted === ["x"]` on a fresh victim object.
- `constructor`/`prototype` keys leave `Object.prototype` untouched (own-props only) — confirming the trigger is literally `__proto__`.
## Affected Versions
`@apostrophecms/form <= 1.5.6` (latest published; `trackConditionals` present on HEAD, no fix). This is a standalone optional npm package, not bundled in core `apostrophe`.
## Suggested Fix
Route `conditionName`/`conditionValue` through a `{__proto__, constructor, prototype}` denylist and/or build `conditionals` with `Object.create(null)` and `Object.hasOwn` traversal — matching the fix (`unsafePathSegments`) already present in `@apostrophecms/db-connect` `shared.js`.
---
Reported by zx (Jace) — GitHub: @manus-use
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@apostrophecms/form |
Corregida | 1.5.7 | 0 d | 1.5.7 no afectada |
1.5.7Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/apostrophecms/apostrophe/security/advisories/GHSA-3fg6-2672-62jfLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
