arXiv:2611.08745cs.CRNov 2026

Manuscript Offprint

arXiv:2611.08745

I Don't Care How You Hide It, I Care What You Do: Runtime Detection of Malicious ML Models

Hala Ali, Andrew Case

Hala Ali

Virginia Commonwealth University, USA

halaali.cs@gmail.com

Andrew Case

Volatility Foundation, USA

andrew@dfir.org

Abstract—Pre-trained machine learning (ML) models shared through public platforms can be weaponized to execute malicious payloads during loading or inference. Existing scanners prove inadequate for detecting malicious models as they rely on static analysis and function denylists, support limited serialization formats, and miss attacks that replace denylisted functions with equivalent alternatives, exploit unsupported loading paths, or abuse legitimate framework APIs. To address this problem, we present MODELSHIELD, the first runtime behavioral detection system for malicious ML models that attributes observed system-level behavior to specific model operations. It combines application-level instrumentation of ML framework APIs with eBPF-based syscall tracing, tracking model behavior across spawned threads and child processes to separate model-triggered activity from environment noise. Attributed syscall sequences are classified using 195 detection patterns mapped to MITRE ATT&CK techniques. We implemented MODELSHIELD to support 17 ML frameworks and 36 formats. On an independent dataset, it is the only evaluated tool to achieve zero false positives, with false negatives limited to payloads that produce no malicious runtime behavior. It detected all 29 published evasion variants spanning function substitution, loading-path obfuscation, and TensorFlow API abuse, where no existing scanner achieved complete coverage. Across 145,000 models scanned from public platforms, it captured 41 malicious models on Hugging Face, including a reverse-shell payload and a payload that performed host reconnaissance and outbound exfiltration. Among these, ModelScan, PickleScan, Fickling, and ModelAudit detected only 29%, 56%, 80%, and 93%, respectively. Despite runtime overhead, MODELSHIELD achieves a median analysis time of 12.3 seconds, with 90% of scans completing within 35.5 seconds, making it practical for hub-scale screening.

Index Terms—Machine Learning Security, Malicious ML Models, Runtime Behavioral Detection, System Call Tracing

1. Introduction

Pre-trained machine learning (ML) models are commonly shared through public platforms such as Hugging Face [1], Kaggle [2], ModelScope [3], TensorFlow Hub [4], and Keras Hub [5]. While adopting these models reduces the time, cost, and expertise required to deploy ML systems [6]–[8], it introduces security risks. ML models can encapsulate learned parameters, architecture, and computational logic, allowing attackers to embed malicious code that is triggered during loading or inference [9], [10].

Existing static scanners rely on limited and inconsistent denylist rules, resulting in varying detection results across tools. For instance, PickleScan [11], which is used in Hugging Face's built-in pickle scanning pipeline [12], focuses on pickle-based serialization formats. ModelScan [13] supports additional formats such as H5 and TensorFlow SavedModel, but still relies on predefined lists of unsafe functions, imports, and operators. Recent work has shown that these scanners fail against evasion techniques that replace commonly denylisted functions, such as os.system, eval, and exec, with functionally equivalent alternatives from Python's standard library or common ML dependencies. These techniques also exploit loading paths that scanners do not fully support, including nested archives, compression layers, framework-specific packaging formats such as zip, tar, gzip, bz2, and xz, and craft malformed pickle bytecode or archive structures that trigger parser exceptions in scanners while remaining loadable by the framework [14]. Beyond pickle-based formats, attackers can also abuse legitimate framework APIs, such as TensorFlow SavedModel operations (e.g., FixedLengthRecordDatasetV2 and DebugIdentityV3), to perform file leakage, IP exposure, code execution, and shell access [15].

Addressing these gaps within the current scanners is challenging. Blocking legitimate framework APIs is impractical as benign models and standard ML workflows depend on them [16]. Expanding denylists to include broader Python standard-library functions or ML dependencies is also insufficient, since the same function can be benign or malicious depending on its arguments and runtime effects [17]. Moreover, extending scanner support to all possible loading paths and container formats imposes a continuous maintenance burden as frameworks evolve. Although sandboxing is recommended for executing untrusted models [18], a sandboxed trace does not inherently determine whether an observed syscall originated from the model artifact, the ML framework, or the execution environment itself [19].

Therefore, we present MODELSHIELD, the first runtime behavioral detection system for malicious ML models that attributes observed system-level behavior to specific model operations. Unlike existing scanners, which flag models containing suspicious or denylisted callables regardless of runtime effect, MODELSHIELD reports a model as malicious only when it produces an observable harmful action. This complements static analysis, which remains necessary for payloads that never execute, while avoiding false positives from dormant or benign uses of flagged functions. MODELSHIELD combines application-level instrumentation of ML framework APIs with eBPF-based syscall tracing to link each captured syscall to the model loading or inference operation that triggered it. This attribution is preserved across threads and child processes, separating model-triggered behavior from framework and execution-environment noise. The attributed syscall sequences are then classified against a taxonomy of 195 detection patterns mapped to MITRE ATT&CK [20]. To capture behaviors not covered by the taxonomy, the syscall traces are further analyzed offline by an LLM to identify candidate patterns, which are manually reviewed before inclusion.

We implemented MODELSHIELD to support 17 ML frameworks and 36 formats. On the PickleBall evaluation dataset [17], MODELSHIELD is the only evaluated tool to achieve zero false positives; its false negatives arise from payloads that never execute or produce no malicious behavior during analysis, not from classification errors. It detected all 29 published evasion variants covering function substitution, loading-path obfuscation, and TensorFlow API abuse, where no static tool achieved complete coverage. On a large-scale scan of 105,000 Hugging Face, 30,000 ModelScope, and 10,000 Kaggle models uploaded between March 25 and May 5, 2026, it detected 41 malicious models on Hugging Face, including two real-world malware samples. The first is a reverse-shell payload that remained undetected for three days after upload, with 108 downloads at detection time; the second performed host reconnaissance and outbound exfiltration. Among these, ModelScan, PickleScan, Fickling, and ModelAudit detected only 29%, 56%, 80%, and 93%, respectively. DynaHug [19], a recent dynamic approach, could analyze only 12% as it is limited to PyTorch formats and loading-phase monitoring. Although slower than existing scanners due to runtime analysis overhead, MODELSHIELD achieves a median analysis time of 12.3 seconds per model, with 90% of scans completing within 35.5 seconds, making it practical for hub-scale screening.

To summarize, we make the following contributions:

  • We introduce MODELSHIELD, the first runtime behavioral detection system that attributes syscall activity to specific model loading and inference operations.

  • We design a dual-layer architecture combining AOP-based framework instrumentation with eBPF syscall tracing, propagating correlation across threads and child processes.

  • We develop a taxonomy of 195 detection patterns across eight attack classes mapped to MITRE ATT&CK, extended via offline LLM-based discovery.

  • We evaluate MODELSHIELD on the PickleBall evaluation dataset, 29 published evasion variants, and 145,000

models across three platforms, detecting 41 malicious models including two real-world malware samples, with 90% of scans completing within 35.5 seconds.

References (37)