Skip to content

Arbitrary Code Execution via PyTorch Library Loading

Description

Loading custom operator libraries in PyTorch can result in arbitrary code execution. This can happen when using the `torch.classes.load_library` function with untrusted input.

Examples

Insecure Code

python
torch.classes.load_library('untrusted_library')

Secure Code

python
torch.classes.load_library('trusted_library')

Remediation

Validate and sanitize any input passed to `torch.classes.load_library` to prevent loading malicious libraries.

Rule Details

FieldValue
IDCODE-0470
CategoryInjection
SeverityCRITICAL
CWECWE-676
ConfidenceMEDIUM
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagsarbitrary code execution, library loading
OWASPN/A

References