Skip to content

Comments

feat(security): add timeout to PDF compilation subprocesses#144

Open
anchapin wants to merge 3 commits intomainfrom
sentinel-pdf-generation-timeout-11471057020964618685
Open

feat(security): add timeout to PDF compilation subprocesses#144
anchapin wants to merge 3 commits intomainfrom
sentinel-pdf-generation-timeout-11471057020964618685

Conversation

@anchapin
Copy link
Owner

🛡️ Sentinel: [MEDIUM] Add timeout to PDF compilation to prevent DoS

Vulnerability:
The pdflatex and pandoc commands were executed using subprocess.Popen().communicate() without a timeout. In certain scenarios (e.g., waiting for user input, infinite loops in TeX), this could cause the process to hang indefinitely, leading to a Denial of Service (DoS) condition.

Fix:

  • Added timeout=30 to process.communicate() calls in cli/generators/template.py.
  • Added shell=False to subprocess.Popen calls for explicit security.
  • Added exception handling for subprocess.TimeoutExpired to kill the process and raise a descriptive RuntimeError.

Verification:

  • Added tests/test_template_generator_security.py which mocks subprocess.Popen to simulate a timeout and verifies that the process is killed and the correct exception is raised.
  • Verified that existing tests pass.

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

Add a 30-second timeout to `pdflatex` and `pandoc` subprocess calls in `TemplateGenerator` to prevent indefinite hanging (DoS risk). Explicitly set `shell=False` for security. Added `tests/test_template_generator_security.py` to verify the fix.

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

@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

google-labs-jules bot and others added 2 commits February 20, 2026 00:39
Add a 30-second timeout to `pdflatex` and `pandoc` subprocess calls in `TemplateGenerator` to prevent indefinite hanging (DoS risk). Explicitly set `shell=False` for security. Added `tests/test_template_generator_security.py` to verify the fix and ensured it is formatted with black.

Co-authored-by: anchapin <6326294+anchapin@users.noreply.github.com>
Add a 30-second timeout to `pdflatex` and `pandoc` subprocess calls in `TemplateGenerator` to prevent indefinite hanging (DoS risk). Explicitly set `shell=False` for security. Added `tests/test_template_generator_security.py` to verify the fix and ensured it complies with black, isort, and ruff formatting standards.

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