Web Application Security Theory Flashcards
What is the golden rule of web application security
The client is never trustworthy
What does the golden rule means in practice?
We need to filter and check carefully anything that is sent to us
What are the possibilities for implementing filtering?
Whitelisting, only allowing through what we expect
Blacklisting, discard known bad stuff
Escaping, transform special characters into something else which is less dangerous
Blacklisting is safer than whitelisting
True or false
False
What is XSS?
Cross site scripting, is a vulnerability by means of which client side code can be injected in a page
What are the types of XSS
Stored XSS
Reflected XSS
Dom-based XSS
Describe the stored cross site scripting
The attacker input is stored on the target server in a database. Then the victim retrieves the stored, malicious code from the web application without that data being made safe to render in the browse.
Describe how the reflected XSS happens
A reflected Cross-Site Scripting (XSS) attack occurs when an attacker injects malicious scripts into a website, which are then reflected off a web server and executed in a user’s browser. These scripts are often included in a URL or input field and are processed by the server, then sent back to the user’s browser without proper validation or encoding.
Here’s a breakdown of how a reflected XSS attack typically works:
1. Injection: The attacker crafts a malicious URL or input that contains JavaScript or other executable scripts. 2. Submission: The victim clicks on the malicious link or submits a form with the malicious input. 3. Reflection: The web server processes the input and includes it in the response back to the user’s browser without proper sanitization. 4. Execution: The user’s browser executes the malicious script, which can then perform actions like stealing cookies, session tokens, or other sensitive information, and sending it back to the attacker.
What is the main difference between Stored and Reflected XSS
• Persistence: Stored XSS is persistent and affects any user accessing the compromised data, while reflected XSS is transient and targets individual users who interact with the malicious input.
• Attack Vector: Stored XSS typically requires an attacker to inject the script into a part of the application where it will be saved and viewed by users later. Reflected XSS requires the attacker to convince a user to click a link or submit a form containing the malicious script.
Describe the DOM based XSS
A DOM-based Cross-Site Scripting (XSS) attack is a type of XSS where the vulnerability exists in the client-side code rather than the server-side code. In this scenario, the malicious script is injected and executed entirely within the Document Object Model (DOM) of the user’s browser.
How DOM-based XSS Works
1. Injection: The attacker crafts a malicious URL or input that manipulates the client-side script. 2. Execution: When the victim’s browser processes the page, the client-side JavaScript reads and executes the malicious payload from the URL or other client-side sources like document.location, document.referrer, or document.cookie. 3. Result: The script is executed within the context of the page, leading to the same kinds of effects as reflected or stored XSS, such as data theft, session hijacking, or defacement.
What can be done with cross site scripting
Cookie theft or section hijack
Manipulation of a section and execution of fraudulent transaction
Snooping on private information
Drive by download
Effective bypass, the same origin policy
Define the same origin policy (SOP)
All client side code loaded from origin A should only be able to access data from origin A
What is the problem of SOP?
Modern web has blurry boundaries (cross origin resource sharing, client side extensions)
What does CSP stand for and what are its uses?
It stands for content security policy. It is a world wild Web consortium (W3C) specification to inform the browser on what should be trusted, and what not should be trusted.
Technically, it’s a set of directives sent by the server to the client in the form of HTTP response Heather.
Discuss an example of a CSP policy enforcement
Client ← Server:
Content-Security-Policy: script-src ‘self’ https://apis.google.com
Client (attacker) → Server:
XSS to permanently inject
Client (victim) ← Server:
<html> ...
<script> </html> Browser refuses to load script </script></html>