llamaCVEVulnerability Intelligence
/
Advisory · GitHub · npm · @apostrophecms/form

GHSA-RGG4-476Q-XGCG

@apostrophecms/form: File attachments stored and publicly accessible before CAPTCHA validation is enforced

Parche disponible
Descargar PNG JSON
CVSS 3.1
6.5
Media
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche a -33 d de la divulgación
Exposición98 dDesde la divulgación, 12 ago 2026, 12:41 p. m.
Detección97 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 1.5.4
Monitoreo
Detectada +1
10 jul 26
12 ago 26
18 nov 26
19 nov 26
10 jul 26
12 ago 26
14 sept 26
17 oct 26
19 nov 26
FechaFaseEventoDetalle
Remediación Parche 1.5.4 @apostrophecms/form · -33 d desde divulgación
Divulgación Publicada GHSA-RGG4-476Q-XGCG divulgada · CVSS 6.5 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

<img width="1919" height="1047" alt="stored" src="https://github.com/user-attachments/assets/4990ff98-f4a7-42c5-8a3d-4975781b68bb" />
server.js https://github.com/user-attachments/files/28651508/server.js
exploit.sh https://github.com/user-attachments/files/28651516/exploit.sh

Summary

In `@apostrophecms/form`, file attachments are stored to the database and served publicly before CAPTCHA validation errors are enforced. When CAPTCHA verification fails, the server returns HTTP 400 and creates no submission record, but `attachment.insert()` has already executed.

The resulting attachment record is never removed by garbage collection, which only targets records with `utilized: true` — a flag that form-uploaded attachments never receive.

An unauthenticated user can generate persistent, publicly accessible files on any site running `@apostrophecms/form` with file upload fields enabled, regardless of CAPTCHA configuration.

---

Details

Root Cause 1 — Incorrect Execution Order in `lib/processor.js`

`submitForm()` calls `checkRecaptcha()`, which pushes to `formErrors` but does not throw. File upload runs unconditionally before `formErrors` is checked:

// lib/processor.js lines 17–101
if (form.enableRecaptcha) {
  await self.checkRecaptcha(req, input, formErrors); // records failure, does not throw
}

for (const [field, value] of Object.entries(input)) {
  if (value === 'files-pending') {
    input[field] = await self.insertFieldFiles(req, field, req.files); // file stored here
  }
}

if (formErrors.length > 0) {
  throw self.apos.error('invalid', { formErrors }); // too late — file already in DB
}

`insertFieldFiles()` calls `attachment.insert()` with `{ permissions: false }`:

// lib/processor.js lines 121–123
const attachment = await self.apos.attachment.insert(req, files[entry], {
  permissions: false
});
Root Cause 2 — Orphaned Records Never Collected by Garbage Collection

The garbage collector in `modules/@apostrophecms/attachment/index.js` only processes records where `utilized: true`:

async function _delete() {
  const docs = await self.db.find({
    utilized: true,
    'docIds.0': { $exists: 0 },
    archived: true
  }).toArray();
}

Attachments created via `insertFieldFiles()` are never linked to any document and never receive the `utilized` flag. They match none of the garbage collection queries and persist indefinitely.

---

Proof of Concept

Tested Versions
  • `apostrophe` v4.30.0
  • `@apostrophecms/form` v1.5.3
Requirements
  • Node.js ≥ 18
  • Docker
Terminal 1 — MongoDB
docker start apos-mongo 2>/dev/null || docker run -d --name apos-mongo -p 27017:27017 mongo:6
Terminal 2 — Server
kill $(lsof -ti:3737) 2>/dev/null; sleep 1
cd /tmp/apos-form-inttest && node server.js 2>&1 | grep -v "Nonexistent widget\|doc type @apos\|WARNING: widget\|DeprecationWarning\|Use .node --trace"

Wait for:

[*] Ready. Run exploit.sh in Terminal 3.
Terminal 3 — Exploit
sleep 16 && bash /tmp/apos-form-inttest/exploit.sh
Expected Output
✓ Submission rejected (HTTP 400)
✓ Attachment record created (+1 in aposAttachments)
✓ No form submission record created (file completely detached)
✓ utilized flag absent — GC will never collect this record
✓ Attachment publicly accessible without authentication (HTTP 200)

CONFIRMED — all criteria met.

---

Impact

Any site running `@apostrophecms/form` with file upload fields is affected, regardless of whether CAPTCHA is enabled.

An unauthenticated attacker can repeatedly submit forms with attached files. Each rejected submission permanently stores an attachment record with a stable public URL.

Characteristics of the resulting attachments:

  • The submission is rejected with HTTP 400.
  • No form submission record is created.
  • The file remains publicly accessible.
  • The attachment record persists indefinitely.
  • Garbage collection does not remove the record.

As a result, an attacker can generate unbounded persistent storage and publicly accessible attacker-controlled files through requests that are explicitly rejected by the application.

Verified Behavior
  1. CAPTCHA verification fails.
  2. The application returns HTTP 400.
  3. `attachment.insert()` executes before the rejection path.
  4. A new record is written to `aposAttachments`.
  5. No new record is written to `aposFormSubmissions`.
  6. The uploaded file is retrievable through its public attachment URL.
  7. The attachment record lacks the state required for garbage-collection cleanup.

Remediation

Validate form submissions before processing file uploads.

Specifically, `submitForm()` should enforce CAPTCHA and other validation errors before calling `insertFieldFiles()` or `attachment.insert()`. Failed submissions should not result in attachment creation, public URL generation, or persistent storage.

Additionally, attachments created during form processing should either:

  • Be deleted if the submission ultimately fails, or
  • Be marked as temporary and automatically garbage collected unless associated with a successful form submission.

This ensures rejected submissions cannot create persistent, publicly accessible attachment records.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:L
AltoBajoNinguno
DisponibilidadA:L
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida Última
@apostrophecms/form≤ 1.5.3
1.5.3
1.5.7
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
npm@apostrophecms/form
Corregida 1.5.4 -33 d 1.5.7 no afectada
Versiones corregidas1.5.4
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/apostrophecms/apostrophe/security/advisories/GHSA-rgg4-476q-xgcg

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.