Repository navigation
Conversation
Applied `-no-shell-escape` to `pdflatex` and `--pdf-engine-opt=-no-shell-escape` to `pandoc` in `cli/pdf/converter.py` and `cli/generators/cover_letter_generator.py` to prevent Remote Code Execution (RCE) vulnerabilities from malicious LaTeX control characters. Also added explicit timeout handling for compilation subprocesses to fail securely on timeout. 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 LaTeX/PDF compilation by disabling shell escape in pdflatex/pandoc and introducing timeouts for the external processes, plus documenting the security issue in Sentinel notes. Flow diagram for hardened LaTeX PDF compilation with no shell escape and timeoutsflowchart TD
start([Start _compile_pdf])
try_pdflatex["Call subprocess.Popen pdflatex -interaction=nonstopmode -no-shell-escape"]
pdflatex_comm["process.communicate(timeout=30)"]
pdflatex_timeout{TimeoutExpired?}
pdflatex_kill["process.kill() and process.communicate()"]
pdflatex_fail["Return False"]
pdflatex_success{pdflatex success or output_path exists?}
set_pdf_true["pdf_created = True"]
fallback_needed{Need pandoc fallback?}
try_pandoc["Call subprocess.Popen pandoc --pdf-engine=xelatex --pdf-engine-opt=-no-shell-escape"]
pandoc_comm["process.communicate(timeout=30)"]
pandoc_timeout{TimeoutExpired?}
pandoc_kill["process.kill() and process.communicate()"]
pandoc_fail["Return False"]
pandoc_success{pandoc success or output_path exists?}
set_pdf_true_fallback["pdf_created = True"]
end_node([End _compile_pdf])
start --> try_pdflatex --> pdflatex_comm --> pdflatex_timeout
pdflatex_timeout -- Yes --> pdflatex_kill --> pdflatex_fail
pdflatex_timeout -- No --> pdflatex_success
pdflatex_success -- Yes --> set_pdf_true --> end_node
pdflatex_success -- No --> fallback_needed
fallback_needed -- Yes --> try_pandoc --> pandoc_comm --> pandoc_timeout
pandoc_timeout -- Yes --> pandoc_kill --> pandoc_fail
pandoc_timeout -- No --> pandoc_success
pandoc_success -- Yes --> set_pdf_true_fallback --> end_node
pandoc_success -- No --> end_node
fallback_needed -- No --> end_node
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
🚨 Severity: CRITICAL
💡 Vulnerability: PDF compilation commands lacked restricted execution flags (
-no-shell-escape), allowing malicious LaTeX input to execute arbitrary system commands via shell escape.🎯 Impact: An attacker could achieve Remote Code Execution (RCE) on the server.
🔧 Fix: Applied
-no-shell-escapetopdflatexand--pdf-engine-opt=-no-shell-escapetopandoc. Added process timeout handling to fail securely.✅ Verification: Tested PDF compilation functions to ensure flags are correctly applied and fallbacks work on timeout.
PR created automatically by Jules for task 9643023613464355314 started by @anchapin
Summary by Sourcery
Harden LaTeX-based PDF generation against command execution and hangs by restricting shell access and enforcing timeouts on compilation processes.
Bug Fixes:
Documentation: