🛡️ Sentinel: [CRITICAL] Fix subprocess compilation RCE & DoS vulnerabilities#315
🛡️ Sentinel: [CRITICAL] Fix subprocess compilation RCE & DoS vulnerabilities#315anchapin wants to merge 1 commit into
Conversation
…ilities Enforce `-no-shell-escape` flags and explicit timeouts for `pdflatex` and `pandoc` compilation subprocesses in `cover_letter_generator.py` and `converter.py`. Co-authored-by: anchapin <6326294+anchapin@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Reviewer's GuideHarden subprocess LaTeX/PDF compilation against RCE and DoS by disabling shell escape for pdflatex/pandoc and adding bounded, well‑cleaned timeouts for all compilation and availability checks, and record this as a new Sentinel security note. Sequence diagram for secure PDF compilation subprocess handlingsequenceDiagram
participant Caller as CoverLetterGenerator_or_Converter
participant Subprocess as subprocess
participant Process as Popen_process
Caller->>Subprocess: Popen(pdflatex_or_pandoc_args)
Subprocess-->>Caller: Process
Caller->>Process: communicate(timeout=30)
alt TimeoutExpired
Process-->>Caller: subprocess.TimeoutExpired
Caller->>Process: kill()
Caller->>Process: communicate()
Caller-->>Caller: raise RuntimeError("PDF compilation timed out")
else Completed
Process-->>Caller: stdout, stderr
Caller-->>Caller: check returncode or output_path.exists()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new subprocess invocations for pdflatex/pandoc (including flags, timeouts, and timeout handling) are duplicated across converter.py and cover_letter_generator.py; consider extracting a shared helper to centralize this security-sensitive logic and reduce the risk of future drift.
- Raising a generic RuntimeError("PDF compilation timed out") on timeout changes the observable behavior of these paths; consider using a dedicated exception type or wrapping with additional context (e.g., which engine and source path) so callers and logs can distinguish timeout failures from other runtime errors.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new subprocess invocations for pdflatex/pandoc (including flags, timeouts, and timeout handling) are duplicated across converter.py and cover_letter_generator.py; consider extracting a shared helper to centralize this security-sensitive logic and reduce the risk of future drift.
- Raising a generic RuntimeError("PDF compilation timed out") on timeout changes the observable behavior of these paths; consider using a dedicated exception type or wrapping with additional context (e.g., which engine and source path) so callers and logs can distinguish timeout failures from other runtime errors.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
🚨 Severity: CRITICAL
💡 Vulnerability: The application was calling
pdflatexandpandocincover_letter_generator.pyandconverter.pywithout-no-shell-escapeflags and without tracking subprocess timeouts. Malicious or compromised LaTeX input containing shell-escape commands (\write18) could execute arbitrary system commands (Remote Code Execution) during the compilation step. Furthermore, compilation could hang indefinitely on invalid inputs, causing a Denial of Service (DoS) zombie process.🎯 Impact: Potential Remote Code Execution (RCE) and Denial of Service (DoS) when generating Cover Letters or converting PDFs.
🔧 Fix: Enforced
-no-shell-escapeflag forpdflatexand--pdf-engine-opt=-no-shell-escapeforpandoc. Wrappedprocess.communicate()in explicit try-catch blocks withtimeout=30, correctly catchingsubprocess.TimeoutExpired, executingprocess.kill(), and repeatingprocess.communicate()to prevent double-free issues and clean up zombie processes.✅ Verification: Tests passing (
python -m pytest tests/test_pdf_security.py). Manual code review confirms RCE paths closed and DoS zombie process prevention is handled correctly.PR created automatically by Jules for task 10899137613891022970 started by @anchapin
Summary by Sourcery
Harden PDF compilation against RCE and DoS by tightening LaTeX subprocess invocation and documenting the security learnings.
Bug Fixes:
Documentation: