Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keep getting "CSRF detected!"
#32
Tweaking edit.php that I mentioned in a post above was good till the moment I wanted to update css file of the theme of one of my 2.03 installs. In this case theme-edit.php comes into action so it would require a similiar tweak as edit.php. Instead of tweaking it I decided to observe the beast in the wild and made minor changes to both theme-edit.php and nonce.php to compare the variables compared in nonce.php. These variables must have been different to cause CSRF alert.
So I changed line 44 of theme-edit.php to
Code:
print("inner nonce=".$nonce);    if(!check_nonce($nonce, "save"))
and line 41 of nonce.php to
Code:
print("<br/>outer hash=".get_nonce($action, $file)."<br/>");    return ( $nonce === get_nonce($action, $file) );

Then I proceeded to the test:
-started Firefox
-logged in
-edited css theme file and saved it
-received:
Code:
inner nonce=5beb6ceea80bc2d3eef440e4f14b0db2753ccda3
outer hash=462faccca9b2d0f835db060a8964219a43399eb8
CSRF detected!

I wanted to check why is the $nonce passed from theme-edit.php different than the produced within nonce.php, but beforehand... as you can see form previous post: Google Chrome worked fine.
So I checked the same steps with Chrome:
-logged out
-started Chrome
-logged in
-edited css theme file and saved it
-received:
Code:
inner nonce=973d74b22c7dc7b07de581e9be2a30011d110502
outer hash=973d74b22c7dc7b07de581e9be2a30011d110502
identical as mono-zygotic twins this time.

Definitely not a cross-browser solution...

Ok, now back to firefox: why were nonces-schmonzes different in FF? This time no sha1 in line 28 of nonce.php (don't replicate without parental guidance!):
Code:
$hash=$action.$file.$ip.$USR.$SALT;

Firefox:
Code:
inner nonce=save/admin/theme-edit.php188.146.124.177Redakcjav4pwwe37necqoo1z1b0^1durtz4dh-unx1bz
outer hash=save/admin/theme-edit.php178.180.225.246Redakcjav4pwwe37necqoo1z1b0^1durtz4dh-unx1bz

Chrome:
Code:
inner nonce=save/admin/theme-edit.php188.147.29.93Redakcjav4pwwe37necqoo1z1b0^1durtz4dh-unx1bz
outer hash=save/admin/theme-edit.php188.147.29.93Redakcjav4pwwe37necqoo1z1b0^1durtz4dh-unx1bz
wow, what a miraculous browser...
Will IPs remain identical in FF?

firefox:
Code:
inner nonce=save/admin/theme-edit.php188.147.29.93Redakcjav4pwwe37necqoo1z1b0^1durtz4dh-unx1bz
outer hash=save/admin/theme-edit.php188.147.29.93Redakcjav4pwwe37necqoo1z1b0^1durtz4dh-unx1bz
Yes, as I wrote previously - once or twice a single use of Chrome removed CSRF for some time in FF, so above you can see why.

But, will IPs remain identical in FF from now on? That's what happened after a couple of minutes:
firefox:
Code:
inner nonce=save/admin/theme-edit.php188.146.57.204Redakcjav4pwwe37necqoo1z1b0^1durtz4dh-unx1bz
outer hash=save/admin/theme-edit.php178.180.109.170Redakcjav4pwwe37necqoo1z1b0^1durtz4dh-unx1bz

Sad... I am sorry my provider does it to IP, but does he do it really? Or may be some browsers change HTTP headers? So now I use solution from SamWM's post: change line 25 of nonce.php (remember my example is from 2.03) to
$ip = $_SERVER['REMOTE_ADDR'];$ip=true;
Reply


Messages In This Thread
Keep getting "CSRF detected!" - by todoesverso - 2011-04-17, 01:25:12
Keep getting "CSRF detected!" - by Connie - 2011-04-17, 01:37:53
Keep getting "CSRF detected!" - by todoesverso - 2011-04-17, 01:49:19
Keep getting "CSRF detected!" - by mikeh - 2011-04-17, 04:54:47
Keep getting "CSRF detected!" - by todoesverso - 2011-04-17, 07:22:22
Keep getting "CSRF detected!" - by nitsuj - 2011-04-20, 05:26:56
Keep getting "CSRF detected!" - by snooze - 2011-04-20, 09:37:11
Keep getting "CSRF detected!" - by Connie - 2011-04-20, 14:53:06
Keep getting "CSRF detected!" - by nitsuj - 2011-04-20, 17:31:26
Keep getting "CSRF detected!" - by Connie - 2011-04-20, 18:56:24
Keep getting "CSRF detected!" - by nitsuj - 2011-04-20, 20:45:52
Keep getting "CSRF detected!" - by Connie - 2011-04-20, 21:16:44
Keep getting "CSRF detected!" - by snooze - 2011-04-27, 03:33:38
Keep getting "CSRF detected!" - by snooze - 2011-04-27, 03:42:28
Keep getting "CSRF detected!" - by Connie - 2011-04-27, 04:42:27
Keep getting "CSRF detected!" - by Aron - 2011-04-27, 07:59:16
Keep getting "CSRF detected!" - by ccagle8 - 2011-04-27, 10:54:10
Keep getting "CSRF detected!" - by snooze - 2011-04-28, 01:12:31
Keep getting "CSRF detected!" - by ccagle8 - 2011-04-28, 01:29:47
Keep getting "CSRF detected!" - by snooze - 2011-04-28, 04:58:16
Keep getting "CSRF detected!" - by Aron - 2011-04-29, 06:39:49
Keep getting "CSRF detected!" - by ccagle8 - 2011-04-29, 23:49:57
Keep getting "CSRF detected!" - by SamWM - 2011-05-06, 21:17:34
Keep getting "CSRF detected!" - by ccagle8 - 2011-05-06, 22:43:05
Keep getting "CSRF detected!" - by SamWM - 2011-05-28, 01:52:33
Keep getting "CSRF detected!" - by RobA - 2011-05-28, 02:43:19
Keep getting "CSRF detected!" - by SamWM - 2011-06-10, 19:06:16
Keep getting "CSRF detected!" - by yojoe - 2011-06-10, 23:41:44
Keep getting "CSRF detected!" - by SamWM - 2011-06-11, 02:42:26
Keep getting "CSRF detected!" - by Ampersand - 2012-02-03, 05:16:15
Keep getting "CSRF detected!" - by Connie - 2012-02-03, 16:27:35
Keep getting "CSRF detected!" - by Ampersand - 2012-02-10, 04:09:42
Keep getting "CSRF detected!" - by shawn_a - 2012-02-11, 04:47:00
Keep getting "CSRF detected!" - by bugmenot - 2012-04-03, 15:21:47
Keep getting "CSRF detected!" - by Connie - 2012-04-03, 16:33:41
Keep getting "CSRF detected!" - by rfuller - 2012-04-04, 03:00:46



Users browsing this thread: 1 Guest(s)