add csrf protection

This commit is contained in:
Uwe Steinmann 2021-01-25 09:00:28 +01:00
parent 6dbcd3362f
commit 64152e0d0b
2 changed files with 6 additions and 0 deletions

View File

@ -38,6 +38,11 @@ function _printMessage($heading, $message) {
return; return;
} }
/* Check if the form data comes from a trusted request */
if(!checkFormKey('changepassword')) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_request_token"))),getMLText("invalid_request_token"));
}
if (isset($_POST["hash"])) { if (isset($_POST["hash"])) {
$hash = $_POST["hash"]; $hash = $_POST["hash"];
} }

View File

@ -51,6 +51,7 @@ document.form1.newpassword.focus();
$this->contentContainerStart(); $this->contentContainerStart();
?> ?>
<form class="form-horizontal" action="../op/op.ChangePassword.php" method="post" name="form1"> <form class="form-horizontal" action="../op/op.ChangePassword.php" method="post" name="form1">
<?php echo createHiddenFieldWithKey('changepassword'); ?>
<?php <?php
if ($referuri) { if ($referuri) {
echo "<input type='hidden' name='referuri' value='".$referuri."'/>"; echo "<input type='hidden' name='referuri' value='".$referuri."'/>";