summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-03-16 23:03:02 +0100
committerLukas Reschke <lukas@statuscode.ch>2017-03-16 23:03:02 +0100
commit148e7abb5143a4003d01989c89424900d94e65aa (patch)
tree34b7cb4454e2dca9ea95da24952617f0e37ef13c /core/js
parentc4fe36cc02da9aea95a5b72bebbb4c50719c690d (diff)
downloadnextcloud-server-148e7abb5143a4003d01989c89424900d94e65aa.tar.gz
nextcloud-server-148e7abb5143a4003d01989c89424900d94e65aa.zip
Harden JS by disabling jQuery eval
Disable execution of eval in jQuery. We do require an allowed eval CSP configuration at the moment for handlebars et al. But for jQuery there is not much of a reason to execute JavaScript directly via eval. This thus mitigates some unexpected XSS vectors. As example try to insert `$('.fileinfo').html('<a href="asd"><script>alert(1)</script></a>');` with and without this patch in your browsers JS console when the file list is opened. Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js
index c8907cdfc90..5c737d41793 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1265,6 +1265,15 @@ function initCore() {
});
/**
+ * Disable execution of eval in jQuery. We do require an allowed eval CSP
+ * configuration at the moment for handlebars et al. But for jQuery there is
+ * not much of a reason to execute JavaScript directly via eval.
+ *
+ * This thus mitigates some unexpected XSS vectors.
+ */
+ jQuery.globalEval = function(){};
+
+ /**
* Set users locale to moment.js as soon as possible
*/
moment.locale(OC.getLocale());