JavaScript: Difference between revisions

Content deleted Content added
revert; not general-purpose; non-scripting uses are niche; citation would be needed
Cross-site vulnerabilities: JSON>information. it's not all JSON; removed the part about the comment. that makes no sense and doesn't work.
Line 355:
Another cross-site vulnerability is [[cross-site request forgery]] or CSRF. In CSRF, code on an attacker's site tricks the victim's browser into taking actions the user didn't intend at a target site (like transferring money at a bank). It works because, if the target site relies only on cookies to authenticate requests, then requests initiated by code on the attacker's site will carry the same legitimate login credentials as requests initiated by the user. In general, the solution to CSRF is to require an authentication value in a hidden form field, and not only in the cookies, to authenticate any request that might have lasting effects. Checking the HTTP Referrer header can also help.
 
"JavaScript hijacking" is a type of CSRF attack in which a <script> tag on an attacker's site exploits a page on the victim's site that returns private information such as JSON or JavaScript. Possible solutions include:
* requiring an authentication token in the POST and GET parameters for any response that returns private [[JSON]] (even if it has no side effects);information
* using POST and never GET for requests that return private JSON; and modifying the response so that it can't be used via a <script> tag (by, for example, wrapping the JSON in a JavaScript comment).information
 
====Misplaced trust in the client====