Blog-Layout

Cross Site Scripting

Christian Vierschilling • Sept. 03, 2021

For English, please scroll to the end of this blog article
Für Englisch, scrollen Sie bitte an das Ende dieses Blogartikels

From a high level, cross site scripting (short: XSS) can be described as the embedding of foreign code into a trusted context for execution. Technically speaking, XSS describes a client-side injection attack in which an attacker aims to execute malicious code in a web browser of the victim by including mostly malicious JavaScript in a legitimate web page or web application. The actual attack will occur when the victim visits the target web application that executes the malicious code. It is important to understand that the web application becomes merely a vehicle to deliver the malicious code for attacking the user – the targeted web application is not being attacked itself. Typically, an attacker would look for XSS vulnerabilities on web applications allowing comments, forums, message boards or any other component of a web application that allows user input to be embedded in the sites’ contents.

Usually when verifying XSS vulnerabilities, attackers tend to trigger alert boxes to demonstrate code execution within the browser. Such an alert box after a successful XSS attack might look like this:

This alert box has been spawned on a demo web application by accessing the following link:

https://x.x.x.x/search.php?keyword=cats<script>alert(‘XSS demo by e2 Security!’)</script> 

If this was a real web application vulnerable to an XSS attack, an attacker might now send the link above to a victim of choice, hoping for him to access the link. As the web application seems to embed the user input into its own context without any sanitization or encoding, a malicious JavaScript is likely to be executed in the victims’ browser.

 

What is the risk?
If a XSS vulnerability has been identified, an attacker will most likely try to insert JavaScript because of the vast amount of possibilities. By doing so, an attacker could then try to:

  • steal session information to access the web application himself
  • trigger actions within the same or a different web application on behalf of the user – also known as Cross Site Request Forgery (short: CSRF)
  • exfiltrate accessible information (e.g. personal data of the attacked user, keystrokes (via Keylogger) etc.)
  • directly attack the users’ system by exploiting potentially existing vulnerabilities in the used web browser

While the risk of falling victim to a cross-site scripting attack thus lies mainly with the users of web applications, an affected company could potentially suffer reputational damage and data protection problems if their web applications are vulnerable. However, if a XSS attack reaches users with elevated privileges within the target web application (e.g. administrator accounts) or even users with access to the internal corporate network, the damage dealt could be significantly higher.

 

How to remediate?
The organization OWASP provides guidance for various software and application security use cases. Within its’ series of cheatsheets, they mention some specially crafted rules to prevent XSS vulnerabilities at all. Please note that we will briefly mention a few of them here, while the full list can be accessed on the respective website [1]:

  • Rule #0: Never insert untrusted data except in allowed locations
  • Rule #1: HTML encode before inserting untrusted data into HTML element content
  • Rule #2: Attribute encode before inserting untrusted data into HTML common attributes
  • Rule #6: Sanitize HTML markup with a library designed for the job
  • Bonus Rule #1: Use HTTPOnly cookie flag
  • Bonus Rule #2: Implement Content Security Policy

Though in some cases a web application firewall might support in protecting against XSS attacks, the rules presented by OWASP are considered more effective in the long run. These rules are meant to be applied at the level of a web servers’ configuration and the web applications’ source code.

 

Real life examples
Since XSS is comparably easy to identify, many vulnerabilities are reported every day. At this point we provide two current examples regarding XSS vulnerabilities, not just demonstrating how to spawn alert boxes, but showing the severity and complexity in the execution and remediation of these vulnerabilities:

  • How one XSS bug in Google Chrome took 2.5 years to fix [2]
  • Chaining multiple vulnerabilities (including XSS) to achieve a critical remote code execution [3]

 

Der Beitrag Cross Site Scripting erschien zuerst auf e2 Security.

von Radha Mehta 09 Nov., 2023
GERMAN: Die nächste Grenze der Cybersicherheit: KI und ML revolutionieren die Cybersicherheit, indem sie intelligentere Verteidigungsmaßnahmen und adaptives Lernen ermöglichen. Diese Technologien verbessern die Erkennung von Bedrohungen und die Effizienz der Reaktion. Neue Herausforderungen wie feindliche Angriffe erfordern jedoch eine Mischung aus neuen und traditionellen Sicherheitsansätzen.
von Radha Mehta 12 Okt., 2023
GERMAN: In einer Zeit, in der sich Cyber-Bedrohungen in einem noch nie dagewesenen Tempo weiterentwickeln, ist die Notwendigkeit robuster Sicherheitsmaßnahmen unübersehbar. Da Unternehmen ihren digitalen Fußabdruck immer weiter ausdehnen, wird es immer schwieriger, einen engen Sicherheitsrahmen aufrechtzuerhalten. Die Nachfrage nach zeitnahen und effektiven Penetrationstests ist gestiegen, was zur Konvergenz von maschinellem Lernen und Cybersicherheit geführt hat und eine neue Ära der automatisierten Penetrationstests einläutete.
von Ibrahim Husić & Justin Shabani 12 Sept., 2023
GERMAN: In einer zunehmend vernetzten Welt, in der unsere Abhängigkeit von digitalen Systemen stetig wächst, sind wir auch anfälliger für eine dunkle Bedrohung namens Ransomware. Diese bösartige Software hat in den letzten Jahren einen erschreckenden Aufschwung erlebt und richtet erheblichen Schaden an. In diesem Artikel werden wir uns eingehend mit der Welt der Ransomware beschäftigen, ihre Entstehung, ihre Ziele und die Motivationen hinter diesen Cyberangriffen. Die Einführung in Ransomware Ransomware ist eine Art von Schadsoftware, die entwickelt wurde, um den Zugriff auf Computersysteme oder Daten zu blockieren, bis eine Geldsumme (Lösegeld) bezahlt wird. Typischerweise verschlüsselt Ransomware die Dateien des Opfers und fordert die Zahlung in Kryptowährung für den Entschlüsselungsschlüssel. Es ist beängstigend zu wissen, dass Ransomware-Angriffe in den letzten fünf Jahren um 13% gestiegen sind, wobei der durchschnittliche Schaden pro Vorfall bei 1,85 Millionen US-Dollar liegt. Das Ziel der Angreifer: Dateien im Visier Die Ransomware versucht nicht, jede Datei auf dem infizierten System zu verschlüsseln. Stattdessen sucht sie gezielt nach bestimmten Dateitypen, die wahrscheinlich wertvolle Inhalte enthalten. Über 300 Dateierweiterungen sind im Visier, darunter 17 Arten von Mediendateien. Diese gezielte Auswahl ermöglicht es den Angreifern, den maximalen Schaden zu verursachen.
Weitere Beiträge

Let's talk.

You have questions about this article or want a consultation?

Please contact us directly!

Let's talk.
Share by: