Ticket #154 (closed enhancement: fixed)
Adding Random Tokens for Form Submissions
| Reported by: | Ian Andolina (copied by NilsLindenberg) | Owned by: | DarTar |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.1.6.7 |
| Component: | core | Version: | 1.1.6.5 |
| Severity: | minor | Keywords: | spam, forms, trunk-ported |
| Cc: | JavaWoman |
Description (last modified by BrianKoontz) (diff)
Based on this post, I wonder whether providing randomised session tokens for form submission may provide just one more step to impede spambots. Very simple to implement:
wikka.php:
function FormOpen($method = "", $tag = "", $formMethod = "post")
{
if(!isset($_SESSION['token'])) {
$token = md5(uniqid(rand(), true));
$_SESSION['token'] = $token;
}
$result = "<form action=\"".$this->Href($method, $tag)."\" method=\"".$formMethod."\"><p>\n";
$result .= "<input type=\"hidden\" name=\"token\" value=\"".$_SESSION['token']."\" />";
if (!$this->config["rewrite_mode"]) $result .= "<input type=\"hidden\" name=\"wakka\" value=\"".$this->MiniHref($method, $tag)."\" />\n";
return $result;
}
and then just wrap edit.php and addcomment.php sections using:
if ($_POST['token'] == $_SESSION['token']) { //form spoof protection
}
I'm definitely no expert on security, and I can see how it can be bypassed, but it does require one more step and adds complexity for spambots to spoof the wiki forms at no cost... --IanAndolina
Good point, Ian. I had been thinking about a similar approach (I have a plugin for SquirrelMail installed that essentially does the same thing for the login dialog) - but reading therough the comments on Chris Shiflett's article it's clear that this is no more than another little hurdle easily overcome by the script-writing link spammer (GET the page with the script first, read the token and use that in the scripted POST). That said, it is another hurdle that may deter at least some naive spammers - and with very little code. So, nice. --JavaWoman (who suddenly realizes her Squirrelmail isn't as secure as she thought it was - but at least has built in other layers of security)
Related Tickets
#855 Adding Random Tokens for Edit Form Submissions
#889 Form IDs need to be regenerated after each form submission