I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
11–20 of 80 posts
Re: I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
#12Re: I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
#13Can somebody post the tldr?
Re: I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
#14I love spelunking problems like this, it's quite the rush when you finally crack it.
Re: I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
#15Re: I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
#161. Rails 2.3.11 introduced two subtle changes:
- CSRF tokens have to be included in XHR POST requests
- failing the CSRF check silently resets the session instead of throwing an exception
2. A/Bingo (his A/B testing library) checks if visitors are human with an XHR POST request. He did not notice that he needed to patch it to include the Rails CSRF token.
3. Race Condition: When the login/signup page is loaded, usually the A/Bingo human check will fail the CSRF check and reset the session, and A/Bingo will mark the visitor as human, all before the visitor logs in. The session won't be reset again, because A/Bingo will remember that the visitor is human. However, if the visitor is very fast and logs in/signs up before the A/Bingo human check goes through, it might not be until later in the session that the human check missing the CSRF token resets the session, prompting the visitor to log in again. Now that the session has been reset and the visitor marked human, it won't happen again.
4. His analytics indicated referral stats were way below normal because the referrer was usually getting reset with the session at the login/signup page. The only time his analytics libraries would log the referrer correctly was when the very fast visitors logged in/signed up before the human check missing the CSRF token reset their session.
Lessons:
- Race conditions are hard to track down.
- When analytics indicates something is way out of the ordinary, don't procrastinate tracking down the problem.
- Don't dismiss bugs because they (seem) irreproducible. Figure out how to reproduce them.
Re: I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
#17I'm probably missing something, but missed sessions in Ruby? Doesn't this affect almost everyone using Ruby? What makes this a minor bug for most people?
On top of that, most sites that use AJAX heavily and have this bug have it happen frequently enough that they investigate and fix it. In this case, the author's Javascript ran infrequently and unpredictably enough to make it difficult to trace (interestingly, having dealt with this issue before, I guessed the cause by the third paragraph).
It's the same principle behind the ThinkGeek Annoy-a-Tron. A loud, constant noise will drive you to look for it within seconds, and you'll probably be able to find it. But a brief chirp that happens semirandomly every fifteen minutes is incredibly hard to track down.
Re: I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
#18Debugging this sort of issue, finding the cause, and coming up with a solution is like brain candy to me. I love to do it, and I love to read it.
Re: I Saw An Extremely Subtle Bug Today And I Just Have To Tell Someone
#19Doesn't this change a CSRF attempt into a DoS? I don't understand the logic behind this change. Why not return an error response?