Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix Remote Code Execution in PDF Compilers - #425

Open
anchapin wants to merge 1 commit into
mainfrom
sentinel/fix-rce-pdf-compilers-2547036225237175064
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix Remote Code Execution in PDF Compilers#425
anchapin wants to merge 1 commit into
mainfrom
sentinel/fix-rce-pdf-compilers-2547036225237175064

Conversation

@anchapin

@anchapin anchapin commented Jul 22, 2026

Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL \n πŸ’‘ Vulnerability: Missing shell escape restrictions in pdflatex and pandoc commands allowed potential Remote Code Execution (RCE). \n 🎯 Impact: An attacker could execute arbitrary system commands if malicious LaTeX code was provided. \n πŸ”§ Fix: Added `-no-shell-escape` and `--pdf-engine-opt=-no-shell-escape` flags to subprocess commands. \n βœ… Verification: Verified arguments are passed correctly to subprocess.Popen.


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

Summary by Sourcery

Harden PDF compilation to prevent remote code execution via LaTeX shell escapes.

Bug Fixes:

  • Disable shell escape in pdflatex invocations for both cover letter generation and generic PDF conversion to mitigate RCE risk.
  • Disable shell escape in pandoc-based PDF generation by passing restrictive engine options to prevent execution of arbitrary commands.

Documentation:

  • Expand Sentinel security log with a new entry describing the RCE vulnerability in PDF compilers and the mitigation strategy.

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 22, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds hardened invocation of pdflatex and pandoc by explicitly disabling shell escapes to mitigate a critical RCE risk, and documents the incident in the Sentinel security notes.

Sequence diagram for hardened PDF compilation with disabled shell escape

sequenceDiagram
    participant CoverLetterGenerator
    participant PdfConverter
    participant pdflatex
    participant pandoc

    CoverLetterGenerator->>pdflatex: subprocess.Popen(["pdflatex","-interaction=nonstopmode","-no-shell-escape",tex_path.name])
    alt pdflatex_fails
        CoverLetterGenerator->>pandoc: subprocess.Popen(["pandoc",tex_path,"-o",output_path,"--pdf-engine=xelatex","--pdf-engine-opt=-no-shell-escape"])
    end

    PdfConverter->>pdflatex: subprocess.Popen(["pdflatex","-interaction=nonstopmode","-no-shell-escape",tex_path.name])
    alt pdflatex_fails
        PdfConverter->>pandoc: subprocess.Popen(["pandoc",tex_path,"-o",output_path,"--pdf-engine=xelatex","--pdf-engine-opt=-no-shell-escape"])
    end
Loading

File-Level Changes

Change Details Files
Harden LaTeX PDF compilation commands to disable shell escapes and mitigate RCE.
  • Add -no-shell-escape flag to all pdflatex subprocess.Popen invocations used for PDF generation.
  • Extend pandoc subprocess.Popen invocations to pass --pdf-engine-opt=-no-shell-escape along with the existing --pdf-engine=xelatex option.
  • Preserve existing subprocess configuration (stdout/stderr pipes, cwd/working_dir) while only modifying argument lists and adding clarifying comments about the security rationale.
cli/generators/cover_letter_generator.py
cli/pdf/converter.py
Document the RCE vulnerability and mitigation in the Sentinel security log.
  • Append a new dated entry describing the missing shell-escape restrictions in PDF compilers as a critical RCE issue.
  • Record key learning that external tools must have unsafe features explicitly disabled.
  • Document the prevention guidance to always pass -no-shell-escape/--pdf-engine-opt=-no-shell-escape when compiling PDFs.
.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 command constructions are now duplicated in two modules with the same security options; consider centralizing them in a shared helper to avoid drift if flags need to change again.
  • If there are environments that legitimately rely on LaTeX shell-escape, it may be worth making the -no-shell-escape behavior explicitly configurable (with a very secure default) rather than hard-coding it in the command.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The pdflatex and pandoc command constructions are now duplicated in two modules with the same security options; consider centralizing them in a shared helper to avoid drift if flags need to change again.
- If there are environments that legitimately rely on LaTeX shell-escape, it may be worth making the `-no-shell-escape` behavior explicitly configurable (with a very secure default) rather than hard-coding it in the command.

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.

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