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 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示