Author: Jorg Sowa (jorgsowa) Committer: Derick Rethans (derickr) Date: 2026-12-01T13:21:34Z
Commit: https://github.com/php/web-wiki/commit/6661ed45983c333bf7edc2edea31044bb5727571 Raw diff: https://github.com/php/web-wiki/commit/6661ed45983c333bf7edc2edea31044bb5727571.diff Key doodle votes by the logged-in username and require a POST with a security token Votes were filed under a client-supplied fullname and accepted via GET without a token, allowing one account to cast many votes and votes to be forged via CSRF. Single-choice polls now accept exactly one choice. Changed paths: M dokuwiki/lib/plugins/doodle/syntax.php Diff: diff --git a/dokuwiki/lib/plugins/doodle/syntax.php b/dokuwiki/lib/plugins/doodle/syntax.php index 9518e36c..8175c393 100755 --- a/dokuwiki/lib/plugins/doodle/syntax.php +++ b/dokuwiki/lib/plugins/doodle/syntax.php @@ -235,7 +235,8 @@ function render($mode, Doku_Renderer $renderer, $data) { } // ----- FORM ACTIONS (only allowed when showing the most recent version of the page, not when editing) ----- $formId = 'doodle__form__'.cleanID($this->params['title']); - if ($ACT == 'show' && array_key_exists('formId', $_REQUEST) && $_REQUEST['formId'] == $formId && $REV == false && $can_vote) { + if ($ACT == 'show' && array_key_exists('formId', $_REQUEST) && $_REQUEST['formId'] == $formId && $REV == false && $can_vote + && $_SERVER['REQUEST_METHOD'] === 'POST' && checkSecurityToken()) { // ---- cast new vote if (!empty($_REQUEST['cast__vote'])) { $this->castVote(); @@ -353,7 +354,7 @@ function castVote() { return; } - $fullname = hsc(trim($_REQUEST['fullname'])); + $fullname = $_SERVER['REMOTE_USER']; $selected_indexes = $_REQUEST['selected_indexes']; // may not be set when all checkboxes are deseleted. if (empty($fullname)) { @@ -368,6 +369,10 @@ function castVote() { return; } } + if (!is_array($selected_indexes) || ($this->params['voteType'] != 'multi' && count($selected_indexes) != 1)) { + $this->template['msg'] = $this->getLang('select_one_option'); + return; + } //---- check if user is allowed to vote, according to 'auth' parameter @@ -472,7 +477,7 @@ function isAllowedToEditEntry($entryFullname) { } //check own entry - return strcasecmp(hsc($INFO['userinfo']['name']), $entryFullname) == 0; // compare real name + return $_SERVER['REMOTE_USER'] === (string) $entryFullname; } /** @@ -502,7 +507,7 @@ function getInputTR() { $fullname = ''; $editMode = false; if ($this->isLoggedIn()) { - $fullname = $INFO['userinfo']['name']; + $fullname = $_SERVER['REMOTE_USER']; if (isset($this->template['editEntry'])) { $fullname = $this->template['editEntry']['fullname']; $editMode = true;
