GHSA-F49H-MHF2-FXMG
Unbounded `#'.repeat()` via headingLevels in @apostrophecms/ai-helper rich-text aiHelper route enables cheap request-level DoS
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-F49H-MHF2-FXMG divulgada | |
| Divulgación | Modificada | Última actualización del registro | |
| Remediación | Parche 1.0.0-beta.15 | @apostrophecms/ai-helper · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The rich-text AI helper route in @apostrophecms/ai-helper
(POST /api/v1/@apostrophecms/ai-helper-rich-text-widget/aiHelper) takes
req.body.headingLevels straight through launder.strings + parseInt with no
bounds and uses each value directly as the repeat count of `'#'.repeat(level)`
inside the heading-remap regex callback, followed by marked.parse() of the
amplified markdown and serialization into the JSON response.
Any logged-in user with edit rights on one content type can turn a ~79-byte
request into multi-hundred-MB allocations and seconds of blocked single-thread
event loop, with >100,000x per-request response-size amplification
(measured: 7.6 MB response from 79 bytes). A trivial loop saturates CPU and
memory for as long as the attacker keeps sending.
This code path is unaffected by the beta.13 hardening (GHSA-527g-ff96-x6wj,
Host-header SSRF in the image routes) and covered by no existing advisory.
Details
File: packages/ai-helper/modules/@apostrophecms/ai-helper-rich-text-widget/index.js
(index.js), present at current main a01f937, 2026-10-20:
const headingLevels = self.apos.launder.strings(req.body.headingLevels)
.map(level => parseInt(level)); // no range check
...
const markdown = content.replace(/(^|\n)(#+) /g, (all, before, hashes) => {
if (!headingLevels.length) { return ''; }
const level = headingLevels[hashes.length - 1];
return before + (level ? ('#'.repeat(level) + ' ') : ''); // attacker-controlled size
});
const html = marked.parse(markdown);
1. `apos.launder.strings()` (packages/launder) performs no numeric clamping —
verified: launder.strings(['530000000']) === ['530000000']. parseInt accepts
any decimal size. Zero validation exists between the request body and the
allocator.
2. The replace callback runs once per heading in the model output, so the
amplification multiplies per heading (x8 in a realistic 1000-token response).
3. The amplified string is then parsed by `marked` (unsanitized at this point)
and returned in full as JSON on the wire.
Only precondition: any permission checking that passes (nen "can edit at least
one content type" is sufficient) al and one (checkPermissions in
packages/ai-helper/index.js requires edit rights on at least one content type —
bundles editor minimum); any other step of the request (prompt string) passes as
well, because the vulnerable code runs identical in mock and real provider paths.
(Hold on — items 3 is wrong phrasing. Use this corrected block:)
Only precondition: being logged in as a user that `can(req, 'edit', type)` for
at least one content type — exactly what `checkPermissions` (in
packages/ai-helper/index.js) requires. The attack body passes every check; the
route runs normally and then does the amplification.
Proof of concept
1. Start an ApostropheCMS site with @apostrophecms/ai-helper configured
(any text provider; under APOS_AI_HELPER_MOCK=1 the same vulnerable code path
runs without an API key, which is convenient for verification).
2. Log in as any editor (needs edit rights on at least one piece type) and send:
POST /api/v1/@apostrophecms/ai-helper-rich-text-widget/aiHelper
Content-Type: application/json
Cookie: <session>
{
"prompt": "write about cats",
"headingLevels": ["50000000","50000000","50000000",
"50000000","50000000","50000000",
"50000000","50000000"]
}
3. Local measurements against the UNMODIFIED exported route handler
(widgetModule.apiRoutes(fakeSelf).post.aiHelper — module's own index.js),
real launder + real marked, model output stubbed with a realistic 8-heading
1000-token response, Node 22, --max-old-space-size=4096:
| headingLevels | result
|----------------|---------------------------------------------
| 2 (normal) | 20 ms, 0.7 KB response
| 1,000,000 | 294 ms blocked event loop, 7.6 MB response
| 2,000,000 | 630 ms blocked loop, 15.3 MB response
| 10,000,000 | ~450 ms CPU burn, multi-100MB transient,
| | caught `RangeError` from marked (500)
| 50,000,000 | 1,702 ms CPU burn per request, ~GB transient allocations
8 parallel requests at level 2,000,000: 4,836 ms of continuous CPU-bound
churn, RSS 44 -> 216 MB within seconds.
4. Amplification factor example: 79-byte request -> 7.6 MB response
(~100,000x) while burning ~300 ms of the single-threaded event loop.
Rotation of cheap concurrent requests keeps the CPU saturated indefinitely
and drives heap pressure (OOM risk on container-sized heaps).
Note: the harness script (ifSubmit during the advisory attach step) can be
provided on request; the numbered steps above are self-sufficient on a real
server.
Impact
Type: CWE-400 (Uncontrolled Resource Consumption) — request-level resource
exhaustion / DoS in the CMS admin API.
Who is impacted:
- Any ApostropheCMS site with @apostrophecms/ai-helper installed and configured
(all current releases: <= 1.0.0-beta.14).
- Attackers need only ordinary editor privileges (any user with edit rights on
one content type), which is a standard role — no admin required.
- All traffic sharing the Node process (all other editors, plus anything routed
through the same process, e.g. multisite instances) is starved by the
single-threaded event-loop blocking; the CMS freezes for as long as the
attacker loops requests; memory pressure additionally risks OOM kill on
typical container heaps.
Severity calibration note: the vendor's own prior advisory for a process-wide
DoS class (GHSA-j5rq-xfvr-p969 / CVE-2026-113666) established availability-only
reports as accepted findings; this one is more limited (transient per-request
cost rather than persistent broken state) — I report it as Medium/High boundary
and let you judge the final score.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npm@apostrophecms/ai-helper |
Corregida | 1.0.0-beta.15 | 0 d | 1.0.0-beta.15 no afectada |
1.0.0-beta.15Arsenal 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-f49h-mhf2-fxmgLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
