Skip to content

torch.jit.annotations.parse_type_line is not safe (command injection) even it seems already deprecated. #88868

Closed
@Lyutoon

Description

@Lyutoon

🐛 Describe the bug

In torch.jit.annotations, it looks like there are some functions that are deprecated, but still retain code, which may lead to some backdoors, especially since some of these functions still use eval while implementing.
But now I'm not sure if there are some features (jit decorator) in some version of pytorch are still using this function parse_type_line or get_signature which calls parse_type_line, if so, it can cause RCE, if not, maybe someone can also leave a backdoor by calling this function while writing code and share it to the people.

import torch

torch.jit.annotations.parse_type_line('# type: __import__("os").system("ls") -> 234', None, 1)

Versions

master

cc @ezyang @gchanan @zou3519 @EikanWang @jgong5 @wenzhe-nrv @sanchitintel

Metadata

Metadata

Assignees

Labels

high priorityoncall: jitAdd this issue/PR to JIT oncall triage queuetopic: securitytriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions