Skip to content

🛡️ Sentinel: [CRITICAL] Fix Remote Code Execution and DoS in PDF Compilation#307

Open
anchapin wants to merge 1 commit into
mainfrom
sentinel/fix-pdflatex-rce-712751419682513836
Open

🛡️ Sentinel: [CRITICAL] Fix Remote Code Execution and DoS in PDF Compilation#307
anchapin wants to merge 1 commit into
mainfrom
sentinel/fix-pdflatex-rce-712751419682513836

Conversation

@anchapin
Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL
💡 Vulnerability: The application executed pdflatex and pandoc via subprocess.Popen without enforcing the -no-shell-escape sandboxing flag or compilation timeouts.
🎯 Impact: An attacker or rogue AI output could inject LaTeX control characters (like \write18) to execute arbitrary shell commands on the host machine, leading to complete server compromise. Additionally, malicious or malformed LaTeX syntax could cause pdflatex to hang indefinitely, causing a Denial of Service (DoS).
🔧 Fix: Added -no-shell-escape to the pdflatex execution parameters (and --pdf-engine-opt=-no-shell-escape for pandoc). Enforced a 30-second timeout on all subprocess.communicate() calls and added explicit process cleanup to prevent zombie processes.
✅ Verification: Ran the full local test suite (python -m pytest), including tests/test_pdf_security.py, to ensure no regressions were introduced and security assertions remain intact.


PR created automatically by Jules for task 712751419682513836 started by @anchapin

…ilation

This commit addresses a critical vulnerability in the PDF compilation logic that permitted Remote Code Execution (RCE) via `\write18` and potential Denial of Service (DoS) due to hanging LaTeX compilations.

Specifically:
- Appended the `-no-shell-escape` flag to the `pdflatex` compilation command in `cover_letter_generator.py` and `converter.py`.
- Appended the `--pdf-engine-opt=-no-shell-escape` flag to the `pandoc` fallback command in `cover_letter_generator.py` and `converter.py`.
- Enforced a 30-second timeout on all `subprocess.communicate()` calls for LaTeX rendering.
- Implemented robust process cleanup (`process.kill()`) in the `TimeoutExpired` exception block to prevent zombie processes.

Co-authored-by: anchapin <6326294+anchapin@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @anchapin, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant