Skip to content
Open
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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
**Vulnerability:** API endpoints in `backend/src/server.ts` taking user input (`projectId`, `jobId`) were directly joined with paths using `join` in `backend/src/store/localStore.ts` without proper sanitization. This allowed attackers to escape the project directory context and overwrite or read arbitrary files by sending payload containing `../` sequences.
**Learning:** Even internal backend services handling project resources must securely sanitize all parameter values used for file operations to prevent path traversal outside expected boundaries.
**Prevention:** Always use safe path sanitization utilities, like the implemented `safeJoin` and `toSafeRelativePath` in `backend/src/utils/path.ts`, to securely construct file paths and ensure the final path remains within the intended boundaries.
## 2024-05-24 - [Command Option Injection in Compile Worker]
**Vulnerability:** The `CompileQueueService` passed the user-provided `mainFile` parameter directly as a positional argument to `latexmk` within the Rust compile worker. If `mainFile` started with a hyphen (e.g., `-shell-escape`), `latexmk` would interpret it as a command-line flag rather than a filename, leading to arbitrary flag injection.
**Learning:** External process execution wrappers (like `spawn` or `Command`) that accept array-based arguments are still vulnerable to option/flag injection if user input intended as positional arguments starts with hyphens.
**Prevention:** Always explicitly validate that user-provided arguments intended to be filenames do not start with a hyphen before passing them to external command executors.
3 changes: 3 additions & 0 deletions backend/src/services/compileQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export class CompileQueueService {
const settings = await this.store.getSettings();
const projectId = request.projectId.trim();
const mainFile = request.mainFile?.trim() || "main.tex";
if (mainFile.startsWith("-")) {
throw new HttpError(400, "mainFile cannot start with a hyphen.");
}
const timeoutMs = request.timeoutMs ?? settings.compileTimeoutMs;
const jobId = createId("job");

Expand Down