dongtui4038 2012-04-04 05:50
浏览 39
已采纳

是否应为每个请求包含csrf令牌?

Supose that the users have private content on their account . Like any social websites , when they browse their account , the users can see alot of things about them . Are all of those requests tokenised? Is it a good ideea to make a pattern and tokenise all requests and check them before they are processed ? Any sugestion ?
Do all apps based on private accounts system tokenise all requests?

P.S. : here is a possible attack : the user logs in a social website ("x"), stays loged in , goes to another website ("y") . Website y has a button that gets the first page content of the x site which includes users latest posts . Since the user is loged in , the data will show ...

How would you set up a csrf token mechanism for each request? Set up a middle process that redirects the request to the final processing page if its a valid request? or ... any other ideeas ? Am i wrong here ? Do i see things wrong?

Here i asked same question and got the right final answer : https://stackoverflow.com/a/10006276/1284817 . The validated answer here is good to read about it too .

  • 写回答

1条回答 默认 最新

  • dongsi4547 2012-04-04 06:43
    关注

    CSRF tokens are only normally attached to things that change things on the users behalf (e.g. POST requests). Protecting attackers from viewing private data is much simpler, and indeed is baked right in to all popular browsers:

    To protect attackers viewing private data (rather than modifying it) you would usually rely on the browser's same origin policy, and ensuring your requests do not support Cross-origin resource sharing

    In the specific example of the attack you suggest, the attacker requests example.org/private and the browser will throw an exception which looks like this on my browser:

    XMLHttpRequest cannot load http://example.org/private. Origin http://attacker.com is not allowed by Access-Control-Allow-Origin.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Matlab在app上输入带有矩阵形式的初始条件发生错误
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 用ADS设计一款的射频功率放大器