You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add CSRF for logout
* Prevent get/post requests from unknown domains
* Update changelog
* Limit connections to server port and 443 (SSL)
* Load first sys config
* Orgin is on GET not always set
* Add missing links for normal users and reset password
* Move all links to a var on top of the page
* Use HTTP_REFERER instead
* Add missing ;
* Fix version installer
Without referer exceptions list not working
* Improve error message
Include logout also in csrf check
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
8
8
9
9
### Bugfixes
10
10
- Improve the hostname check to prevent invalid hostnames or the use of an ip address (RFC1178).
11
+
- Prevent CSRF from other domains / websites
12
+
- Fix #2096 Hostname SSL got overwritten by mail.hostname.com certificate
11
13
- Add small wait for /usr/bin/iptables-restore [Forum](https://forum.hestiacp.com/t/clean-install-arm64-does-not-start-after-reboot-v-start-service-iptables/4395/7)
12
14
- Fix bug in v-change-sys-api. When using v-change-sys-api remove and then v-change-sys-api enable + custom release branch the resetting of api failed + no "error" output was producted
if ( $_SERVER['SCRIPT_FILENAME'] == '/usr/local/hestia/web/inc/mail-wrapper.php '){ $check_csrf=false; } // execute only from CLI
5
+
if ( $_SERVER['SCRIPT_FILENAME'] == '/usr/local/hestia/web/reset/mail/index.php '){ $check_csrf=false; } // Localhost only
6
+
if ( $_SERVER['SCRIPT_FILENAME'] == '/usr/local/hestia/web/api/index.php' ){ $check_csrf=false; } // Own check
7
+
if (substr($_SERVER['SCRIPT_FILENAME'], 0, 22)=='/usr/local/hestia/bin/' ){ $check_csrf=false; }
8
+
9
+
functioncheckStrictness($level){
10
+
if ($level >= $_SESSION['POLICY_CSRF_STRICTNESS']) {
11
+
returntrue;
12
+
}else{
13
+
echo"<h1>Potential use CSRF detected</h1>\n".
14
+
"<p>Please disable any plugins/add-ons inside your browser or contact your system administrator. If you are the system administrator you can run v-change-sys-config-value 'POLICY_CSRF_STRICTNESS' '0' as root to disable this check.<p>".
15
+
"<p>If you folowed a bookmark or an static link <a href='/'>please click here</a>";
16
+
die();
17
+
}
18
+
}
19
+
functionprevent_post_csrf(){
20
+
if ($_SERVER['REQUEST_METHOD']=='POST') {
21
+
$hostname = explode( ':', $_SERVER['HTTP_HOST']);
22
+
$port=$hostname[1];
23
+
$hostname=$hostname[0];
24
+
if (strpos($_SERVER['HTTP_ORIGIN'],gethostname()) !== false && in_array($port, array('443',$_SERVER['SERVER_PORT'])) ) {
25
+
returncheckStrictness(2);
26
+
}else{
27
+
if (strpos($_SERVER['HTTP_ORIGIN'],$hostname) !== false && in_array($port, array('443',$_SERVER['SERVER_PORT'])) ){
28
+
returncheckStrictness(1);
29
+
} else {
30
+
returncheckStrictness(0);
31
+
}
32
+
}
33
+
}
34
+
}
35
+
36
+
functionprevent_get_csrf(){
37
+
if ($_SERVER['REQUEST_METHOD']=='GET') {
38
+
$hostname = explode( ':', $_SERVER['HTTP_HOST']);
39
+
$port=$hostname[1];
40
+
$hostname=$hostname[0];
41
+
//list of possible entries route and these should never be blocked
42
+
if (in_array($_SERVER['DOCUMENT_URI'], array('/list/user/index.php', '/login/index.php','/list/web/index.php','/list/dns/index.php','/list/mail/index.php','/list/db/index.php','/list/cron/index.php','/list/backup/index.php','/reset/index.php'))){
43
+
returntrue;
44
+
}
45
+
if (strpos($_SERVER['HTTP_REFERER'],gethostname()) !== false && in_array($port, array('443',$_SERVER['SERVER_PORT'])) ) {
46
+
returncheckStrictness(2);
47
+
}else{
48
+
if (strpos($_SERVER['HTTP_REFERER'],$hostname) !== false && in_array($port, array('443',$_SERVER['SERVER_PORT'])) ){
0 commit comments