Git Product home page Git Product logo

Comments (3)

mmaitre314 avatar mmaitre314 commented on July 16, 2024 1

Should the target be _pickle or pickle (no underscore)?

I setup a repro using this:

class Malicious13:
    def __reduce__(self):
        return pickle.loads, (b'I12345\n.',) # Loads the value 12345

This gets serialized (Pickle version 0, on Windows) as:

cpickle
loads
p0
(c_codecs
encode
p1
(VI12345\u000a.
p2
Vlatin1
p3
tp4
Rp5
tp6
Rp7
.

This has cpickle instead of _pickle in the serialized data.

Without the fix, this gets detected as pickle.loads and reported as Suspicious. The fix I am currently testing raises that to Dangerous.

from picklescan.

McPatate avatar McPatate commented on July 16, 2024

Not sure why in some cases it serializes as __pickle and others as pickle/cpickle. Can't find the repo anymore, but pretty sure the global was __pickle.

from picklescan.

mmaitre314 avatar mmaitre314 commented on July 16, 2024

That looks like a Python 2 - Python 3 compatibility feature. It sounds like in Python 2 the C implementation of pickle was called cPickle and in Python 3 _pickle. When I pickle with version 0, cPickle is written, and with version 4, _pickle is written. Updating the fix to handle both.

from picklescan.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.