Summary
A critical unsafe deserialization vulnerability in the NetBox Device Type Library test harness allows pull-request-controlled pickle files to execute attacker-controlled code when loaded by pytest.
An unauthenticated contributor may be able to trigger code execution in a GitHub Actions runner or in a maintainer environment that runs the affected validation tests, potentially compromising reachable resources.
Affected context
The vulnerability occurs in the NetBox Device Type Library validation workflow when tests deserialize tracked pickle cache files using pickle.load. The risk is present where pull requests can influence the relevant test configuration or pickle files and automated or maintainer-controlled test execution processes those files without treating them as untrusted input.
Exploit preconditions
- Attack surface: Pull-request-controlled repository files processed by the validation test harness
- Required access: Ability to submit or modify contribution content; authentication to the application is not necessarily required
- Trigger point: Pytest execution of the definitions validation tests
- Relevant files: The test configuration and tracked known-module or known-rack pickle cache files
- Why exploitation is possible: Python pickle deserialization can invoke attacker-controlled object reduction behavior during loading, before the resulting data is safely constrained
Why this happens
The underlying bug is the deserialization of untrusted or contributor-controlled data with Python's pickle.load. Pickle is a code-capable serialization format rather than a data-only interchange format, so loading a crafted object can invoke reduction behavior defined by that object.
This maps primarily to CWE-502: Deserialization of Untrusted Data. The contributor-controlled test workflow also relates to CWE-829: Inclusion of Functionality from Untrusted Control Sphere, because repository content from an external contribution is incorporated into a privileged or trusted execution environment.
Potential impact
- Arbitrary code execution in a GitHub Actions runner
- Compromise of credentials, tokens, or artifacts accessible to the runner
- Modification of repository contents or build outputs
- Execution of code in a maintainer-controlled test environment
- Loss of confidentiality, integrity, or availability for reachable resources
- Supply-chain compromise through altered validation or release-related artifacts
General mitigation guidance
Mitigation generally focuses on eliminating executable deserialization from contributor-controlled test paths and reducing trust in repository inputs.
Common defensive patterns include:
- Replacing pickle with a data-only format such as JSON or another schema-constrained representation
- Avoiding deserialization of files that can be changed through pull requests
- Applying strict schemas and type validation before data is used by tests
- Separating untrusted contribution testing from sensitive credentials, deployment permissions, and release infrastructure
- Running automation with least privilege, isolated environments, restricted network access, and ephemeral credentials
- Treating test configuration switches and cached artifacts as untrusted inputs
- Requiring trusted review or controlled regeneration for serialized test fixtures
How teams detect issues like this
Organizations can detect similar issues through:
- Static analysis rules for
pickle.load,pickle.loads, and related deserialization APIs - Code review checks for executable serialization formats in tests, CI workflows, caches, and fixtures
- Repository policies that flag contributor-controlled files consumed by privileged automation
- Dependency and workflow reviews that identify broad runner permissions or exposed secrets
- CI controls that prevent untrusted pull requests from accessing sensitive credentials or modifying trusted artifacts
- Automated security review tools that report unsafe deserialization and untrusted control-flow boundaries

