Skip to content
This repository was archived by the owner on Aug 12, 2023. It is now read-only.

enforce_private unprotected from pickpockets #3

@MostAwesomeDude

Description

@MostAwesomeDude

An unscrupulous pickpocket can reach out and nab private members easily. Assume a module box with:

from lang.access import enforce_private
@enforce_private
class Box(object):
    def __init__(self):
        self._cheese_ = 42

Then, at the REPL:

>>> import box
>>> b = box.Box()
>>> vars(b)["_cheese_"]
42
>>> b.__dict__["_cheese_"]
42

This attack is mitigated by the use of __slots__, on Python interpreters which support slotted classes, but see #4 for something more durable.

Edit: Slots.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions