Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
**Vulnerability:** In `apps/zettel/src/tools/transcribe.ts`, the `binaryAvailable` function used `sh -c command -v ${bin}` which was susceptible to command injection if the `bin` argument (derived from `process.env.WHISPER_BIN`) contained shell metacharacters.
**Learning:** Even when reading from environment variables, interpolating strings into shell execution wrappers (`sh -c`) can expose systems to command injection vulnerabilities. `execFileSync` without `shell: true` should be preferred.
**Prevention:** Avoid using shell interpolation to evaluate environment variables or command-line arguments. Instead, use an argument array to pass executable names securely. For checking binary existence on `$PATH`, `execFileSync("which", [bin])` safely prevents shell execution by relying directly on the `which` executable and standard IO bindings.

## 2026-09-04 - [Path Traversal bypass via path.basename in POSIX env]
**Vulnerability:** Path traversal in file upload endpoints handling `file.name` via `path.basename`.
**Learning:** In Node.js running on POSIX systems (Linux/macOS), `path.basename` only strips `/`, but an attacker can provide a Windows-style path traversal payload (e.g. `..\..\etc\passwd`). Node's `path.basename` considers the entire string as the file name, meaning `path.join` will parse it and traverse directories.
**Prevention:** Thoroughly sanitize file names using strict regex matching (e.g., `file.name.replace(/[^a-zA-Z0-9.-]/g, "_")`) instead of relying on `path.basename` across mixed OS environments.
3 changes: 2 additions & 1 deletion apps/zettel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,10 @@ const routes = api
const arrayBuffer = await file.arrayBuffer();
const data = Buffer.from(arrayBuffer);

const safeFileName = file.name.replace(/[^a-zA-Z0-9.-]/g, "_");
const tmpPath = path.join(
os.tmpdir(),
`zettel-audio-${Date.now()}-${path.basename(file.name)}`,
`zettel-audio-${Date.now()}-${safeFileName}`,
);
fs.writeFileSync(tmpPath, data);

Expand Down
Loading