🛡️ Sentinel: [CRITICAL] Fix pdflatex RCE and DoS mitigation in PDF compilation#375
Conversation
…mpilation 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. |
🚨 Severity: CRITICAL
💡 Vulnerability:
The PDF compilation functions in
cli/pdf/converter.pyandcli/generators/cover_letter_generator.pyexecutedpdflatexandpandocwithout strict sandboxing (-no-shell-escape) and without timeouts in theirsubprocess.communicate()calls.🎯 Impact:
\write18{...}) could execute arbitrary shell commands on the host system because LaTeX shells are permitted by default.communicate(), maliciously crafted.texfiles designed to loop infinitely could hang the compilation process indefinitely, leading to resource exhaustion.🔧 Fix:
-no-shell-escapeflag to the primarypdflatexcalls and--pdf-engine-opt=-no-shell-escapeto the fallbackpandoccalls.subprocess.communicate()calls, gracefully catchingsubprocess.TimeoutExpired, terminating the hung process (kill()), clearing the buffers, and returningFalsewithout raising unhandled exceptions or halting application flow.✅ Verification:
tests/test_pdf_security.pyto ensure complete coverage of both PDFConverter and CoverLetterGenerator implementations.PR created automatically by Jules for task 5904571803552083737 started by @anchapin