CVE-2025-67720
Pyrofork has a Path Traversal in download_media Method
Pyrofork is a modern, asynchronous MTProto API framework. Versions 2.3.68 and earlier do not properly sanitize filenames received from Telegram messages in the download_media method before using them in file path construction. When downloading media, if the user does not specify a custom filename (which is the common/default usage), the method falls back to using the file_name attribute from the media object. The attribute originates from Telegram's DocumentAttributeFilename and is controlled by the message sender. This issue is fixed in version 2.3.69.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- None
- User interaction
- Required
What an attacker can affect
- Confidentiality
- None
- Integrity
- High
- Availability
- None
Exploit likelihood
What each source reports
CVE List Score used
6.5
Pyrofork has a Path Traversal in download_media Method
Pyrofork is a modern, asynchronous MTProto API framework. Versions 2.3.68 and earlier do not properly sanitize filenames received from Telegram messages in the download_media method before using them in file path construction. When downloading media, if the user does not specify a custom filename (which is the common/default usage), the method falls back to using the file_name attribute from the media object. The attribute originates from Telegram's DocumentAttributeFilename and is controlled by the message sender. This issue is fixed in version 2.3.69.
- Record
CVE-2025-67720- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-22
- Updated
- 2026-11-02
EUVDEUVD-2025-202593
6.5
Pyrofork is a modern, asynchronous MTProto API framework. Versions 2.3.68 and earlier do not properly sanitize filenames received from Telegram messages in the download_media method before using them in file path construction. When downloading media, if the user does not specify a custom filename (which is the common/default usage), the method falls back to using the file_name attribute from the media object. The attribute originates from Telegram's DocumentAttributeFilename and is controlled by the message sender. This issue is fixed in version 2.3.69.
- Record
EUVD-2025-202593- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-6h2f-wjhf-4wjx
6.5
Pyrofork has a Path Traversal in download_media Method
Summary
The download_media method in Pyrofork does not sanitize filenames received from Telegram messages before using them in file path construction. This allows a remote attacker to write files to arbitrary locations on the filesystem by sending a specially crafted document with path traversal sequences (e.g., ../) or absolute paths in the filename.
Details
When downloading media, if the user does not specify a custom filename (which is the common/default usage), the method falls back to using the file_name attribute from the media object. This attribute originates from Telegram's DocumentAttributeFilename and is controlled by the message sender.
Vulnerable Code Path
Step 1: In pyrogram/methods/messages/download_media.py (lines 145-151):
media_file_name = getattr(media, "file_name", "") # Value from Telegram message
directory, file_name = os.path.split(file_name) # Split user's path parameter
file_name = file_name or media_file_name or "" # Falls back to media_file_name if empty
When a user calls download_media(message) or download_media(message, "downloads/"), the os.path.split() returns an empty filename, causing the code to use media_file_name which is attacker-controlled.
Step 2: In pyrogram/client.py (line 1125):
temp_file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name))) + ".temp"
The os.path.join() function does not prevent path traversal. When file_name contains ../ sequences or is an absolute path, it allows writing outside the intended download directory.
Why the existing isabs check is insufficient
The check at line 153 in download_media.py:
if not os.path.isabs(file_name):
directory = self.PARENT_DIR / (directory or DEFAULT_DOWNLOAD_DIR)
This check only handles absolute paths by skipping the directory prefix, but:
- For relative paths with
../,os.path.isabs()returnsFalse, so the check doesn't catch it - For absolute paths,
os.path.join()in the next step will still use the absolute path directly
PoC
The following Python script demonstrates the vulnerability by simulating the exact code logic from download_media.py and client.py:
#!/usr/bin/env python3
"""
Path Traversal PoC for Pyrofork download_media
Demonstrates CWE-22 vulnerability in filename handling
"""
import os
import shutil
import tempfile
from pathlib import Path
from dataclasses import dataclass
@dataclass
class MockDocument:
"""Simulates a Telegram Document with attacker-controlled file_name"""
file_id: str
file_name: str # Attacker-controlled!
@dataclass
class MockMessage:
"""Simulates a Telegram Message"""
document: MockDocument
DEFAULT_DOWNLOAD_DIR = "downloads/"
def vulnerable_download_media(parent_dir, message, file_name=DEFAULT_DOWNLOAD_DIR):
"""
Simulates the vulnerable logic from:
- pyrogram/methods/messages/download_media.py (lines 145-154)
- pyrogram/client.py (line 1125)
"""
media = message.document
media_file_name = getattr(media, "file_name", "")
# Line 150-151: Split and fallback
directory, file_name = os.path.split(file_name)
file_name = file_name or media_file_name or ""
# Line 153-154: isabs check (insufficient!)
if not os.path.isabs(file_name):
directory = parent_dir / (directory or DEFAULT_DOWNLOAD_DIR)
if not file_name:
file_name = "generated_file.bin"
# Line 1125 in client.py: Path construction
import re
temp_file_path = os.path.abspath(
re.sub("\\\\", "/", os.path.join(str(directory), file_name))
) + ".temp"
return temp_file_path
def run_poc():
print("=" * 60)
print("PYROFORK PATH TRAVERSAL PoC")
print("=" * 60)
with tempfile.TemporaryDirectory() as temp_base:
parent_dir = Path(temp_base)
expected_dir = str(parent_dir / "downloads")
…
- Record
GHSA-6h2f-wjhf-4wjx- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-22
- Updated
- 2026-11-02
NVD
6.5
Pyrofork is a modern, asynchronous MTProto API framework. Versions 2.3.68 and earlier do not properly sanitize filenames received from Telegram messages in the download_media method before using them in file path construction. When downloading media, if the user does not specify a custom filename (which is the common/default usage), the method falls back to using the file_name attribute from the media object. The attribute originates from Telegram's DocumentAttributeFilename and is controlled by the message sender. This issue is fixed in version 2.3.69.
- Record
CVE-2025-67720- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-22
- Updated
- 2026-11-02
OSV
6.5
Pyrofork has a Path Traversal in download_media Method
Pyrofork is a modern, asynchronous MTProto API framework. Versions 2.3.68 and earlier do not properly sanitize filenames received from Telegram messages in the download_media method before using them in file path construction. When downloading media, if the user does not specify a custom filename (which is the common/default usage), the method falls back to using the file_name attribute from the media object. The attribute originates from Telegram's DocumentAttributeFilename and is controlled by the message sender. This issue is fixed in version 2.3.69.
- Record
CVE-2025-67720- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-22
- Updated
- 2026-11-02
OSVGHSA-6h2f-wjhf-4wjx
6.5
Pyrofork has a Path Traversal in download_media Method
Summary
The download_media method in Pyrofork does not sanitize filenames received from Telegram messages before using them in file path construction. This allows a remote attacker to write files to arbitrary locations on the filesystem by sending a specially crafted document with path traversal sequences (e.g., ../) or absolute paths in the filename.
Details
When downloading media, if the user does not specify a custom filename (which is the common/default usage), the method falls back to using the file_name attribute from the media object. This attribute originates from Telegram's DocumentAttributeFilename and is controlled by the message sender.
Vulnerable Code Path
Step 1: In pyrogram/methods/messages/download_media.py (lines 145-151):
media_file_name = getattr(media, "file_name", "") # Value from Telegram message
directory, file_name = os.path.split(file_name) # Split user's path parameter
file_name = file_name or media_file_name or "" # Falls back to media_file_name if empty
When a user calls download_media(message) or download_media(message, "downloads/"), the os.path.split() returns an empty filename, causing the code to use media_file_name which is attacker-controlled.
Step 2: In pyrogram/client.py (line 1125):
temp_file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name))) + ".temp"
The os.path.join() function does not prevent path traversal. When file_name contains ../ sequences or is an absolute path, it allows writing outside the intended download directory.
Why the existing isabs check is insufficient
The check at line 153 in download_media.py:
if not os.path.isabs(file_name):
directory = self.PARENT_DIR / (directory or DEFAULT_DOWNLOAD_DIR)
This check only handles absolute paths by skipping the directory prefix, but:
- For relative paths with
../,os.path.isabs()returnsFalse, so the check doesn't catch it - For absolute paths,
os.path.join()in the next step will still use the absolute path directly
PoC
The following Python script demonstrates the vulnerability by simulating the exact code logic from download_media.py and client.py:
#!/usr/bin/env python3
"""
Path Traversal PoC for Pyrofork download_media
Demonstrates CWE-22 vulnerability in filename handling
"""
import os
import shutil
import tempfile
from pathlib import Path
from dataclasses import dataclass
@dataclass
class MockDocument:
"""Simulates a Telegram Document with attacker-controlled file_name"""
file_id: str
file_name: str # Attacker-controlled!
@dataclass
class MockMessage:
"""Simulates a Telegram Message"""
document: MockDocument
DEFAULT_DOWNLOAD_DIR = "downloads/"
def vulnerable_download_media(parent_dir, message, file_name=DEFAULT_DOWNLOAD_DIR):
"""
Simulates the vulnerable logic from:
- pyrogram/methods/messages/download_media.py (lines 145-154)
- pyrogram/client.py (line 1125)
"""
media = message.document
media_file_name = getattr(media, "file_name", "")
# Line 150-151: Split and fallback
directory, file_name = os.path.split(file_name)
file_name = file_name or media_file_name or ""
# Line 153-154: isabs check (insufficient!)
if not os.path.isabs(file_name):
directory = parent_dir / (directory or DEFAULT_DOWNLOAD_DIR)
if not file_name:
file_name = "generated_file.bin"
# Line 1125 in client.py: Path construction
import re
temp_file_path = os.path.abspath(
re.sub("\\\\", "/", os.path.join(str(directory), file_name))
) + ".temp"
return temp_file_path
def run_poc():
print("=" * 60)
print("PYROFORK PATH TRAVERSAL PoC")
print("=" * 60)
with tempfile.TemporaryDirectory() as temp_base:
parent_dir = Path(temp_base)
expected_dir = str(parent_dir / "downloads")
…
- Record
GHSA-6h2f-wjhf-4wjx- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N - Weakness
- CWE-22
- Updated
- 2026-11-02
OSVPYSEC-2026-1841
6.5
Pyrofork has a Path Traversal in download_media Method
Summary
The download_media method in Pyrofork does not sanitize filenames received from Telegram messages before using them in file path construction. This allows a remote attacker to write files to arbitrary locations on the filesystem by sending a specially crafted document with path traversal sequences (e.g., ../) or absolute paths in the filename.
Details
When downloading media, if the user does not specify a custom filename (which is the common/default usage), the method falls back to using the file_name attribute from the media object. This attribute originates from Telegram's DocumentAttributeFilename and is controlled by the message sender.
Vulnerable Code Path
Step 1: In pyrogram/methods/messages/download_media.py (lines 145-151):
media_file_name = getattr(media, "file_name", "") # Value from Telegram message
directory, file_name = os.path.split(file_name) # Split user's path parameter
file_name = file_name or media_file_name or "" # Falls back to media_file_name if empty
When a user calls download_media(message) or download_media(message, "downloads/"), the os.path.split() returns an empty filename, causing the code to use media_file_name which is attacker-controlled.
Step 2: In pyrogram/client.py (line 1125):
temp_file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name))) + ".temp"
The os.path.join() function does not prevent path traversal. When file_name contains ../ sequences or is an absolute path, it allows writing outside the intended download directory.
Why the existing isabs check is insufficient
The check at line 153 in download_media.py:
if not os.path.isabs(file_name):
directory = self.PARENT_DIR / (directory or DEFAULT_DOWNLOAD_DIR)
This check only handles absolute paths by skipping the directory prefix, but:
- For relative paths with
../,os.path.isabs()returnsFalse, so the check doesn't catch it - For absolute paths,
os.path.join()in the next step will still use the absolute path directly
PoC
The following Python script demonstrates the vulnerability by simulating the exact code logic from download_media.py and client.py:
#!/usr/bin/env python3
"""
Path Traversal PoC for Pyrofork download_media
Demonstrates CWE-22 vulnerability in filename handling
"""
import os
import shutil
import tempfile
from pathlib import Path
from dataclasses import dataclass
@dataclass
class MockDocument:
"""Simulates a Telegram Document with attacker-controlled file_name"""
file_id: str
file_name: str # Attacker-controlled!
@dataclass
class MockMessage:
"""Simulates a Telegram Message"""
document: MockDocument
DEFAULT_DOWNLOAD_DIR = "downloads/"
def vulnerable_download_media(parent_dir, message, file_name=DEFAULT_DOWNLOAD_DIR):
"""
Simulates the vulnerable logic from:
- pyrogram/methods/messages/download_media.py (lines 145-154)
- pyrogram/client.py (line 1125)
"""
media = message.document
media_file_name = getattr(media, "file_name", "")
# Line 150-151: Split and fallback
directory, file_name = os.path.split(file_name)
file_name = file_name or media_file_name or ""
# Line 153-154: isabs check (insufficient!)
if not os.path.isabs(file_name):
directory = parent_dir / (directory or DEFAULT_DOWNLOAD_DIR)
if not file_name:
file_name = "generated_file.bin"
# Line 1125 in client.py: Path construction
import re
temp_file_path = os.path.abspath(
re.sub("\\\\", "/", os.path.join(str(directory), file_name))
) + ".temp"
return temp_file_path
def run_poc():
print("=" * 60)
print("PYROFORK PATH TRAVERSAL PoC")
print("=" * 60)
with tempfile.TemporaryDirectory() as temp_base:
parent_dir = Path(temp_base)
expected_dir = str(parent_dir / "downloads")
…
- Record
PYSEC-2026-1841- CVSS 3.1
- 6.5 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N - Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
pyroforkPyPI |
through 2.3.68 | 2.3.69 |
pyroforkPyPI |
before 2.3.69, plus listed versions 2.1.32.1.42.1.4.dev2023032037212.1.52.1.6 Show 45 moreShow less2.1.72.1.82.2.02.2.12.2.102.2.112.2.22.2.32.2.42.2.52.2.62.2.72.2.82.2.92.3.02.3.12.3.102.3.112.3.11.post12.3.11.post22.3.11.post32.3.11.post42.3.11.post52.3.11.post62.3.122.3.12.post12.3.132.3.13.post12.3.142.3.14.post12.3.14.post22.3.152.3.15.post12.3.15.post22.3.15.post32.3.15.post42.3.15.post52.3.162.3.16.post12.3.16.post22.3.16.post32.3.16.post42.3.16.post52.3.172.3.17.post1 |
2.3.69 |
History
| Recorded | Changed | Sources |
|---|---|---|
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2025-67720 is a medium vulnerability (CVSS 6.5) in Mayuri-chan Pyrofork, published December 10, 2025. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.32%, the 24th percentile. Fixed in pyrofork 2.3.69.
References
github.com/Mayuri-Chan/pyrofork/security/advisories/GHSA-6h2f-wjhf-4wjx
github.com/Mayuri-Chan/pyrofork/commit/2f2d515575cc9c360bd74340a61a1d2b1e1f1f95
nvd.nist.gov/vuln/detail/CVE-2025-67720
github.com/advisories/GHSA-6h2f-wjhf-4wjx
github.com/CVEProject/cvelistV5/tree/main/cves/2025/67xxx/CVE-2025-67720.json
github.com/Mayuri-Chan/pyrofork
pypi.org/project/pyrofork
Left out here: 78 versions and the rest of 3 source descriptions. The JSON record has them.