T09 · Insecure Skill Coding Practices
- Location
assets/2022年度精选策略.txt:5666- Finding
Unsafe Deserialization of Mutable Research Files
- Content
View full analysis
Vulnerability Details
File Locations:
assets/2022年度精选策略.txt:5666-5669assets/2023年度精选策略.txt:7967assets/2024年度精选策略上.txt:14213-14214assets/2024年度精选策略下.txt:8177-8178assets/2024年度精选策略下.txt:12849assets/2025年度精选策略.txt:6408
Vulnerability Type: Unsafe Python pickle deserialization
Risk Level: HighVulnerable Code
python col = pickle.load(BytesIO(read_file("col_50etf_20191109.dat"))) model = pickle.load(BytesIO(read_file("model_50etf_20191109.dat")))python tmp_df_dic = pickle.loads(read_file('test_predict_300_q.pkl'))python g.model = pickle.loads(read_file('model/xgboost_technical.pkl'))python g.model_zb = pickle.loads(read_file(g.model_zb_path)) g.model_cyb = pickle.loads(read_file(g.model_cyb_path))python g.model = pickle.loads(read_file('model_baseline.pkl'))Technical Analysis
Python's
pickle.load()andpickle.loads()are code-capable deserialization operations. A pickle stream may define reduction functions that invoke arbitrary Python callables during loading. Consequently, loading a pickle is equivalent to executing code supplied by whoever controls the serialized file.The affected strategies read model and data files from JoinQuant research storage without authenticating their contents or restricting the object types that may be reconstructed. The vulnerability becomes exploitable if an attacker can upload, replace, share, or otherwise influence one of the referenced
.pklor.datfiles.Attack Path
- An attacker constructs a malicious pickle whose deserialization routine invokes an arbitrary Python callable.
- The attacker causes the malicious file to be stored under a referenced filename, such as
model_baseline.pklortest_predict_300_q.pkl. This may occur through a malicious shared project, a replaced research artifact, or unauthorized access to mutable research storage. - The ...[truncated 854 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not deserialize untrusted or mutable files with Python pickle.
- Store tabular data in CSV, Parquet, or another non-code-bearing format.
- Use a model format designed for the relevant framework that does not reconstruct arbitrary Python objects.
- If legacy pickle files are unavoidable, distribute them from a controlled source and verify a pinned SHA-256 digest or digital signature before deserialization.
- Restrict write access to research artifacts and do not accept model files from untrusted shared projects.
- Document the expected filename, cryptographic digest, model type, and trusted publisher.
- Treat hash verification as an integrity control rather than a substitute for trusted provenance.
