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

Security improvement: consider avoiding pickle.load #20

Closed
FedericoCeratto opened this issue Jun 9, 2012 · 1 comment
Closed

Security improvement: consider avoiding pickle.load #20

FedericoCeratto opened this issue Jun 9, 2012 · 1 comment

Comments

@FedericoCeratto
Copy link
Contributor

Hello and thank you for developing Beaker.

The pickle.loads() [1] method is used on data generated by crypto.aesDecrypt() that can parse an user-submitted cookie. Pickle is considered insecure to be executed on untrusted data [2], [3]

An attacker that is able to craft a valid encrypted cookie (e.g. by having obtained a leaked copy of encrypt_key or using a vulnerability in aesDecrypt) should have a limited impact, i.e. mangling session data. Pickle might allow such attacker to execute arbitrary code instead.

A solution could be to use json.loads() and json.dumps() instead of pickle.

[1] https://github.com/bbangert/beaker/blob/master/beaker/session.py#L283
[2] """The pickle module is not intended to be secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source."""
[3] http://docs.python.org/library/pickle.html

Thank you!

@bbangert
Copy link
Owner

bbangert commented Jun 9, 2012

There's more than just encryption being used. All cookies are signed with an HMAC and no work is done with the data unless the HMAC is valid. The only way for a person to sign cookies such that they'll be loaded requires them to know your servers' secret key, which implies they already have access to your machine.

This signing ensures the source is authenticated.

@bbangert bbangert closed this as completed Jun 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants