Skip to content

fix(pptx): limit the decompressed size of PPTX archive members - #5113

Merged
dolfim-ibm merged 1 commit into
docling-project:mainfrom
hktitof:fc172-hunt
Nov 19, 2026
Merged

dolfim-ibm merged 1 commit into
docling-project:mainfrom
hktitof:fc172-hunt

Conversation

@hktitof

@hktitof hktitof commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

what this fixes

a .pptx file is a ZIP archive, same as docx and xlsx, python-pptx decompresses the package members while it loads them and there was no check of the declared sizes for PPTX, so a small .pptx can decompress to a very large size in memory

#4977 added that check for docx, xlsx and epub, it did not cover PPTX

what changed

  • MsPowerpointBackendOptions gets max_file_bytes (128 MiB), max_total_bytes (512 MiB) and max_member_count (10,000), the same defaults as the word and excel backends
  • MsPowerpointDocumentBackend calls check_archive_limits() before Presentation(), so a file over a limit fails with ArchiveLimitError (a DocumentLoadError) and no member is read
  • the advanced options page and the python sdk reference now name PPTX in the archive limit section

review evidence

i drove the real converter (DocumentConverter.convert) with a real 78 KB .pptx whose ppt/slides/slide1.xml declares 32,520,093 bytes (about 31 MiB) of decompressed data

input before after
78 KB .pptx, one member declares 31 MiB, limit 1 MiB converted ok, 76.7 MiB peak ArchiveLimitError, 0.2 MiB peak
normal sample deck converted converted, unchanged
the same 32 MiB bomb inside a .docx rejected, 0.1 MiB peak rejected, 0.1 MiB peak

before this change MsPowerpointBackendOptions(max_file_bytes=...) was accepted and then ignored, so the limit looked like it worked and did nothing

test and check commands i ran

pytest tests/test_backend_archive_limits.py -q
23 passed

the pptx backend test files, run on master and on this branch
9 failed on both trees, all of them local rendering and omml cases, so this change adds no regression

ruff check and ruff format on the 3 touched python files
clean

Checklist:

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

note

check-collision reports file overlap only, with 21 open PRs (#5085 #5082 #5063 #5057 #5017 #5005 #4880 #4844 #4815 #4781 #4752 #4716 #4689 #4546 #4443 #4148 #4144 #3978 #3891 #3803 #3791), none of them is about archive size limits, most of them only touch the docs, the overlap is mechanical

@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

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)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working error-handling pptx issue related to pptx backend labels Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 16def335ac. The analysis read the diff only. It did not run code from this pull request.

The PR adds decompressed-size limits for PPTX archives. MsPowerpointDocumentBackend now calls check_archive_limits() before Presentation(). MsPowerpointBackendOptions gets max_file_bytes, max_total_bytes and max_member_count. The docs and tests are updated.

CI safety: no concern found. A maintainer must still approve CI.

2 related pull request(s) in the same code
PR State Signal Assessment
#5377 open changes the same code related: It edits the same backend file, but it only serializes PDFium rendering with a lock. It adds no archive limits.
#3707 open changes the same code related: It adds macro detection with warn_if_macros in the same __init__. It does not add any size limits.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI first review (advisory): no blocker found

This review covers the full diff at 0fec429e5a. It read the code and did not run it.

I found no defect. docling/backend/mspowerpoint_backend.py now checks the archive limits the same way docling/backend/msexcel_backend.py does, and the new options match the Word and Excel options. The check runs before Presentation(), rewinds a BytesIO stream after the check, and re-raises ArchiveLimitError before the generic DocumentLoadError wrapper. The parametrized PPTX tests in tests/test_backend_archive_limits.py test the real defect for both path and stream input. They use a real sample deck, an inflated member, and an assertion on the rejection cause.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 30, 2026
@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

A PPTX package is a ZIP archive. python-pptx decompresses its members while it
loads them, without a check of the declared sizes, so a small file can
decompress to a very large size. DOCX and XLSX packages already have this
check (see docling-project#4977).

A PPTX file now fails to load with ArchiveLimitError, before python-pptx reads
any member, when one member, the whole package or the member count exceeds the
limit. MsPowerpointBackendOptions gets max_file_bytes (128 MiB),
max_total_bytes (512 MiB) and max_member_count (10,000).

Signed-off-by: Abdel <62770500+hktitof@users.noreply.github.com>
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) and removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Nov 15, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI first review (advisory): no blocker found

This review covers the full diff at 16def335ac. It read the code and did not run it.

I found no defect that blocks the merge. The check in docling/backend/mspowerpoint_backend.py runs before Presentation(). It uses the shared check_archive_limits helper, the same as the Word backend. ArchiveLimitError is re-raised before the generic except Exception can wrap it. The new options and their defaults match the DOCX/XLSX options. The PPTX cases in tests/test_backend_archive_limits.py reuse the existing parametrized tests, including the converter-level test.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Nov 15, 2026

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@dolfim-ibm
dolfim-ibm merged commit 587d121 into docling-project:main Nov 19, 2026
34 checks passed
@hktitof

hktitof commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge @dolfim-ibm, glad this fix is in now, cheers!

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

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working error-handling pptx issue related to pptx backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants