Skip to content

Commit 24d0eb5

Browse files
committed
Improved protection against cross framing
We now include CSS to hide the page and display it conditionally after checking we're in top frame. This adds extra protection for clients who do not support X-Frame-Options. See also http://en.wikipedia.org/wiki/Framekiller and https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet
1 parent 240b833 commit 24d0eb5

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

js/cross_framing_protection.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
/* vim: set expandtab sw=4 ts=4 sts=4: */
22
/**
3-
* Conditionally included if third-party framing is not allowed
4-
*
3+
* Conditionally included if framing is not allowed
54
*/
6-
7-
try {
8-
if (top != self) {
9-
top.location.href = self.location.href;
10-
}
11-
} catch(e) {
12-
alert("Redirecting... (error: " + e);
13-
top.location.href = self.location.href;
5+
if(self == top) {
6+
document.documentElement.style.display = 'block' ;
7+
} else {
8+
top.location = self.location ;
149
}

libraries/Header.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ private function _getMetaTags()
531531
$retval = '<meta charset="utf-8" />';
532532
$retval .= '<meta name="robots" content="noindex,nofollow" />';
533533
$retval .= '<meta http-equiv="X-UA-Compatible" content="IE=Edge">';
534+
$retval .= '<style>html{display: none;}</style>';
534535
return $retval;
535536
}
536537

0 commit comments

Comments
 (0)