Skip to content

fix: sanitize subprocess call in _exiftool.py#1671

Open
orbisai0security wants to merge 1 commit intomicrosoft:mainfrom
orbisai0security:fix-fix-v-001-exiftool-subprocess-path-validation
Open

fix: sanitize subprocess call in _exiftool.py#1671
orbisai0security wants to merge 1 commit intomicrosoft:mainfrom
orbisai0security:fix-fix-v-001-exiftool-subprocess-path-validation

Conversation

@orbisai0security
Copy link
Copy Markdown

Summary

Fix critical severity security issue in packages/markitdown/src/markitdown/converters/_exiftool.py.

Vulnerability

Field Value
ID V-001
Severity CRITICAL
Scanner multi_agent_ai
Rule V-001
File packages/markitdown/src/markitdown/converters/_exiftool.py:41
CWE CWE-22

Description: The ExifTool converter passes user-controlled file paths to subprocess.run() without proper validation. While the code uses a list format (not shell=True), the local_path variable comes from user input and could contain malicious filenames. If the file path contains special characters or is manipulated through path traversal, it could lead to unintended file access or command execution through ExifTool's own command parsing.

Changes

  • packages/markitdown/src/markitdown/converters/_exiftool.py

Verification

  • Build not verified
  • Scanner re-scan not performed
  • LLM code review not performed

Automated security fix by OrbisAI Security

Automated security fix generated by Orbis Security AI
Copy link
Copy Markdown

@VANDRANKI VANDRANKI left a comment

Choose a reason for hiding this comment

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

Solid security improvement. Three things work together here:

  1. shutil.which() + os.realpath() resolves the path to an absolute canonical path before it reaches subprocess. This prevents symlink-based path manipulation and catches cases where the path looks valid but does not resolve to an executable.

  2. -- separator before - in the exiftool invocation. Without this, a filename starting with - could be interpreted as a flag. Passing content via stdin with - was already safe, but the -- makes the intent explicit.

  3. timeout=30 on the version check subprocess call, with subprocess.TimeoutExpired added to the except clause. The main subprocess call - is there a timeout on that too? Large files passed via stdin could hang indefinitely if exiftool stalls. Worth adding the same timeout there.

Otherwise LGTM.

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