T09 · Insecure Skill Coding Practices
- Location
references/examples.md:190- Finding
Unsafe deserialization of pipeline data and model artifacts
- Content
View full analysis
Vulnerability Details
File Location:
references/examples.md, lines 190 and 222-223
Vulnerability Type: Unsafe pickle-compatible deserialization
Risk Level: HighVulnerable Code
python # Load processed data data = joblib.load(processed_data_path) X_train, y_train = data['X_train'], data['y_train']python # Load data and model data = joblib.load(processed_data_path) model = joblib.load(model_path) X_test, y_test = data['X_test'], data['y_test']Technical Analysis
joblib.load()uses Python's pickle-compatible deserialization mechanism. Pickle-compatible artifacts can define object-reconstruction behavior that invokes arbitrary Python callables during loading. Consequently, loading an artifact is effectively a code-execution operation rather than a passive data-parsing operation.The training and evaluation components load the files identified by
processed_data_pathandmodel_pathwithout verifying an immutable digest, cryptographic signature, trusted origin, ownership, or artifact-store authorization. If an attacker can create or replace either artifact, malicious instructions embedded in it execute before the code accesses the expected data or model fields.This is particularly significant in an MLOps environment because pipeline components commonly have access to artifact repositories, MLflow credentials, service-account tokens, cloud metadata, internal endpoints, and subsequent pipeline stages.
Attack Path
- An attacker obtains write access to the pipeline artifact store, compromises an upstream producer, or causes an untrusted artifact path to be supplied to the component.
- The attacker creates a malicious pickle-compatible Joblib artifact containing an object whose reconstruction routine executes attacker-selected Python code.
- The artifact is stored where the pipeline expects the processed dataset or model.
- The training or evaluation component ca ...[truncated 1079 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not deserialize untrusted data with Joblib, pickle, cloudpickle, or similar executable formats.
- Store datasets in non-executable formats such as Parquet or Arrow, and use a constrained model format such as ONNX, SafeTensors, or another format suitable for the model type.
- If Joblib is unavoidable, accept artifacts only from a dedicated repository with strict producer and consumer access controls.
- Sign artifacts during production and verify their signatures and immutable cryptographic digests before loading.
- Bind artifact identities to pipeline-run metadata so that arbitrary paths cannot be substituted.
- Run deserialization in an isolated, non-privileged container with a read-only filesystem, no unnecessary secrets, restricted egress, dropped Linux capabilities, and a narrowly scoped service account.
- Record artifact provenance and reject artifacts whose producer, digest, model version, or pipeline run cannot be verified.
- Treat checksum validation as an integrity mechanism only when the expected checksum comes from an authenticated, independently protected source.
