Too many CSRF tokens generated (PHP), how do I deal with them? -


i run problem. following owasp cheatsheet, implemented one-time-use csrf token system in php (basically copy&paste owasp). each form or link (link generate action) create own csrf token, once it's used, deleted. application website, multiples tabs opened @ same time.

the problem each time load page, create new csrf token (even if hit reload , not send form). example, in admin panel, there's list of items, each item deleted link have csrf token (same csrf token links), if reload page, new csrf generated.

at end of day, ended more un-used tokens wanted to. problem in servers.

tldr; generate token per request. deleted used token (except ajax request tokens, after hour delete then). problem unused tokens, @ end of day, there're many of them.

there no (practical) way of knowing if user still use token or not. thus, have automatically delete (and invalidate) them after x hours, example using cronjob.

just suggestion: sure need one-time tokens? owasp not absolutely necessary security: "in general, developers need generate token once current session. [...]) (https://www.owasp.org/index.php/cross-site_request_forgery_%28csrf%29_prevention_cheat_sheet).

keep in mind one-time tokens make tabbed browsing or using browser history huge pain.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -