protect form hijacking hack

依然范特西╮ 提交于 2019-12-08 19:55:31

Based on your comment…

Anything outside your server is outside your control. You must define what you want to let in at the border of your server, and not in the browser.

So, for example, if you want to let people send messages, then any restrictions you want to impose (only logged in users, only to friends, only when the moon is waxing, etc) must be imposed on the server.

What you send to the browser can be thought of as an application that interacts with your API. People might interact with your API in ways that you don't expect, but you are safe if all your security is taken care of by the server.

(Until we come onto the subject of man in the middle stuff, in which case look into CSRF prevention and encryption with SSL)

This vulnerability is called as Cross Site Request Forgery (CSRF). You must add a random token value in your form (input hidden).

$_SESSION['token'] = md5(rand()); //example
//ur code
if($_SESSION["token"] != $_POST["token"]){
    echo 'Invalid Request!';
}
else{
    //action
}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!