Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix LaTeX shell escape RCE - #431

Open
anchapin wants to merge 3 commits into
mainfrom
sentinel-fix-latex-rce-15206891120435747647
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix LaTeX shell escape RCE#431
anchapin wants to merge 3 commits into
mainfrom
sentinel-fix-latex-rce-15206891120435747647

Conversation

@anchapin

@anchapin anchapin commented Jul 25, 2026

Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: Missing flags allowed arbitrary shell command execution if malicious LaTeX was injected.
🎯 Impact: Prevents RCE and protects the system from arbitrary command execution.
πŸ”§ Fix: Disabled shell escapes in pdflatex and pandoc during PDF compilation.
βœ… Verification: Verified via unit tests that compilation proceeds successfully while blocking shell escapes.


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

Summary by Sourcery

Harden LaTeX-based PDF generation against remote code execution by disabling shell escapes in all compilation paths and documenting the vulnerability and its mitigation in Sentinel notes.

Bug Fixes:

  • Disable LaTeX shell escapes in pdflatex and pandoc-based PDF compilation to prevent arbitrary command execution when handling untrusted LaTeX content.

Documentation:

  • Add Sentinel security note describing the LaTeX shell escape RCE vulnerability, its risks, and required compilation flags to prevent it.

Disabled LaTeX shell escapes to prevent arbitrary command execution via maliciously injected LaTeX code during PDF compilation. Added `-no-shell-escape` for pdflatex and `--pdf-engine-opt=-no-shell-escape` for pandoc.

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.

@sourcery-ai

sourcery-ai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR hardens PDF generation by explicitly disabling LaTeX shell escapes for both pdflatex and pandoc-based compilation paths, and documents the vulnerability and its mitigation in the Sentinel security log.

Sequence diagram for hardened LaTeX PDF compilation

sequenceDiagram
    participant CoverLetterGenerator
    participant subprocess
    participant pdflatex
    participant pandoc

    CoverLetterGenerator->>subprocess: Popen(["pdflatex", "-interaction=nonstopmode", "-no-shell-escape", tex_path.name])
    subprocess->>pdflatex: execute pdflatex
    pdflatex-->>CoverLetterGenerator: returncode

    alt pdflatex_success
        CoverLetterGenerator-->>CoverLetterGenerator: use pdflatex PDF output
    else pdflatex_failure
        CoverLetterGenerator->>subprocess: Popen(["pandoc", tex_path, "-o", output_path, "--pdf-engine=xelatex", "--pdf-engine-opt=-no-shell-escape"]) 
        subprocess->>pandoc: execute pandoc
        pandoc-->>CoverLetterGenerator: returncode
    end
Loading

File-Level Changes

Change Details Files
Disable LaTeX shell escapes during pdflatex and pandoc compilation in the cover letter generator.
  • Add -no-shell-escape flag to pdflatex invocation when compiling cover letters.
  • Add --pdf-engine-opt=-no-shell-escape to pandoc invocation using xelatex as the pdf engine.
  • Update inline comments to highlight RCE prevention via disabled shell-escape flags.
cli/generators/cover_letter_generator.py
Disable LaTeX shell escapes during pdflatex and pandoc compilation in the generic PDF converter.
  • Add -no-shell-escape flag to pdflatex invocation in the converter.
  • Add --pdf-engine-opt=-no-shell-escape to pandoc invocation in the converter.
  • Update inline comments to clarify intent to block LaTeX-based RCE via shell escapes.
cli/pdf/converter.py
Document the LaTeX shell escape RCE vulnerability and its mitigation in the Sentinel security record.
  • Add a new Sentinel entry describing the missing -no-shell-escape flag vulnerability in LaTeX compilation.
  • Explain why LaTeX compilation on untrusted input is unsafe without shell escape restrictions.
  • Record preventive guidance to always pass -no-shell-escape for pdflatex and corresponding options for pandoc, with caveat for non-compilation utility commands.
.jules/sentinel.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The pdflatex and pandoc invocation arguments are now duplicated in multiple places; consider centralizing command construction (e.g., a helper that injects the -no-shell-escape / --pdf-engine-opt flags) to keep the shell-escape policy consistent and easier to maintain.
  • If there are any other LaTeX compilation paths in the codebase (e.g., different generators or utilities), it would be worth checking that they also explicitly pass -no-shell-escape / --pdf-engine-opt=-no-shell-escape to avoid inconsistent hardening.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The pdflatex and pandoc invocation arguments are now duplicated in multiple places; consider centralizing command construction (e.g., a helper that injects the `-no-shell-escape` / `--pdf-engine-opt` flags) to keep the shell-escape policy consistent and easier to maintain.
- If there are any other LaTeX compilation paths in the codebase (e.g., different generators or utilities), it would be worth checking that they also explicitly pass `-no-shell-escape` / `--pdf-engine-opt=-no-shell-escape` to avoid inconsistent hardening.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click πŸ‘ or πŸ‘Ž on each comment and I'll use the feedback to improve your reviews.

google-labs-jules Bot and others added 2 commits July 25, 2026 06:04
Disabled LaTeX shell escapes to prevent arbitrary command execution via maliciously injected LaTeX code during PDF compilation. Added `-no-shell-escape` for pdflatex and `--pdf-engine-opt=-no-shell-escape` for pandoc.

Co-authored-by: anchapin <6326294+anchapin@users.noreply.github.com>
Disabled LaTeX shell escapes to prevent arbitrary command execution via maliciously injected LaTeX code during PDF compilation. Added `-no-shell-escape` for pdflatex and `--pdf-engine-opt=-no-shell-escape` for pandoc.

Co-authored-by: anchapin <6326294+anchapin@users.noreply.github.com>
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