summaryrefslogtreecommitdiff
path: root/program/js
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-11-23 18:53:58 +0000
committerthomascube <thomas@roundcube.net>2011-11-23 18:53:58 +0000
commit10e2dbbb9c49f1721b4d740bc102c10c742a7b76 (patch)
tree093ff3e39521d3bb266b1b78dc84235a2eaedc7b /program/js
parentd65dd9cbe81031244fd9af047a474bb08f6045ef (diff)
Improve clickjacking protection: bust frame or disable all form elements and abort UI initialization
Diffstat (limited to 'program/js')
-rw-r--r--program/js/app.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/program/js/app.js b/program/js/app.js
index d784f5354..cc1eeef15 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -145,6 +145,22 @@ function rcube_webmail()
for (n in this.gui_objects)
this.gui_objects[n] = rcube_find_object(this.gui_objects[n]);
+ // clickjacking protection
+ if (this.env.x_frame_options) {
+ try {
+ // bust frame if not allowed
+ if (this.env.x_frame_options == 'deny' && top.location.href != self.location.href)
+ top.location.href = self.location.href;
+ else if (top.location.hostname != self.location.hostname)
+ throw 1;
+ } catch (e) {
+ // possible clickjacking attack: disable all form elements
+ $('form').each(function(){ ref.lock_form(this, true); });
+ this.display_message("Blocked: possible clickjacking attack!", 'error');
+ return;
+ }
+ }
+
// init registered buttons
this.init_buttons();