jQuery GetJSON Security Issues. Copying URL and pasting in the browser

前端 未结 2 1457
醉梦人生
醉梦人生 2021-01-14 20:57

I am using the jQuery GetJSON call in my ASP page. It is something like the following code:

$.ajax({
    url: myUrl/myPage.aspx?callback=BookARoom,
    dataT         


        
2条回答
  •  粉色の甜心
    2021-01-14 21:38

    There are two problems here.

    First problem: GET requests are supposed to be safe. There are lots of things that can trigger a GET request. If you are changing state based on a GET request, your code is dangerously broken. Use POST.

    Secondly, other websites can cause your user to make requests to your website. This is known as Cross-Site Request Forgery. The typical solution is to require a nonce with each request. Because the nonce is unknown to the other website, they can no longer forge requests. The link I provided will give you further reading on alternative solutions.

提交回复
热议问题