Reiners Wrote:
-------------------------------------------------------
> hm both are good ideas indeed, but impractical for
> static analysis.
>
>
>
>
> <?php echo csrfToken(); ?>
>
>
>
> you can't really tell with static analysis if the
> user is logged in (or what session properties he
> holds) nor if the function csrfToken() builds a
> random token or a captcha or whatever.
> however for dynamic analysis it would be a good
> way to go.
While I agree that it is probably impractical, it isn't necessarily impossible.
When I opened this topic my first thought was that there is no way to detect CSRF because it is business logic, however it's not completely true.
If we assume that any page that writes to the database or other persistent store needs csrf protectiom, then you could potentially use model checking or similar to see if it is possible to reach the code path where the persistent store is altered without being able to read the page. Even if you cannot create the response, you would be left with a set of variables that you need to know, which would be something to do further analysis on.
Of course, there will be writes that are unimportant, but you could potentially mark certain databases or columns safe to write to, e.g. a user visit statistics table.
Maybe take a look at Microsoft's SAGE fuzzer, it seems that kind of technology could potentially be applied here.
One of the things you will probably miss here though is relationships between pages, e.g. if you have a page somewhere that reseeds a prng with time(), the prng is broken everywhere, but you're not going to know that unless you scan for that first.
P.S. If anyone works on this, send me an email, I'd be keen to see how this goes :)
----------------------------------------------------------
Don't forget our IRC: irc://irc.irchighway.net/#slackers
[
kuza55.blogspot.com]
Edited 3 time(s). Last edit at 09/12/2010 06:02PM by kuza55.