sqlitedict icon indicating copy to clipboard operation
sqlitedict copied to clipboard

How can I report if there's a potential vulnerability

Open William957-web opened this issue 1 year ago • 2 comments
trafficstars

I found out a vulnerability in this library, how can I report it? Already reported cve.

William957-web avatar May 08 '24 01:05 William957-web

@piskvorky

William957-web avatar May 08 '24 01:05 William957-web

I think you can just report the issue here

mpenkov avatar May 08 '24 04:05 mpenkov

@mpenkov @piskvorky CVE-2024-35515

William957-web avatar Jun 08 '24 07:06 William957-web

Thanks. Closing until there's a clearly demonstrated proof-of-concept or attack vector. Ideally with a mitigation PR where relevant.

piskvorky avatar Jun 08 '24 09:06 piskvorky

@piskvorky https://william957-web.github.io/sqlitedict-vuln-report.zip Additional details

William957-web avatar Jun 09 '24 07:06 William957-web

Isn't this a problem with pickle, not with sqlitedict itself?

mpenkov avatar Jun 10 '24 02:06 mpenkov

@mpenkov Probably not, for example, you won't say that code injection vulnerbility is the problem with eval. In fact, there're serveral prevention due to pickle deserialization(like check object titles, sandboxes...), and ML often used libraries like clearML, pytorch also patched this kind of vulnerabilities.

William957-web avatar Jun 11 '24 12:06 William957-web

@mpenkov @piskvorky patched version (Reference:https://docs.python.org/3/library/pickle.html):

import builtins
import io
import pickle

safe_builtins = {
    'range',
    'complex',
    'set',
    'frozenset',
    'slice',
}

class RestrictedUnpickler(pickle.Unpickler):

    def find_class(self, module, name):
        # Only allow safe classes from builtins.
        if module == "builtins" and name in safe_builtins:
            return getattr(builtins, name)
        # Forbid everything else.
        raise pickle.UnpicklingError("global '%s.%s' is forbidden" %
                                     (module, name))

def restricted_loads(s):
    """Helper function analogous to pickle.loads()."""
    return RestrictedUnpickler(io.BytesIO(s)).load()

and change the decode and decode_key function's loads into restricted_loads. The only drawback of this prevention is that user can't store other none builtin data types(like numpy or else(but I think the functions can be replaced just by sqlitedict!))...

William957-web avatar Jun 20 '24 13:06 William957-web

Just asking,is this vuln patched?

yoni13 avatar Aug 16 '24 11:08 yoni13

No, we didn't consider this worth patching, right @piskvorky ?

mpenkov avatar Aug 16 '24 12:08 mpenkov

Correct.

piskvorky avatar Aug 16 '24 13:08 piskvorky

After I read those pdfs, I think add a warning to warn user don't load untrusted db file is actually enough.

What do you think @William957-web ?

yoni13 avatar Aug 16 '24 16:08 yoni13

@yoni13 Yeah, I agree with your idea! @piskvorky

William957-web avatar Aug 17 '24 01:08 William957-web