Knowledge Base Regulation Tracker Standards & Frameworks OSS Directory AI Incident Database Research Paper Library Case Studies Society Articles News Jobs About Charter Sign inBecome a Member

ModelScan

Model file scanning

Scanner that inspects serialised model files (pickle, PyTorch, TensorFlow, Keras, H5) for embedded code that would execute on load, so models can be checked before they are used. Named in the taxonomy and the OWASP solutions landscape.

model scanningpickleserialisation attacks

How ModelScan Works

ModelScan is designed to detect malicious code embedded within serialized machine learning model files without executing the file directly. This is critical because loading certain model formats—such as PyTorch, TensorFlow, Keras, or Pickle files—can automatically trigger embedded code during deserialization, potentially leading to attacks like credential theft, data exfiltration, or model poisoning. To mitigate this risk, ModelScan reads model files byte-by-byte, scanning for known code signatures associated with unsafe operations. This approach ensures the scan is both fast and secure, typically completing in seconds depending on the file size. The tool does not load the model, thus avoiding the execution of any malicious payloads.

When ModelScan identifies unsafe code, it categorizes findings into four severity levels: CRITICAL, HIGH, MEDIUM, and LOW. These classifications help users prioritize responses based on the potential impact of the detected vulnerabilities. For example, CRITICAL issues might involve direct attempts to exfiltrate data or execute arbitrary commands, while MEDIUM or LOW issues could include less immediately dangerous but still problematic embedded code, such as debugging scripts left in the model for reproducibility.

By treating model files as potential attack vectors—akin to scanning PDFs or executable files—ModelScan enforces a proactive security posture in the machine learning supply chain. This is particularly relevant given the increasing reliance on pre-trained models, many of which are shared publicly or distributed across teams without adequate scrutiny.

ModelScan’s scanning mechanism is optimized for performance and safety. It avoids the pitfalls of traditional deserialization by never loading the model into memory as a live object. Instead, it processes the file as raw bytes, extracting and analyzing only the structural components that could indicate malicious intent. The tool’s output includes detailed reports on detected issues, allowing users to investigate further or contact the model’s authors for clarification on benign but suspicious code patterns.

The effectiveness of ModelScan is further enhanced by its support for multiple serialization formats, which are commonly used across different machine learning frameworks. These formats include Pickle, PyTorch’s SavedModel, TensorFlow’s Protocol Buffer, and HDF5 (H5) files used by Keras and other libraries. By covering a broad range of formats, ModelScan addresses the fragmentation in model serialization practices, providing a unified solution for teams working with diverse toolchains.

The tool’s CLI and programmatic interfaces allow for seamless integration into existing workflows, whether for ad-hoc scanning or continuous security validation.

For instance, it recommends reaching out to model authors to determine whether embedded code is intentional (e.g., for reproducibility) or malicious.

As machine learning models become more integral to critical applications—such as autonomous systems, financial decision-making, and healthcare diagnostics—the risks associated with compromised models also escalate. ModelScan’s open-source nature encourages community contributions, ensuring that the tool evolves alongside emerging threats and use cases. Its permissive Apache 2.0 license further facilitates adoption across organizations with varying security requirements.

The tool’s design also accounts for the practical challenges of integrating security into fast-moving development cycles. By providing both command-line and programmatic interfaces, ModelScan can be deployed in environments ranging from individual research projects to large-scale enterprise deployments.

Exit codes range from 0 (no vulnerabilities found) to 4 (invalid CLI usage), enabling scripts and CI/CD pipelines to act on scan results programmatically. This feature is particularly valuable for organizations implementing continuous security checks, where automated responses to vulnerabilities—such as quarantining compromised models—can prevent downstream risks.

Under the hood, ModelScan relies on a combination of static analysis techniques and signature-based detection to identify unsafe code patterns.

By preventing the execution of potentially malicious code during the scanning process, ModelScan reduces the attack surface associated with model deserialization. This is especially important in environments where models are frequently shared or updated, as it minimizes the window of opportunity for attackers to exploit vulnerabilities during the loading phase.

ModelScan’s integration with enterprise-grade solutions, such as Protect AI’s Guardian product, offers organizations a pathway to scale their security efforts. While ModelScan provides open-source scanning capabilities, Guardian extends these features with additional tools for proactive security enforcement, comprehensive audit trails, and seamless CI/CD integration.

By providing clear examples of how attacks can be executed, ModelScan raises awareness within the machine learning community, fostering a culture of security-by-design in model development and deployment.

For instance, updates to libraries like PyTorch, TensorFlow, and HDF5 ensure compatibility with the latest versions of these frameworks, while fixes for vulnerabilities in supporting packages (such as Jinja2 or Rich) maintain the tool’s reliability.

The tool’s support for classic machine learning libraries—such as Scikit-learn, XGBoost, and others that rely on Pickle or similar serialization formats—further broadens its applicability. Its ability to detect issues in these formats underscores the importance of a unified approach to model security, regardless of the underlying framework.

ModelScan’s settings file feature allows users to tailor the scanning process to their specific needs. By supporting JSON, console, or custom output formats, ModelScan accommodates diverse operational needs while maintaining flexibility.

For example, users can instantiate a scanner with default or custom settings, scan a model file or directory, and access detailed issue reports programmatically. This integration capability is critical for organizations that require automated security checks as part of their model validation workflows.

The ability to specify a settings file or generate reports in different formats (e.g., JSON for machine-readable logs) enhances its utility in both interactive and automated environments.

The tool’s exit codes are designed to facilitate error handling and automation. Similarly, an exit code of 2 signals a scanning failure, prompting users to investigate potential issues with the tool or the input files. This structured feedback mechanism is essential for building reliable and maintainable security workflows.

ModelScan’s focus on model serialization attacks highlights a critical but often overlooked aspect of AI security. These attacks exploit the trust placed in serialized model files, which are assumed to contain only model weights and architecture. By embedding malicious code during serialization, attackers can bypass traditional security measures that focus on runtime behavior or network-level threats. ModelScan’s ability to detect such attacks at the point of deserialization fills a gap in the AI security toolchain, providing a preemptive layer of defense.

The tool’s compatibility with major machine learning frameworks—PyTorch, TensorFlow, Keras, and classic ML libraries—reflects its practical relevance to the broader AI community. These frameworks are foundational to modern machine learning, and their widespread adoption makes ModelScan a valuable asset for teams working across different ecosystems. By supporting a variety of serialization formats, ModelScan ensures that security checks are not limited by the choice of framework, fostering consistency in security practices across diverse environments.

ModelScan’s open-source nature encourages collaboration and innovation within the AI security community. By making the tool freely available under the Apache 2.0 license, Protect AI invites contributions from developers, researchers, and security professionals. The community-driven model aligns with the principles of open-source software, where collective expertise drives continuous improvement.

ModelScan’s integration with enterprise solutions, such as Protect AI’s Guardian, offers a scalable path for organizations to enhance their security posture. This tiered approach allows organizations to start with open-source tooling and gradually adopt more comprehensive solutions as their security needs grow. The synergy between these tools ensures that users can build a robust and adaptive security framework tailored to their specific requirements.

The tool’s support for multiple output formats—including JSON, console, and custom reports—enables seamless integration into existing security workflows. This flexibility ensures that ModelScan can be adapted to a wide range of use cases, from ad-hoc scanning to fully automated security pipelines.

ModelScan’s development roadmap includes ongoing improvements to its scanning capabilities and supported formats. By staying ahead of emerging risks, ModelScan continues to provide a critical layer of defense for organizations relying on machine learning models.

The tool’s ability to detect a wide range of malicious behaviors—such as credential theft, data exfiltration, and model poisoning—underscores its importance in the AI security toolchain. ModelScan’s proactive approach to identifying these risks helps organizations prevent attacks before they can cause harm, thereby reducing the overall impact of model-related security incidents.

By treating model files as potential attack vectors and implementing rigorous scanning procedures, the tool reinforces the idea that security is not an afterthought but a fundamental requirement. By embedding security checks into the model lifecycle, ModelScan helps organizations build trust in their AI-driven processes.

By maintaining compatibility with a wide range of Python versions, ModelScan reduces barriers to adoption, allowing teams to integrate security checks into their existing workflows without requiring significant infrastructure changes.

This dual approach ensures that ModelScan can be used effectively by both individual developers and large organizations with complex security requirements.

The tool’s focus on model serialization attacks addresses a specific but critical vulnerability in the machine learning pipeline. Serialization attacks exploit the trust placed in model files, which are often assumed to contain only model parameters and architecture. By embedding malicious code during serialization, attackers can bypass traditional security measures, making these attacks particularly insidious. ModelScan’s ability to detect such attacks at the point of deserialization provides a critical layer of defense, helping organizations mitigate risks before models are deployed in production environments.

ModelScan’s support for classic machine learning libraries—such as Scikit-learn and XGBoost—expands its relevance beyond deep learning frameworks. These libraries are widely used in both research and production settings, and their reliance on serialization formats like Pickle makes them susceptible to the same types of attacks. By addressing these formats, ModelScan ensures that security checks are not limited to modern deep learning models but extend to the broader spectrum of machine learning applications. This comprehensive approach is essential for building a holistic security posture in AI-driven environments.

The tool’s ability to categorize findings by severity helps users prioritize responses based on the potential impact of detected vulnerabilities. For example, CRITICAL issues—such as attempts to exfiltrate data or execute arbitrary commands—require immediate attention, while MEDIUM or LOW issues may warrant further investigation or monitoring. By providing clear severity classifications, ModelScan enables users to make informed decisions about how to address detected issues.

ModelScan’s integration with enterprise solutions, such as Protect AI’s Guardian, offers organizations a pathway to scale their security efforts. While ModelScan provides open-source scanning capabilities, Guardian extends these features with additional tools for policy enforcement, audit trails, and CI/CD integration.

For example, updates to libraries like PyTorch and TensorFlow ensure that ModelScan remains effective as these frameworks introduce new features or serialization methods.

Use Cases

ModelScan is primarily designed for organizations and individuals involved in the development, deployment, or consumption of machine learning models. Its use cases span across various stages of the model lifecycle, from initial development to production deployment, and include scenarios where models are shared internally or externally. One of the most critical use cases is the validation of third-party models, which are often downloaded from public repositories or shared across teams without adequate scrutiny. By scanning these models before use, organizations can prevent attacks such as credential theft, data exfiltration, or model poisoning, which could compromise sensitive systems or data.

In research environments, ModelScan is particularly valuable for teams that rely on pre-trained models or models shared by collaborators. These models may originate from untrusted sources, such as public datasets or open-source repositories, where the risk of malicious code injection is higher. For example, a data scientist downloading a model from Hugging Face or another public platform can use ModelScan to verify its safety before integrating it into their workflow. This is especially important in collaborative research settings, where models may be shared frequently and the provenance of the code is unclear.

ModelScan is also well-suited for enterprise environments where machine learning models are used to power critical applications. For instance, in financial services, models may be used for fraud detection, risk assessment, or algorithmic trading. In both cases, the integrity of the model is paramount, as compromised models could lead to incorrect decisions with severe consequences. By integrating ModelScan into their model validation pipelines, organizations can ensure that only secure models are deployed in production, reducing the risk of operational disruptions or security breaches.

In these environments, ModelScan can be automated to scan model files as part of the deployment process, ensuring that only verified models are promoted to production. This is particularly useful in DevOps workflows, where speed and automation are prioritized, but security cannot be compromised. By embedding ModelScan into CI/CD pipelines, organizations can maintain a consistent security posture across their machine learning workflows, even as models are rapidly iterated upon.

ModelScan is also relevant for organizations that develop and distribute their own machine learning models, either internally or as part of a product offering. For example, a company that provides pre-trained models as a service can use ModelScan to verify the security of these models before releasing them to customers. This not only protects the company’s reputation but also ensures that customers can trust the models they are using. Similarly, internal teams that share models across departments can use ModelScan to validate the safety of these assets before they are deployed in different environments.

In educational settings, ModelScan can be used to teach students and researchers about the risks associated with model serialization and the importance of security in machine learning. By demonstrating how attacks can be executed and how ModelScan detects them, educators can raise awareness about these threats and encourage best practices in model development and deployment.

The tool is also valuable for security teams responsible for protecting an organization’s infrastructure from AI-related threats. By integrating ModelScan into their security toolchain, these teams can proactively identify and mitigate risks associated with model serialization attacks. This is particularly important in environments where models are frequently shared or updated, as it minimizes the window of opportunity for attackers to exploit vulnerabilities. ModelScan’s ability to detect a wide range of malicious behaviors—such as credential theft, data exfiltration, and model poisoning—makes it an essential component of a comprehensive AI security strategy.

In cloud and edge computing environments, ModelScan can be used to secure models deployed across distributed systems. ModelScan can ensure that these models are scanned and validated before being deployed in any cloud or edge device, reducing the risk of cross-environment attacks. This is particularly relevant in scenarios where models are used to make real-time decisions, such as in autonomous vehicles or industrial IoT systems, where security breaches could have catastrophic consequences.

ModelScan’s support for multiple serialization formats—including Pickle, PyTorch’s SavedModel, TensorFlow’s Protocol Buffer, and HDF5—makes it versatile across different machine learning frameworks. This is particularly useful for organizations that use a mix of frameworks, as it allows them to maintain a consistent security posture regardless of the tools they employ. For example, a team using both PyTorch and TensorFlow can scan models from both frameworks using the same tool, simplifying their security workflows and reducing the risk of oversight due to format-specific vulnerabilities.

Sources

Contribute

Spot an error, or know a record we should add? Members can propose additions and submit corrections.