Skip to content

Commit 23af7c9

Browse files
author
t3tra
authored
Ensure safe ExifTool usage: require >= 12.24 (microsoft#1399)
* feat: add version verification for ExifTool to ensure security compliance * fix: improve ExifTool version verification ---------
1 parent f7337ba commit 23af7c9

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import json
2-
import subprocess
32
import locale
4-
from typing import BinaryIO, Any, Union
3+
import subprocess
4+
from typing import Any, BinaryIO, Union
5+
6+
7+
def _parse_version(version: str) -> tuple:
8+
return tuple(map(int, (version.split("."))))
59

610

711
def exiftool_metadata(
@@ -13,6 +17,24 @@ def exiftool_metadata(
1317
if not exiftool_path:
1418
return {}
1519

20+
# Verify exiftool version
21+
try:
22+
version_output = subprocess.run(
23+
[exiftool_path, "-ver"],
24+
capture_output=True,
25+
text=True,
26+
check=True,
27+
).stdout.strip()
28+
version = _parse_version(version_output)
29+
min_version = (12, 24)
30+
if version < min_version:
31+
raise RuntimeError(
32+
f"ExifTool version {version_output} is vulnerable to CVE-2021-22204. "
33+
"Please upgrade to version 12.24 or later."
34+
)
35+
except (subprocess.CalledProcessError, ValueError) as e:
36+
raise RuntimeError("Failed to verify ExifTool version.") from e
37+
1638
# Run exiftool
1739
cur_pos = file_stream.tell()
1840
try:

0 commit comments

Comments
 (0)