Changeset 5476 in subversion


Ignore:
Timestamp:
Nov 23, 2011 1:53:58 PM (18 months ago)
Author:
thomasb
Message:

Improve clickjacking protection: bust frame or disable all form elements and abort UI initialization

Location:
trunk/roundcubemail/program
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_template.php

    r5471 r5476  
    7272        //$this->framed = $framed; 
    7373        $this->set_env('task', $task); 
     74        $this->set_env('x_frame_options', $this->app->config->get('x_frame_options', 'sameorigin')); 
    7475 
    7576        // load the correct skin (in case user-defined) 
  • trunk/roundcubemail/program/js/app.js

    r5475 r5476  
    145145    for (n in this.gui_objects) 
    146146      this.gui_objects[n] = rcube_find_object(this.gui_objects[n]); 
     147 
     148    // clickjacking protection 
     149    if (this.env.x_frame_options) { 
     150      try { 
     151        // bust frame if not allowed 
     152        if (this.env.x_frame_options == 'deny' && top.location.href != self.location.href) 
     153          top.location.href = self.location.href; 
     154        else if (top.location.hostname != self.location.hostname) 
     155          throw 1; 
     156      } catch (e) { 
     157        // possible clickjacking attack: disable all form elements 
     158        $('form').each(function(){ ref.lock_form(this, true); }); 
     159        this.display_message("Blocked: possible clickjacking attack!", 'error'); 
     160        return; 
     161      } 
     162    } 
    147163 
    148164    // init registered buttons 
Note: See TracChangeset for help on using the changeset viewer.