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

Limit get_tree to a predefined set of types #222

Open
adrinjalali opened this issue Nov 29, 2022 · 2 comments
Open

Limit get_tree to a predefined set of types #222

adrinjalali opened this issue Nov 29, 2022 · 2 comments
Labels
persistence Secure persistence feature

Comments

@adrinjalali
Copy link
Member

Right now get_tree is called in __init__ of many nodes, where they know what kind of child they expect. This can be a dict or a list for instance. In these cases, it'd be better for get_tree to accept an argument to limit the types of nodes it can return/construct.

For instance, instead of

"kwds": get_tree(state["content"]["kwds"], load_context),

we could have

"kwds": get_tree(state["content"]["kwds"], load_context, allowed_types=[DictNode]),

This would reduce the attack surface when loading a file.

@adrinjalali adrinjalali added the persistence Secure persistence feature label Nov 29, 2022
@BenjaminBossan
Copy link
Collaborator

This would work for some but not all cases, right? E.g. a TupleNode can't know the type of its content.

For all other cases, it probably wouldn't hurt. However, I don't see yet how this could be used as an attack, since at this stage we're not actually instantiating any objects (which doesn't mean we shouldn't still do it).

A minor problem is that this could lead to circular imports, but I haven't checked if it actually occurs.

@adrinjalali
Copy link
Member Author

This would work for some but not all cases, right? E.g. a TupleNode can't know the type of its content.

Correct, collections can load anything.

As for attacks, I can't think of a specific attack which would use this, but it would reduce the attack surface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
persistence Secure persistence feature
Projects
None yet
Development

No branches or pull requests

2 participants