How to best prevent CSRF attacks in a GAE app?

前端 未结 3 1017
-上瘾入骨i
-上瘾入骨i 2021-02-04 12:01

So, what is the best way to prevent an XSRF attack for a GAE application? Imagine the following:

  1. Anyone can see a user\'s public object, and the db.Model id is us
3条回答
  •  离开以前
    2021-02-04 12:16

    Simple: Check the referer. It's (deliberately) impossible to set this using Javascript, HTML forms, etc. If it's blank (some proxies and browsers strip referers) or from your own site - or more specifically from the expected source - allow it. Otherwise, deny it and log it.

    Edit: Jeff wrote a followup article with a couple of ways to prevent CSRF attacks.

提交回复
热议问题