verifyCSRFToken fails randomly
Environment: CF2016 + patch17
OS: Windows
Session Enabled and hosted via Elasticache (Redis)
Multi-instance environment
Load: A LOT
Given the two functions:
/**
* Method used to create a CSRF token, mainly used for login forms - Returns string
*
* tokenKey - optional, string. Unique key. Must also be used for decoding the token
* forceNew - optional, boolean. Defualt to true. Will create new token each time the method is called
**/
public string function generateCSRFToken( string tokenKey='some-special-key', boolean forceNew=true ){
return CSRFGenerateToken( arguments.tokenKey, arguments.forceNew );
}
/**
* Method used to verify a CSRF token, mainly used for login forms - Returns string
*
* token - required, string. The token to be verified
* tokenkey - optional, string. Defualt to true. Will create new token each time the method is called
**/
public boolean function verifyCSRFToken( required string token, string tokenKey='some-special-key' ){
return CSRFVerifyToken( arguments.token, arguments.tokenKey ) ? true : false;
}
The way I understood the CSRFGenerateToken() function, it creates a token and sticks it into the session. Given that our multi-instance environment is using the same Elasticache service (to prevent session duplication) and so the session is shared on all instances, I would assume that the CSRFVerifyToken() would not have an issue verifying the token (presummably that is in the session). For some very ODD reason, it fails for random users - I don't have any debug information other than when the CSRFVerifyToken() function is called, it returns false.
Thoughts?
