Our production server has been producing invalid authenticity token errors for several months now. The errors are produced on almost all forms sending (PUT|POST|DELETE) requests. Sometimes the error occurs, sometimes they don't. There appears to be no rhyme or reason as to why they occur. The error itself does not occur often but it is a worry for us. Below is an example of what a typical form that causes this error looks like.
<form class="button_to" method="post" action="/lesson_progress_trackers/333">
<input type="hidden" name="_method" value="patch">
<input class="finish-lesson-button" type="submit" value="Done!">
<input type="hidden" name="authenticity_token" value="Qd3FsJZY2UXR9vahuFmaY5rrqA+J5xzGpl4cGI2Vwerx8PZPQtDMugz6oqoe3iviC+/U5zTYPdeX3apwbap09E==">
<input type="hidden" name="completed" value="true">
</form>
Here's what I've discovered so far.
- We use Turbolinks 2.5.3 (we have not updated this in over a year).
- In every case of an invalid token error, the user passed an authenticity token to the server, it just ended up being invalid.
- We currently use
protect_from_forgery with: :exception
in our application controller. - The errors started appearing when we pushed a bunch of new code to production several months ago. This new code spans hundreds of files but so far I've found nothing in the code that would be relevant to this issue.
- The error can occur on any type of browser and device.
- There is no correlation between increased traffic and the invalid auth tokens appearing.
- Users can come from any country.
- These are not bots experiencing these issues. We even had a colleague experience this error though they can't recall what they did to produce it.
- The users follow typical if not expected behavior. They are using the app as intended. I looked through their clicks and recorded behavior history to conclude this.
Ultimately I want to figure out how to solve this. My first step is to reproduce the error successfully, but I can't even do that. My question is this: what can I do to get me on my way to figuring out what's causing this? I am running out of options. Thanks!