Skip to content

fix: prevent path traversal in LaTeX macro handlers#3330

Merged
PeterStaar-IBM merged 2 commits intomainfrom
fix/latex-resolve-path
Apr 21, 2026
Merged

fix: prevent path traversal in LaTeX macro handlers#3330
PeterStaar-IBM merged 2 commits intomainfrom
fix/latex-resolve-path

Conversation

@ceberam
Copy link
Copy Markdown
Member

@ceberam ceberam commented Apr 20, 2026

Summary

This PR adds path containment checks to prevent path traversals in the LaTeX backend and includes minor code style improvements.

Path checks

  • Added path containment checks for \includegraphics and \input/\include macro handlers
  • Prevents directory traversal attacks by validating that resolved paths stay within the base directory using is_relative_to()
  • Logs warnings when path traversal attempts are detected

Code Style Improvements

  • Removed unnecessary imports in LaTeX backend
  • Replaced deprecated typing.List with modern list syntax

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

ceberam added 2 commits April 20, 2026 14:34
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
@ceberam ceberam requested review from dolfim-ibm and vagenas April 20, 2026 12:42
@ceberam ceberam added the bug Something isn't working label Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @ceberam, all your commits are properly signed off. 🎉

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 20, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 41.17647% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/backend/latex/handlers/macros.py 41.17% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ceberam ceberam self-assigned this Apr 21, 2026
@PeterStaar-IBM PeterStaar-IBM merged commit 65ef180 into main Apr 21, 2026
26 of 27 checks passed
@PeterStaar-IBM PeterStaar-IBM deleted the fix/latex-resolve-path branch April 21, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants