DOM Explained
2023-03-188 turns8,876 charstext-davinci-002-render-sha
Summary
The user is learning about web security concepts including DOM, HTTP methods, and XSS vulnerabilities.
Messages
what does DOM stand for
DOM stands for Document Object Model. It is a programming interface for web documents that represents the page so that programs can change the document structure, style, and content. The DOM represents the document as nodes and objects, which can be manipulated with programming languages such as JavaScript to dynamically change the web page without needing to reload it.
text-davinci-002-render-sha
what is a node
In computer science, a node is a basic unit of a data structure, such as a linked list or tree. In the context of web development and the Document Object Model (DOM), a node refers to an element within an HTML or XML document.
In the DOM, each element, attribute, and piece of text in the HTML or XML document is represented as a node. These nodes are organized in a hierarchical structure, with the document node at the top, followed by element nodes, attribute nodes, and text nodes.
Each node in the DOM can be accessed and manipulated using programming languages like JavaScript, allowing web developers to dynamically change the content and structure of a web page in response to user interactions and other events.
text-davinci-002-render-sha
What is the difference between POST and GET
POST and GET are two of the most commonly used HTTP methods used to send data from a client (such as a web browser) to a server. The key differences between POST and GET are as follows:
1. Data Transmission:
The GET method sends data to the server via the URL query string, while the POST method sends data in the request body.
2. Data Size:
GET requests have a limitation on the amount of data that can be sent because the data is sent in the URL query string, which has a maximum length. In contrast, POST requests have no such limitation as data is sent in the request body.
3. Security:
Because GET requests send data via the URL, the data is visible in the browser's address bar and in browser history. In contrast, POST requests do not expose the data in this way, making them a more secure method for transmitting sensitive data.
4. Caching:
GET requests can be cached by the browser, whereas POST requests are not cacheable.
5. Idempotence:
GET requests are considered idempotent, meaning that multiple identical requests will produce the same result. In contrast, POST requests are not necessarily idempotent, meaning that multiple identical requests may produce different results.
In general, GET requests are used to retrieve data from the server, while POST requests are used to submit data to the server for processing. However, both methods can be used for a variety of purposes depending on the specific requirements of the application.
text-davinci-002-render-sha
summerize: XSS and Authorization
XSS Review
Most common bug
Reflected XSS - Input from a user is directly returned to the browser, permitting injection of arbitrary content
Stored XSS - input from a user is stored on the server (often in a database) and returned later without proper esacaing
DOM XSS – Input from a user is inserted into the page’s DOM without proper handling, enabling insertion of arbitrary nodes
what does DOM stand for
DOM stands for Document Object Model. It is a programming interface for web documents that represents the page so that programs can change the document structure, style, and content. The DOM represents the document as nodes and objects, which can be manipulated with programming languages such as JavaScript to dynamically change the web page without needing to reload it.
what is a node
In computer science, a node is a basic unit of a data structure, such as a linked list or tree. In the context of web development and the Document Object Model (DOM), a node refers to an element within an HTML or XML document.
In the DOM, each element, attribute, and piece of text in the HTML or XML document is represented as a node. These nodes are organized in a hierarchical structure, with the document node at the top, followed by element nodes, attribute nodes, and text nodes.
Each node in the DOM can be accessed and manipulated using programming languages like JavaScript, allowing web developers to dynamically change the content and structure of a web page in response to user interactions and other events.
Reflected and Stored XSS
Recognition
First step is to find XSS
Mental checklist for each input
Figure otu where it goes: Does it get embedded in a tag attribute? Does it get embedded into a string in a script tag?
Figure out any special handling: Do URLs get turned into links, like posts in level1?
Figure out how special characters are handled: A good way is to input something like ‘<>:;”
From those three steps you’ll know whether or not a given input is vulnerable to XSS.
At this point one of the differences between stored and reflected XSS becomes apparent: rXSS vulnerabilities are inherently dependent on CSRF vulnerabilities to be exploitable, in the case of POSTs. If your rXSS exists just in a GET you’re fine, but you're dependent on CSRF otherwise
POST and GET are two of the most commonly used HTTP methods used to send data from a client (such as a web browser) to a server. The key differences between POST and GET are as follows:
Data Transmission:
The GET method sends data to the server via the URL query string, while the POST method sends data in the request body.
Data Size:
GET requests have a limitation on the amount of data that can be sent because the data is sent in the URL query string, which has a maximum length. In contrast, POST requests have no such limitation as data is sent in the request body.
Security:
Because GET requests send data via the URL, the data is visible in the browser's address bar and in browser history. In contrast, POST requests do not expose the data in this way, making them a more secure method for transmitting sensitive data.
Caching:
GET requests can be cached by the browser, whereas POST requests are not cacheable.
Idempotence:
GET requests are considered idempotent, meaning that multiple identical requests will produce the same result. In contrast, POST requests are not necessarily idempotent, meaning that multiple identical requests may produce different results.
In general, GET requests are used to retrieve data from the server, while POST requests are used to submit data to the server for processing. However, both methods can be used for a variety of purposes depending on the specific requirements of the application.
Problem
The core problem with DOM XSS is that there are effectively an infinite number of ways in which it can come about, each of which requiring different mitigations:
Embedding attacker data into eval/setTimeout/setInterval requires string escaping/filtering
Embedding attacker data into tags and attributes requires HTML encoding
Same goes for innerHTML
Don’t put user-controlled data on the page. It seems strict but it’s the way to go. Whitelist very specific things, eg a list of valid locales for the flag example.
If you must put user data into a page, you have to escape/encode for the specific context.
Forced browsing and improper authorization
The line is very fine between the two. Generally forced browsing or direct object reference is used when you’re talking about enumberable values such as post IDs and other parts of the site that are not ordinarily available to you from your privilege level. Don’t worry too much about which you use; some people combine them just under “authorization bugs” or auth-z to differentiate from auth-n, authentication.
An example of an auth-z bug is just changing the ID in the GET request in order to get to someone else’s posts.
XSS has three types
Reflected
Stored
DOM-based
rXSS and sXSS are similar
If it is innumerable it is probably forced browsings.
The article discusses two important concepts in web development, XSS and authorization. XSS (Cross-Site Scripting) is a common vulnerability that can be exploited to inject malicious scripts into a web page, allowing attackers to steal sensitive information or gain unauthorized access. The article explains the different types of XSS, including Reflected XSS, Stored XSS, and DOM XSS. It also provides guidance on how to recognize XSS vulnerabilities and mitigate them.
Authorization refers to the process of determining whether a user has permission to access a particular resource or perform a specific action. The article highlights the difference between forced browsing and direct object reference, and how they can be used to exploit authorization vulnerabilities. It also provides an example of an auth-z bug where an attacker changes the ID in a GET request to access someone else's posts.
Additionally, the article briefly explains the differences between the POST and GET methods in HTTP, and the core problem with DOM XSS. It emphasizes the importance of escaping and encoding user-controlled data to prevent XSS and other security vulnerabilities.
text-davinci-002-render-sha