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

Use json for imports and exports, not pickle #4243

Merged
merged 2 commits into from
Jan 24, 2018

Conversation

timifasubaa
Copy link
Contributor

@timifasubaa timifasubaa commented Jan 19, 2018

Importing and exporting dashboards with pickle files, which the user controls poses a security vulnerability. A well constructed pickle file can potentially spawn a shell.
The exploit is fleshed out here (https://blog.nelhage.com/2011/03/exploiting-pickle/)
This PR changes the format of the exported and imported files to json strings and eliminates this possibility.

@mistercrunch @john-bodley @michellethomas

@timifasubaa timifasubaa force-pushed the export_json_not_pickle branch 4 times, most recently from 85c6190 to 2f7e195 Compare January 19, 2018 02:28
@@ -1919,7 +1945,7 @@ def dashboard(self, dashboard_id):
else:
qry = qry.filter_by(slug=dashboard_id)

dash = qry.one()
dash = qry.first()#one()
Copy link
Contributor Author

@timifasubaa timifasubaa Jan 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing a new dashboard from an existing dashboard leaves the slug value the same and when .one() has more than one result, it errors out.
Would it be better to avoid importing dashboards with the same slug or to add a random new slug or just return the first slug?

@timifasubaa timifasubaa changed the title Use json for imports and exports, not pickle [WIP] Use json for imports and exports, not pickle Jan 19, 2018
@timifasubaa timifasubaa force-pushed the export_json_not_pickle branch 6 times, most recently from 196915d to d85aead Compare January 19, 2018 19:07
@timifasubaa timifasubaa changed the title [WIP] Use json for imports and exports, not pickle Use json for imports and exports, not pickle Jan 19, 2018
@timifasubaa timifasubaa force-pushed the export_json_not_pickle branch 11 times, most recently from acedfe1 to 1c8eee2 Compare January 22, 2018 10:05
@@ -240,6 +241,55 @@ def dttm_from_timtuple(d):
d.tm_year, d.tm_mon, d.tm_mday, d.tm_hour, d.tm_min, d.tm_sec)


def decode_dashboards(o):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think using jsonpickle with custom handlers for encoding/decoding would be more pythonic?

Copy link
Contributor Author

@timifasubaa timifasubaa Jan 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it would be more pythonic but as it turns out, jsonpickle is also susceptible to the RCE attack.

@timifasubaa
Copy link
Contributor Author

PING

@michellethomas
Copy link
Contributor

this looks good to me

@mistercrunch
Copy link
Member

💯

@mistercrunch mistercrunch merged commit 2c72a7a into apache:master Jan 24, 2018
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Jan 24, 2018
* make superset imports and exports use json, not pickle

* fix tests
mistercrunch added a commit that referenced this pull request Jan 27, 2018
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
* make superset imports and exports use json, not pickle

* fix tests
@iamamoose
Copy link
Member

Note this is CVE-2018-8021

wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
* make superset imports and exports use json, not pickle

* fix tests
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.23.0 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.23.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants