diff --git a/misuzu.php b/misuzu.php index c100ed18..6531fc47 100644 --- a/misuzu.php +++ b/misuzu.php @@ -287,11 +287,11 @@ MIG; tpl_add_filter('vsprintf'); tpl_add_filter('perms_check'); tpl_add_filter('bg_settings', 'user_background_settings_strings'); - tpl_add_filter('csrf', 'csrf_html'); tpl_add_function('git_commit_hash'); tpl_add_function('git_tag'); tpl_add_function('csrf_token'); + tpl_add_function('csrf_input', 'csrf_html'); tpl_add_function('startup_time', function (float $time = MSZ_STARTUP) { return microtime(true) - $time; }); diff --git a/public/auth.php b/public/auth.php index 59ed9480..691de59d 100644 --- a/public/auth.php +++ b/public/auth.php @@ -81,6 +81,11 @@ switch ($authMode) { tpl_var('auth_reset_message', "A verification code should've been sent to your e-mail address."); while ($isSubmission) { + if (!csrf_verify('passreset', $_POST['csrf'] ?? '')) { + tpl_var('auth_reset_error', 'Possible request forgery detected, refresh and try again.'); + break; + } + if (!user_recovery_token_validate($resetUser['user_id'], $authVerification)) { tpl_var('auth_reset_error', 'Invalid verification code!'); break; diff --git a/templates/_layout/comments.twig b/templates/_layout/comments.twig index 6e872a77..c19dab40 100644 --- a/templates/_layout/comments.twig +++ b/templates/_layout/comments.twig @@ -1,14 +1,16 @@ {% macro comments_input(category, user, perms, reply_to) %} {% set reply_mode = reply_to is not null %} + {% from '_layout/input.twig' import input_hidden, input_csrf %} +