🛡️ Sentinel: [HIGH] Fix PDF compilation RCE vulnerabilities#381
🛡️ Sentinel: [HIGH] Fix PDF compilation RCE vulnerabilities#381anchapin wants to merge 1 commit into
Conversation
… `-no-shell-escape` to `pdflatex` and `--pdf-engine-opt=-no-shell-escape` to `pandoc` to prevent RCE vulnerabilities when rendering LaTeX to PDF. Added a 30-second timeout to `subprocess.communicate()` calls and implemented proper zombie process cleanup upon timeout. These changes span both `cli/pdf/converter.py` and `cli/generators/cover_letter_generator.py` and are thoroughly tested in `tests/test_pdf_security.py`. Co-authored-by: anchapin <[email protected]>
|
👋 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 GuideThis PR hardens all PDF compilation paths by enforcing no-shell-escape flags for pdflatex/pandoc, adding timeouts and cleanup for hanging subprocesses, and backfilling tests and sentinel documentation to cover these security guarantees. Sequence diagram for hardened PDF compilation with no-shell-escape and timeoutssequenceDiagram
participant PdfCompiler
participant Subprocess
participant Pdflatex
participant Pandoc
PdfCompiler->>Subprocess: subprocess.Popen_pdflatex_no_shell_escape
Subprocess->>Pdflatex: run_pdflatex
alt pdflatex_finishes_before_timeout
Pdflatex-->>Subprocess: process.communicate_timeout_30
Subprocess-->>PdfCompiler: pdflatex_success_or_output_path_exists
else pdflatex_hangs_timeout
Subprocess-->>Pdflatex: process.kill
Subprocess-->>PdfCompiler: pdflatex_timeout_failure
PdfCompiler->>Subprocess: subprocess.Popen_pandoc_no_shell_escape
Subprocess->>Pandoc: run_pandoc
alt pandoc_finishes_before_timeout
Pandoc-->>Subprocess: process.communicate_timeout_30
Subprocess-->>PdfCompiler: pandoc_success_or_output_path_exists
else pandoc_hangs_timeout
Subprocess-->>Pandoc: process.kill
Subprocess-->>PdfCompiler: pandoc_timeout_failure
end
end
File-Level Changes
Possibly linked issues
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 subprocess timeout and kill/cleanup logic is duplicated across multiple compilation paths; consider extracting a shared helper/wrapper for running pdflatex/pandoc with consistent flags, timeouts, and error handling.
- The 30-second timeout is hardcoded in several places; using a single configurable constant (or config option) would make it easier to tune and keep consistent across all PDF compilation routines.
- Given the security sensitivity of the no-shell-escape flags, it may be safer to centralize construction of pdflatex/pandoc command arguments so future additions to PDF generation can’t accidentally omit them.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The subprocess timeout and kill/cleanup logic is duplicated across multiple compilation paths; consider extracting a shared helper/wrapper for running pdflatex/pandoc with consistent flags, timeouts, and error handling.
- The 30-second timeout is hardcoded in several places; using a single configurable constant (or config option) would make it easier to tune and keep consistent across all PDF compilation routines.
- Given the security sensitivity of the no-shell-escape flags, it may be safer to centralize construction of pdflatex/pandoc command arguments so future additions to PDF generation can’t accidentally omit them.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
🚨 Severity: HIGH\n💡 Vulnerability: PDF compilation could allow RCE without
-no-shell-escapeand lead to zombie processes without timeout cleanups.\n🎯 Impact: Remote Code Execution or Denial of Service.\n🔧 Fix: Added appropriate flags and timeout cleanup.\n✅ Verification: New security tests added and passing.PR created automatically by Jules for task 18071782307955844015 started by @anchapin
Summary by Sourcery
Harden PDF compilation paths against RCE and hanging processes by enforcing secure engine flags and subprocess timeouts.
Bug Fixes:
Enhancements:
Documentation:
Tests: