fix: auto-discover ExifTool installed in subdirectories of trusted paths#1679
Open
octo-patch wants to merge 2 commits intomicrosoft:mainfrom
Open
fix: auto-discover ExifTool installed in subdirectories of trusted paths#1679octo-patch wants to merge 2 commits intomicrosoft:mainfrom
octo-patch wants to merge 2 commits intomicrosoft:mainfrom
Conversation
added 2 commits
April 8, 2026 13:35
…icrosoft#1660) Previously ExifTool was only auto-discovered if found directly in a trusted directory (e.g. C:\Program Files). Common Windows installs place the binary one level deeper (C:\Program Files\ExifTool\exiftool.exe), so dirname returned a path that failed the exact-equality check and ExifTool was silently not used. Switch to startswith(d + os.sep) to allow subdirectory matches while keeping the exact-match check, preserving the security boundary. Also add C:\Windows as a trusted root since ExifTool is sometimes installed there directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1660
Problem
When MarkItDown auto-discovers ExifTool via
shutil.which("exiftool"), it verifies that the binary resides in a known trusted directory to prevent running arbitrary executables. The check used an exact directory comparison:However, a common Windows installation places ExifTool one level deeper than the trusted root, for example:
Here
os.path.dirname(candidate)returnsC:\Program Files\ExifTool, which does not equal the trusted entryC:\Program Files, so ExifTool is silently skipped. The user then gets metadata-lite image output with no error message explaining why.Solution
Replace the exact-equality check with a two-part check:
This allows binaries installed in any subdirectory of a trusted root to be auto-discovered, while still rejecting paths outside the trusted roots (e.g.
C:\Users\username\Downloads).Additionally adds
C:\Windowsas a trusted root, since some users place ExifTool directly there.Testing
C:\Program Files\ExifTool\exiftool.exe→ trusted ✓/opt/homebrew/Cellar/exiftool/12.90/bin/exiftool→ trusted ✓C:\Users\user\Downloads\exiftool.exe→ not trusted ✓