Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan for Pickle INST opcode #51

Closed
mehrinkiani opened this issue Oct 25, 2023 · 0 comments · Fixed by #52
Closed

Scan for Pickle INST opcode #51

mehrinkiani opened this issue Oct 25, 2023 · 0 comments · Fixed by #52
Labels
enhancement New feature or request

Comments

@mehrinkiani
Copy link
Member

Describe the bug
The INST opcode is similar to GLOBAL opcode. Picklescan has recently updated their code to handle INST opcode.
Here is some sample code for injecting malicious code in a pickle file with INST opcode. At the moment, modelscan does not detect INST opcode.

To Reproduce
Steps to reproduce the behavior:

  1. Create a malicious pickle file that has INST opcode:
def initialize_data_file(path: str, data) -> None:    
    with open(path, "wb") as file:
        file.write(data)

initialize_data_file(
        f"malicious-file.pkl",
        b"(S'print(\"Injection running\")'\ni__builtin__\nexec\n.",
    )

Expected behavior
Would be nice to be able to detect INST opcode

Screenshots
image

Environment (please complete the following information):

  • OS: macOS 14.0
  • Modelscan Version : 0.0.0
  • ML Framework version [e.g. Tensorflow v2.13.0] : Not applicable
  • Describe the model serialization format that triggered this error: pickle
@mehrinkiani mehrinkiani added the bug Something isn't working label Oct 25, 2023
@seanpmorgan seanpmorgan added enhancement New feature or request and removed bug Something isn't working labels Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants