🛡️ Sentinel: [CRITICAL] Fix RCE and DoS in PDF Compilation - #439
Conversation
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 GuideAdds hardened PDF compilation by disabling LaTeX shell escape and enforcing execution timeouts for pdflatex/pandoc in both the cover letter generator and shared PDF converter, and documents the security fix in the Sentinel log. Sequence diagram for hardened PDF compilation with timeout and no_shell_escapesequenceDiagram
participant CoverLetterGenerator
participant subprocess
participant pdflatex
CoverLetterGenerator->>subprocess: Popen(pdflatex -interaction=nonstopmode -no-shell-escape)
subprocess-->>pdflatex: start_process
CoverLetterGenerator->>pdflatex: process.communicate(timeout=30)
alt compilation completes
pdflatex-->>CoverLetterGenerator: stdout, stderr (returncode == 0)
CoverLetterGenerator->>CoverLetterGenerator: set pdf_created True
else subprocess.TimeoutExpired
pdflatex-->>CoverLetterGenerator: TimeoutExpired
CoverLetterGenerator->>pdflatex: process.kill()
pdflatex-->>CoverLetterGenerator: stdout, stderr after kill
CoverLetterGenerator->>CoverLetterGenerator: return False
end
Sequence diagram for hardened Pandoc PDF compilation with timeout and no_shell_escapesequenceDiagram
participant PDFConverter
participant subprocess
participant pandoc
PDFConverter->>subprocess: Popen(pandoc --pdf-engine=xelatex --pdf-engine-opt=-no-shell-escape)
subprocess-->>pandoc: start_process
PDFConverter->>pandoc: process.communicate(timeout=30)
alt compilation completes
pandoc-->>PDFConverter: stdout, stderr (returncode == 0)
PDFConverter->>PDFConverter: return True
else subprocess.TimeoutExpired
pandoc-->>PDFConverter: TimeoutExpired
PDFConverter->>pandoc: process.kill()
pandoc-->>PDFConverter: stdout, stderr after kill
PDFConverter->>PDFConverter: return False
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
🚨 Severity: CRITICAL
💡 Vulnerability: PDF compilation commands (pdflatex/pandoc) lacked restricted execution flags and timeouts, allowing arbitrary command execution (RCE) via write18 and Denial of Service (DoS) via process hanging.
🎯 Impact: Malicious LaTeX input could execute arbitrary shell commands on the host system or consume all resources by hanging the process indefinitely.
🔧 Fix: Added -no-shell-escape flag to pdflatex and --pdf-engine-opt=-no-shell-escape to pandoc. Implemented subprocess.communicate(timeout=30) to enforce execution limits.
✅ Verification: Run the test suite (make test) and verify that compilation commands are correctly sanitized and time out as expected.
PR created automatically by Jules for task 5865900579289697483 started by @anchapin
Summary by Sourcery
Harden PDF compilation by restricting LaTeX shell execution and enforcing timeouts on external processes.
Bug Fixes:
Documentation: