π‘οΈ Sentinel: [HIGH] Fix Inconsistent LaTeX RCE & DoS Mitigation#397
π‘οΈ Sentinel: [HIGH] Fix Inconsistent LaTeX RCE & DoS Mitigation#397anchapin wants to merge 1 commit into
Conversation
Added `-no-shell-escape` flags and strict 30-second `timeout` handling to `subprocess.Popen` calls in `cli/pdf/converter.py` and `cli/generators/cover_letter_generator.py` to prevent Command Execution and Denial of Service attacks when compiling LaTeX via pdflatex or pandoc. 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. |
π¨ Severity: HIGH
π‘ Vulnerability:
CoverLetterGeneratorandPDFConverterexecutepdflatexandpandocusingsubprocess.Popenbut fail to enforce-no-shell-escapeand processing timeouts. These mitigations were present inTemplateGeneratorbut inconsistently missed here.π― Impact: This allows malicious user input (e.g.,
\write18) or AI hallucinations injected into the LaTeX source to result in Remote Code Execution (RCE) on the host machine. Furthermore, intentionally complex or recursive LaTeX payloads could cause the underlying subprocess to hang indefinitely, resulting in a Denial of Service (DoS) by exhausting server resources.π§ Fix: Added
-no-shell-escape(for pdflatex) and--pdf-engine-opt=-no-shell-escape(for pandoc) to the arguments. Applied a strict 30-secondtimeoutto thecommunicate()calls and implemented robust explicit cleanup (catchingTimeoutExpired, executingkill(), and callingcommunicate()again). Symmetrically applied these fixes to both missing modules.β Verification: Ran the full test suite (
pytest) successfully. Added new robust unittests totests/test_pdf_security.pyusingsubprocess.Popenmocks and environment patches to explicitly verify process timeouts are handled and security flags are passed intoCoverLetterGeneratorandPDFConverter. Verified via localblackandflake8execution.PR created automatically by Jules for task 5980168402611118692 started by @anchapin