Skip to content

TIKA-4861: reject a BigTIFF directory offset that overflows the prefi… - #3130

Merged
tballison merged 4 commits into
apache:mainfrom
tballison:TIKA-4861-follow-ups
Sep 4, 2026
Merged

TIKA-4861: reject a BigTIFF directory offset that overflows the prefi…#3130
tballison merged 4 commits into
apache:mainfrom
tballison:TIKA-4861-follow-ups

Conversation

@tballison

Copy link
Copy Markdown
Contributor

…x bounds check

Thanks for your contribution to Apache Tika! Your help is appreciated!

Before opening the pull request, please verify that

  • there is an open issue on the Tika issue tracker which describes the problem or the improvement. We cannot accept pull requests without an issue because the change wouldn't be listed in the release notes.
  • the issue ID (TIKA-XXXX)
    • is referenced in the title of the pull request
    • and placed in front of your commit messages surrounded by square brackets ([TIKA-XXXX] Issue or pull request title)
  • commits are squashed into a single one (or few commits for larger changes)
  • Tika builds and unit tests pass with ./mvnw clean install (clean test alone cannot resolve the pipes plugin zips)
  • if you used a generative AI tool: follow the ASF Generative Tooling Guidance (Generated-by: <tool> in the commit message), and consider running the pre-flight in .skills/devs/pr-review/SKILL.md — fix what it finds; don't paste its report here
  • there should be no conflicts when merging the pull request branch into the recent main branch. If there are conflicts, please try to rebase the pull request branch on top of a freshly pulled main branch
  • if you add new module that downstream users will depend upon add it to relevant group in tika-bom/pom.xml.

We will be able to faster integrate your pull request if these conditions are met. If you have any questions how to fix your problem or about using Tika in general, please sign up for the Tika mailing list. Thanks!

Copilot AI 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.

🟢 Approval recommended

The change is small, localized, and directly addresses the described overflow failure mode with solid regression coverage.

Pull request overview

Fixes an overflow edge case in RawTiffDetector’s prefix bounds checking so malformed BigTIFF directory offsets near Long.MAX_VALUE cannot wrap negative and incorrectly pass the “already in prefix” fast-path (preventing uncaught runtime exceptions during detection).

Changes:

  • Harden Prefix.ensure(long end) to reject negative (wrapped) end values before comparing against current buffer length.
  • Add targeted regression tests for out-of-range BigTIFF directory offsets and for skipping an invalid “next IFD” follower offset.
  • Add a randomized boundary fuzz test for directory-walk offset/count/value arithmetic invariants, and document the fix in CHANGES.txt.
File summaries
File Description
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-image-module/src/main/java/org/apache/tika/detect/image/RawTiffDetector.java Rejects negative/wrapped end in prefix bounds checks to prevent overflow-driven misclassification and exceptions.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-image-module/src/test/java/org/apache/tika/detect/image/RawTiffDetectorTest.java Adds regression coverage for invalid BigTIFF directory offsets and invalid follower offsets.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-image-module/src/test/java/org/apache/tika/detect/image/RawTiffDetectorFuzzTest.java Adds randomized boundary fuzzing to ensure no throwables escape detection across arithmetic edge cases.
CHANGES.txt Adds release note describing the overflow fix and its impact (TIKA-4861).
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tballison
tballison merged commit bea45c9 into apache:main Sep 4, 2026
1 check passed
@tballison
tballison deleted the TIKA-4861-follow-ups branch September 4, 2026 19:10
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.

2 participants