Are JSON web services vulnerable to CSRF attacks?

后端 未结 5 1464
故里飘歌
故里飘歌 2020-12-02 06:06

I am building a web service that exclusively uses JSON for its request and response content (i.e., no form encoded payloads).

Is a web service vulnerable to

5条回答
  •  醉酒成梦
    2020-12-02 06:20

    It is possible to do CSRF on JSON based Restful services using Ajax. I tested this on an application (using both Chrome and Firefox). You have to change the contentType to text/plain and the dataType to JSON in order to avaoid a preflight request. Then you can send the request, but in order to send sessiondata, you need to set the withCredentials flag in your ajax request. I discuss this in more detail here (references are included):

    http://wsecblog.blogspot.be/2016/03/csrf-with-json-post-via-ajax.html

提交回复
热议问题