Matrix Networks And Solutions - Cross-site scripting - Impact

What is cross-site scripting?

 · 2 min read

Cross-site scripting (XSS) is an exploit where the attacker attaches code onto a legitimate website that will execute when the victim loads the website. That malicious code can be inserted in several ways. Most popularly, it is either added to the end of a url or posted directly onto a page that displays user-generated content. In more technical terms, cross-site scripting is a client-side code injection attack.



What is an example of cross-site scripting?


One useful example of cross-site scripting attacks is commonly seen on websites that have unvalidated comment forums. In this case, an attacker will post a comment consisting of executable code wrapped in ‘<script></script>’ tags. These tags tell a web browser to interpret everything between the tags as JavaScript code. Once that comment is on the page, when any other user loads that website, the malicious code between the script tags will be executed by their web browser, and they will become a victim of the attack.



How can an attacker use cross-site scripting to cause harm?


JavaScript cross-site scripting attacks are popular because JavaScript has access to some sensitive data that can be used for identity theft and other malicious purposes. For example, JavaScript has access to cookies*, and an attacker could use an XSS attack to steal a user’s cookies and impersonate them online. JavaScript can also create HTTP requests, which can be used to send data (such as stolen cookies) back to the attacker. Additionally, client-side JavaScript can also help an attacker gain access to APIs that contain geolocation coordinates, webcam data, and other sensitive information.


A typical cross-site scripting attack flow is as follows:


  1. The victim loads a webpage, and the malicious code copies the user’s cookies
  2. The code then sends an HTTP request to an attacker’s webserver with the stolen cookies in the body of the request.
  3. The attacker can then use those cookies to impersonate the user on that website for the purpose of a Social Engineering Attack or even to access bank account numbers or other sensitive data.


*Cookies are temporary login credentials saved on a user’s computer. For example when a user logs onto a site like Facebook, the site gives them a cookie so that if they close the browser window and go back to Facebook later that day, they are automatically authenticated by the cookie and won’t need to login again




No comments yet.

Add a comment
Ctrl+Enter to add comment