mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-11-29 08:56:03 +00:00
Added CSRF to the application (took in account backwards compatibility)
Mitigated the XSS vulnerabilities reported by HackDefense Advisories for said vulnerabilities can be found here: https://hackdefense.com/publications/cve-2019-18345-davical-caldav-server-vulnerability https://hackdefense.com/publications/cve-2019-18346-davical-caldav-server-vulnerability https://hackdefense.com/publications/cve-2019-18347-davical-caldav-server-vulnerability
This commit is contained in:
1 parent
710bc6cccd
commit
86a8ec5302
6 files changed
+195
-2
No files matched your search
+7
-1
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once('./always.php');
|
||||
require_once('classEditor.php');
|
||||
require_once('classBrowser.php');
|
||||
@@ -25,7 +26,12 @@ require_once('interactive-page.php');
|
||||
$page_elements = array();
|
||||
$code_file = sprintf( 'ui/%s-%s.php', $component, $action );
|
||||
if ( ! @include_once( $code_file ) ) {
|
||||
$c->messages[] = sprintf('No page found to %s %s%s%s', $action, ($action == 'browse' ? '' : 'a '), $component, ($action == 'browse' ? 's' : ''));
|
||||
$c->messages[] = sprintf(
|
||||
'No page found to %s %s%s%s',
|
||||
htmlspecialchars($action),
|
||||
($action == 'browse' ? '' : 'a '), $component,
|
||||
($action == 'browse' ? 's' : '')
|
||||
);
|
||||
include('page-header.php');
|
||||
include('page-footer.php');
|
||||
@ob_flush(); exit(0);
|
||||
|
||||
@@ -8,6 +8,47 @@
|
||||
|
||||
if ( preg_match('{/always.php$}', $_SERVER['SCRIPT_NAME'] ) ) header('Location: index.php');
|
||||
|
||||
// XSS Protection
|
||||
function filter_post(&$val, $index) {
|
||||
if(in_array($index, ["newpass1", "newpass2"])) return;
|
||||
|
||||
switch (gettype($val)) {
|
||||
case "string":
|
||||
$val = htmlspecialchars($val);
|
||||
break;
|
||||
|
||||
case "array":
|
||||
array_walk_recursive($val, function(&$v) {
|
||||
if (gettype($v) == "string") {
|
||||
$v = htmlspecialchars($v);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function clean_get() {
|
||||
$temp = [];
|
||||
|
||||
foreach($_GET as $key => $value) {
|
||||
// XSS is possible in both key and values
|
||||
$k = htmlspecialchars($key);
|
||||
$v = htmlspecialchars($value);
|
||||
$temp[$k] = $v;
|
||||
}
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
// Before anything else is executed we filter all the user input, a lot of code in this project
|
||||
// relies on variables that are easily manipulated by the user. These lines and functions filter all those variables.
|
||||
if(isset($_POST)) array_walk($_POST, 'filter_post');
|
||||
$_GET = clean_get();
|
||||
$_SERVER['REQUEST_URI'] = str_replace("&", "&", htmlspecialchars($_SERVER['REQUEST_URI']));
|
||||
$_SERVER['HTTP_REFERER'] = htmlspecialchars($_SERVER['HTTP_REFERER']);
|
||||
|
||||
|
||||
|
||||
// Ensure the configuration starts out as an empty object.
|
||||
$c = (object) array();
|
||||
$c->script_start_time = microtime(true);
|
||||
|
||||
Reference in new issue
Block a user