why is ouputing html through php security risk using cookie? -
im relatively new php , hoping me understand why should sanitize html when 'echo'ing , specially if data cookie..
i.e instead of
<h3>hello, <?php echo $_cookie['user']; ?>!</h3> you should do
<h3>hello, <?php echo htmlspecialchars($_cookie['user']); ?>!</h3> this understand.
cookies stored on client side, hence security risk since data in them can manipulated/changed evil users (lol @ evil) .
but since cookie stored on client side, means client can change own cookie, means if adds kind of malicious code $_cookie['user'] , when cookie run, malicious code shown 1 user (who changed cookie in first place) , no 1 else!? whats problem?
you're assuming user changed own cookie. cookies can changed third-party (edit: using additional software. third-party websites cannot change cookie directly). enable inject malicious code user's browser, changing user experience , potentially posing additional security risk code.
Comments
Post a Comment