From 4ff17ffc8de30c3813a81c80cf38d89d9da7a73d Mon Sep 17 00:00:00 2001 From: David Dworken Date: Fri, 9 Feb 2018 14:33:29 -0800 Subject: [PATCH] Fix 4 security vulnerabilities (#4390) * Switched yaml.load to yaml.safe_load to prevent code execution via crafted yaml files Python's yaml.laod can lead to code execution via crafted yaml files such as: ``` code_exec: !!python/object/apply:subprocess.check_output ['ls'] ``` * Fixed XSS via bleach It was possible to get an XSS via the markdown library via simply setting a description containing arbitary HTML tags. It was also possible to create links that went to the `javascript:` link handler (eg `[example](javascript:alert(0)`) Using bleach to sanitize it solves both of these. * Added XFO header by default to prevent clickjacking attacks Note that with this application clickjacking can be relatively severe via the SQLLab functionality which allows executing arbitary SQL. * Added justification for dangerouslySetInnerHTML * Fixed linting errors * Fixed linting errors --- setup.py | 1 + .../javascripts/dashboard/components/GridCell.jsx | 6 ++++++ superset/cli.py | 2 +- superset/config.py | 10 ++++++---- superset/utils.py | 8 ++++++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index df71d5621..393af3b5b 100644 --- a/setup.py +++ b/setup.py @@ -80,6 +80,7 @@ setup( 'thrift>=0.9.3', 'thrift-sasl>=0.2.1', 'unidecode>=0.04.21', + 'bleach==2.1.2', ], extras_require={ 'cors': ['Flask-Cors>=2.0.0'], diff --git a/superset/assets/javascripts/dashboard/components/GridCell.jsx b/superset/assets/javascripts/dashboard/components/GridCell.jsx index 4f7213d3b..2748fccd9 100644 --- a/superset/assets/javascripts/dashboard/components/GridCell.jsx +++ b/superset/assets/javascripts/dashboard/components/GridCell.jsx @@ -108,6 +108,12 @@ class GridCell extends React.PureComponent { annotationQuery={annotationQuery} /> + { + /* This usage of dangerouslySetInnerHTML is safe since it is being used to render + markdown that is sanitized with bleach. See: + https://github.com/apache/incubator-superset/pull/4390 + and + https://github.com/apache/incubator-superset/commit/b6fcc22d5a2cb7a5e92599ed5795a0169385a825 */}