🛡️ Sentinel: [CRITICAL] Fix PDF compilation RCE vulnerability - #444
🛡️ Sentinel: [CRITICAL] Fix PDF compilation RCE vulnerability#444anchapin wants to merge 2 commits into
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 GuideHarden PDF compilation by disabling LaTeX shell escape in all pdflatex/pandoc subprocesses and adding timeout handling to avoid hanging or exploitable processes, while documenting the vulnerability in Sentinel notes. Sequence diagram for hardened PDF compilation subprocesssequenceDiagram
participant Generator as CoverLetterGenerator
participant Subprocess as subprocess
participant Pdflatex as pdflatex_process
Generator->>Subprocess: Popen(["pdflatex", "-interaction=nonstopmode", "-no-shell-escape", tex_path.name])
Subprocess-->>Pdflatex: start_process
Generator->>Pdflatex: communicate(timeout=30)
alt TimeoutExpired
Generator->>Pdflatex: kill()
Generator->>Pdflatex: communicate()
Generator-->>Generator: return False
else Completed
Pdflatex-->>Generator: returncode, stdout, stderr
alt success_or_output_path_exists
Generator-->>Generator: pdf_created = True
else failure
Generator->>Subprocess: Popen(["pandoc", tex_path, "-o", output_path, "--pdf-engine=xelatex", "--pdf-engine-opt=-no-shell-escape"])
Subprocess-->>Pdflatex: start_pandoc_process
Generator->>Pdflatex: communicate(timeout=30)
alt TimeoutExpired
Generator->>Pdflatex: kill()
Generator->>Pdflatex: communicate()
Generator-->>Generator: return False
else Completed
Pdflatex-->>Generator: returncode, stdout, stderr
alt success_or_output_path_exists
Generator-->>Generator: pdf_created = True
else failure
Generator-->>Generator: pdf_created = False
end
end
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Co-authored-by: anchapin <6326294+anchapin@users.noreply.github.com>
🚨 Severity: CRITICAL\n💡 Vulnerability: PDF compilation via pdflatex and pandoc lacked restricted execution flags (-no-shell-escape), allowing potential Remote Code Execution (RCE) via
\write18or shell-escape attacks if malicious LaTeX is compiled.\n🎯 Impact: An attacker could execute arbitrary system commands on the server during the PDF generation process.\n🔧 Fix: Added the-no-shell-escapeflag topdflatexand--pdf-engine-opt=-no-shell-escapetopandoccommands incli/pdf/converter.pyandcli/generators/cover_letter_generator.py. Also handledsubprocess.TimeoutExpiredproperly to prevent infinite processes.\n✅ Verification: The modifications prevent RCE and thetest_pdf_security.pytests have passed successfully.PR created automatically by Jules for task 12750106391259952737 started by @anchapin
Summary by Sourcery
Harden PDF generation against remote code execution by sandboxing LaTeX engine subprocesses and enforcing timeouts.
Bug Fixes:
Enhancements: