Forum Moderators: coopster
I developed a site and yesterday, accessing him, saw that it owns a bug.
Authenticate system is via cookies, it owns 3 cookies, one with the user name, other with the password and another with the iD. However if change cookie( name ) he changes the user name and lets the same continues navigating with login that wish( and until post goods as if it was other person )
Below it follows the code that I did and that is not working:
<?
include("db.php");
$user = @$_COOKIE["user"];
$pass = @$_COOKIE["pass"];
$id = @$_COOKIE["id"];
$query = mysql_query("SELECT * FROM users WHERE BINARY id='$id' AND user='$user' AND pass='$pass' LIMIT 1");
if(!$query){
setcookie("id");
setcookie("user");
setcookie("pass");
header("Location: /");
}
?>
Would anybody know to help?
Anybody know some security site in files PHP? With tutorials, hints, etc? When I do a site for customers, I am afraid to of being invaded and the customer thinks I am incompetent :(
At once I thank.
Robson
Anybody know some security site in files PHP? With tutorials, hints, etc? When I do a site for customers, I am afraid to of being invaded and the customer thinks I am incompetent
i see. you should start at php.net when you can read and understand english quite ok, otherwise there should be sites linked in your own language there. just browse a bit around there.
it might be a good advise for your to get in touch with a php usergroup next to your city. checkout your countries php related page here:
[php.net...]
i don't want to be harsh so please don't be offended, but even the small piece of code you provided here has got serious security issues and should not be used unchanged. if you really want to professionally offer your php code you should get in contact with a webapplication / php security consult. i guess you already thought so by asking for a security site here. one start for that specific thing might be [phpsec.org...] which contains some articles to read through.
for sessions your users only need to have cookies enabled (there is workaround for no-cookies even).
the code you provided uses cookies directly which is a bit unsafe. with sessions, only the sessionid is saved in a cookie and the data according to it remains on the server only. so this can not be that easy manipulated and is more safe.
Now already of the to search tutorials about that and to read post that jatar_k put.
That safety subject is very important because if anybody invade the site the problem is not to erase the data ( that a backup solves ) but the site image gets a little burnt. An aspect of insecurity.
Sorry my english.
But thank you very much.
Robson