Skip to content

Get rid of pickle. #14016

Open
Open

Description

@KOLANICH
self.db = PickleShareDB(os.path.join(self.profile_dir.location, 'db'))

is like

self.db = exec((Path(self.profile_dir.location) / 'backdoor.py').read_text())

, but worse: at least we can audit contents of backdoor.py with a text editor.

Activity

  1. Carreau commented on Apr 14, 2023

    @Carreau
    Member

    An attacker would need to already have write access to self.profile_dir.location, so would already have compromised your machine.

    Plus if there are other files in self.profile_dir.location that would be executed anyway.

    It is dangerous to unpickle untrusted files, here what we have is perfectly trusted.

  2. KOLANICH commented on Apr 15, 2023

    @KOLANICH
    Author

    An attacker would need to already have write access to self.profile_dir.location, so would already have compromised your machine.

    Sure, but at least it is easier to check for this case.

    Plus if there are other files in self.profile_dir.location that would be executed anyway.

    Sure, but self.db = PickleShareDB(os.path.join(self.profile_dir.location, 'db')) just adds a yet another place to check, and checking is nontrivial. Also the dir name tells nothing about the files in it are pickles.

    It is dangerous to unpickle untrusted files, here what we have is perfectly trusted.

    I know, but I'd prefer ipython to follow defense-in-depth approach and prefer file formats that are safe to work with.

  3. added this to the wishlist milestone on Apr 17, 2023
  4. Carreau commented on Apr 17, 2023

    @Carreau
    Member

    I understand your point of view, but IPython being an interactive interpreter, there are just too many things like this that are weird in other libraries but are not here. This is by far not the most dangerous.

    If you want to send PR(s) that slowly replace this code with a difference safe serialization format, I will consider it, but you will need to take into account migration from older format.

    I'm going to reopen, but it's not going to be high priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions