Skip to content

B614: false positive on torch.utils.cpp_extension.load #1343

@AlexanderDokuchaev

Description

@AlexanderDokuchaev

Describe the bug

Got unexpected error on using torch.utils.cpp_extension.load function which has no weights_only argument https://docs.pytorch.org/docs/stable/cpp_extension.html#torch.utils.cpp_extension.load

Reproduction steps

# r.py
import torch

torch.utils.cpp_extension.load(**kwargs)
bandit  r.py
>> Issue: [B614:pytorch_load] Use of unsafe PyTorch load
   Severity: Medium   Confidence: High
   CWE: CWE-502 (https://cwe.mitre.org/data/definitions/502.html)
   More Info: https://bandit.readthedocs.io/en/1.9.2/plugins/b614_pytorch_load.html
   Location: ./r.py:3:0
2
3       torch.utils.cpp_extension.load(**kwargs)

Expected behavior

No error

Bandit version

1.9.1 (Default)

Python version

3.14 (Default)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions