Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XSS Reorganization #1074

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4434ff6
insecure configuration of CSP when using the unsafe-hashes directive
manindar-mohan Jul 3, 2022
a3951cb
Merge branch 'OWASP:master' into master
manindar-mohan Jul 3, 2022
ee398e2
conflict resolved
manindar-mohan Jul 13, 2022
09555cd
Merge branch 'OWASP:master' into master
manindar-mohan Aug 6, 2022
93db96a
Merge branch 'OWASP:master' into master
manindar-mohan Jun 15, 2023
17f7b86
Moved all XSS to chapter 11, client-side testing, and have one big se…
Jun 30, 2023
d05dcaa
Merge branch 'OWASP:master' into master
manindar-mohan Jun 30, 2023
3188789
mistakes fixed
Jun 30, 2023
8304381
mistake fixed for 07-Input_Validation_Testing/02-Testing_for_HTTP_Par…
Jun 30, 2023
c5277d4
mistake fixed for 07-Input_Validation_Testing/02-Testing_for_HTTP_Par…
Jun 30, 2023
b96069f
Mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
4e19ca5
Mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
6de5b1f
Mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
abd0d14
mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
13af516
mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
ca63381
mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
796ff39
mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
6f4e77f
mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
57577bb
Mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
3b25297
Mistake fixed document/4-Web_Application_Security_Testing/07-Input_V…
Jun 30, 2023
da5a26b
Mistake fixed document/4-Web_Application_Security_Testing/07-Input_Va…
Jun 30, 2023
4f972b8
Mistake fixed document/4-Web_Application_Security_Testing/07-Input_Va…
Jun 30, 2023
407ef1e
Mistake fixed 4-Web_Application_Security_Testing/07-Input_Validation_…
Jun 30, 2023
3c18cf3
Mistake fixed 4-Web_Application_Security_Testing/11-Client-side_Testi…
Jun 30, 2023
d9985e5
Mistake fixed 4-Web_Application_Security_Testing/11-Client-side_Testi…
Jun 30, 2023
04a6714
Mistake fixed 4-Web_Application_Security_Testing/11-Client-side_Testi…
Jun 30, 2023
cd15fd4
links are broken mistake fixed in 4-Web_Application_Security_Testing/…
Jul 1, 2023
9bc3108
mistake with code blok surrounded by blank lines fixed (#591)
Jul 1, 2023
42f5333
Removed broken link from 03.1-Testing_for_Oracle (#591)
Jul 1, 2023
5e4e779
new line and other format error fixed (#591)
Jul 1, 2023
4ca6ebd
formatting mistake fixed (#591)
Jul 1, 2023
2ea1e4a
formatting mistake fixed (#591)
Jul 1, 2023
b916869
formatting mistake fixed (#591)
Jul 1, 2023
209123f
Mistake caused by insuffitent new lines fixed
Jul 3, 2023
907b73c
Mistake caused by top level heading fixed
Jul 3, 2023
9ea0801
Mistake caused by insuffitent new lines fixed
Jul 3, 2023
effe070
Mistake caused by insuffitent new lines fixed
Jul 3, 2023
b068749
Mistake caused by broken link fixed
Jul 3, 2023
84536e7
Mistake caused by Incorrect usage of the term fixed
Jul 3, 2023
cd9010b
Mistake caused by roken link for case study is fixed by adding new ca…
Jul 3, 2023
39e23bf
ATHN-01 removed and added renamed to new numbers (#598)
Jul 11, 2023
c8dd891
Update document/4-Web_Application_Security_Testing/07-Input_Validatio…
manindar-mohan Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

|ID |
|------------|
|WSTG-INPV-03|
|WSTG-INPV-01|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kingthorin I wouldn't put this as Id number 1. I feel with v5, we can take it out, no?
This will impact all the other docs, so I think we need to decide on this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this specific topic?


This content has been merged into: [Test HTTP Methods](../02-Configuration_and_Deployment_Management_Testing/06-Test_HTTP_Methods.md)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-04|
|WSTG-INPV-02|

## Summary

Expand All @@ -20,7 +20,7 @@ In 2009, immediately after the publication of the first research on HTTP Paramet

One of these flaws, affecting *ModSecurity SQL Injection Core Rules*, represents a perfect example of the impedance mismatch between applications and filters. The ModSecurity filter would correctly apply a deny list for the following string: `select 1,2,3 from table`, thus blocking this example URL from being processed by the web server: `/index.aspx?page=select 1,2,3 from table`. However, by exploiting the concatenation of multiple HTTP parameters, an attacker could cause the application server to concatenate the string after the ModSecurity filter already accepted the input. As an example, the URL `/index.aspx?page=select 1&page=2,3` from table would not trigger the ModSecurity filter, yet the application layer would concatenate the input back into the full malicious string.

Another HPP vulnerability turned out to affect *Apple Cups*, the well-known printing system used by many UNIX systems. Exploiting HPP, an attacker could easily trigger a Cross-Site Scripting vulnerability using the following URL: `http://127.0.0.1:631/admin/?kerberos=onmouseover=alert(1)&kerberos`. The application validation checkpoint could be bypassed by adding an extra `kerberos` argument having a valid string (e.g. empty string). As the validation checkpoint would only consider the second occurrence, the first `kerberos` parameter was not properly sanitized before being used to generate dynamic HTML content. Successful exploitation would result in JavaScript code execution under the context of the hosting web site.
Another HPP vulnerability turned out to affect *Apple Cups*, the well-known printing system used by many UNIX systems. Exploiting HPP, an attacker could easily trigger a Cross-Site Scripting vulnerability using the following URL: `http://127.0.0.1:631/admin/?kerberos=onmouseover=alert(1)&kerberos`. The application validation checkpoint could be bypassed by adding an extra `kerberos` argument having a valid string (e.g. empty string). As the validation checkpoint would only consider the second occurrence, the first `kerberos` parameter was not properly sanitized before being used to generate dynamic HTML content. Successful exploitation would result in JavaScript code execution under the context of the hosting site.

### Authentication Bypass

Expand Down Expand Up @@ -54,7 +54,7 @@ Given the URL and querystring: `http://example.com/?color=red&color=blue`
| JSP, Servlet / Jetty | First occurrence only | color=red |
| IBM Lotus Domino | Last occurrence only | color=blue |
| IBM HTTP Server | First occurrence only | color=red |
| node.js / express | First occurrence only | color=red |
| Node.js / express | First occurrence only | color=red |
| mod_perl, libapreq2 / Apache | First occurrence only | color=red |
| Perl CGI / Apache | First occurrence only | color=red |
| mod_wsgi (Python) / Apache | First occurrence only | color=red |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-05|
|WSTG-INPV-03|

## Summary

Expand Down Expand Up @@ -805,14 +805,14 @@ For generic input validation security, refer to the [Input Validation CheatSheet

Technology specific Testing Guide pages have been created for the following DBMSs:

- [Oracle](05.1-Testing_for_Oracle.md)
- [MySQL](05.2-Testing_for_MySQL.md)
- [SQL Server](05.3-Testing_for_SQL_Server.md)
- [PostgreSQL](05.4-Testing_PostgreSQL.md)
- [MS Access](05.5-Testing_for_MS_Access.md)
- [NoSQL](05.6-Testing_for_NoSQL_Injection.md)
- [ORM](05.7-Testing_for_ORM_Injection.md)
- [Client-side](05.8-Testing_for_Client-side.md)
- [Oracle](03.1-Testing_for_Oracle.md)
- [MySQL](03.2-Testing_for_MySQL.md)
- [SQL Server](03.3-Testing_for_SQL_Server.md)
- [PostgreSQL](03.4-Testing_PostgreSQL.md)
- [MS Access](03.5-Testing_for_MS_Access.md)
- [NoSQL](03.6-Testing_for_NoSQL_Injection.md)
- [ORM](03.7-Testing_for_ORM_Injection.md)
- [Client-side](03.8-Testing_for_Client-side.md)

### Whitepapers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ On older versions of the PL/SQL Gateway, it is possible to directly access the p

`http://www.example.com/pls/dad/owa_util.signature`

returns the following output on the webpage
returns the following output on the web page

`"This page was produced by the PL/SQL Web Toolkit on date"`

Expand Down Expand Up @@ -334,10 +334,6 @@ returns an error or a `404`, then there might be a SQL injection flaw. This can

If this request returns books by Charles Dickens, you've confirmed the presence of the SQL injection vulnerability.

## Tools

- [Orascan (Oracle Web Application VA scanner), NGS SQuirreL (Oracle RDBMS VA Scanner)](https://www.nccgroup.trust/globalassets/service-pages/documents/security-consulting/information-security-software/ncc-squirrel-suite.pdf)

## References

### Whitepapers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MySQL comes with at least four versions which are used in production worldwide,

It should be noted that for MySQL versions before 4.0.x, only Boolean or time-based Blind Injection attacks could be used, since the subquery functionality or `UNION` statements were not implemented.

From now on, we will assume that there is a classic SQL injection vulnerability, which can be triggered by a request similar to the one described in the Section on [Testing for SQL Injection](05-Testing_for_SQL_Injection.md).
From now on, we will assume that there is a classic SQL injection vulnerability, which can be triggered by a request similar to the one described in the Section on [Testing for SQL Injection](03-Testing_for_SQL_Injection.md).

`http://www.example.com/page.php?id=2`

Expand Down Expand Up @@ -60,7 +60,7 @@ For example the following injection will result in an error:

#### Fingerprinting MySQL

Of course, the first thing to know is if there's MySQL DBMS as a back end database. MySQL server has a feature that is used to let other DBMS ignore a clause in MySQL dialect. When a comment block `'/**/'` contains an exclamation mark `'/*! sql here*/'` it is interpreted by MySQL, and is considered as a normal comment block by other DBMS as explained in [MySQL manual](https://dev.mysql.com/doc/refman/8.0/en/comments.html).
Of course, the first thing to know is if there's MySQL DBMS as a backend database. MySQL server has a feature that is used to let other DBMS ignore a clause in MySQL dialect. When a comment block `'/**/'` contains an exclamation mark `'/*! sql here*/'` it is interpreted by MySQL, and is considered as a normal comment block by other DBMS as explained in [MySQL manual](https://dev.mysql.com/doc/refman/8.0/en/comments.html).

Example:

Expand Down Expand Up @@ -224,4 +224,4 @@ For a complete list, refer to the [MySQL manual](https://dev.mysql.com/doc/refma

### Case Studies

- [Zeelock: Blind Injection in MySQL Databases](https://archive.cert.uni-stuttgart.de/bugtraq/2005/02/msg00289.html)
- [All Your Databases Belong To Me! A Blind SQLi Case Study](https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/all-your-databases-belong-to-me-a-blind-sqli-case-study)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-06|
|WSTG-INPV-04|

## Summary

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-07|
|WSTG-INPV-05|

## Summary

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-08|
|WSTG-INPV-06|

## Summary

Expand Down Expand Up @@ -72,8 +72,8 @@ User-Agent: <!--#include virtual="/proc/version"-->

- [Nginx SSI module](http://nginx.org/en/docs/http/ngx_http_ssi_module.html)
- [Apache: Module mod_include](https://httpd.apache.org/docs/current/mod/mod_include.html)
- [IIS: Server Side Includes directives](https://docs.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms525185%28v=vs.90%29)
- [Apache Tutorial: Introduction to Server Side Includes](https://httpd.apache.org/docs/current/howto/ssi.html)
- [IIS: server-side Includes directives](https://docs.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms525185%28v=vs.90%29)
- [Apache Tutorial: Introduction to server-side Includes](https://httpd.apache.org/docs/current/howto/ssi.html)
- [Apache: Security Tips for Server Configuration](https://httpd.apache.org/docs/current/misc/security_tips.html#ssi)
- [SSI Injection instead of JavaScript Malware](https://jeremiahgrossman.blogspot.com/2006/08/ssi-injection-instead-of-javascript.html)
- [IIS: Notes on Server-Side Includes (SSI) syntax](https://blogs.iis.net/robert_mcmurray/archive/2010/12/28/iis-notes-on-server-side-includes-ssi-syntax-kb-203064-revisited.aspx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-09|
|WSTG-INPV-07|

## Summary

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

|ID |
|------------|
|WSTG-INPV-10|
|WSTG-INPV-08|

## Summary

This threat affects all applications that communicate with mail servers (IMAP/SMTP), generally webmail applications. The aim of this test is to verify the capacity to inject arbitrary IMAP/SMTP commands into the mail servers, due to input data not being properly sanitized.

The IMAP/SMTP Injection technique is more effective if the mail server is not directly accessible from Internet. Where full communication with the backend mail server is possible, it is recommended to conduct direct testing.
The IMAP/SMTP Injection technique is more effective if the mail server is not directly accessible from internet. Where full communication with the backend mail server is possible, it is recommended to conduct direct testing.

An IMAP/SMTP Injection makes it possible to access a mail server which otherwise would not be directly accessible from the Internet. In some cases, these internal systems do not have the same level of infrastructure security and hardening that is applied to the front-end web servers. Therefore, mail server results may be more vulnerable to attacks by end users (see the scheme presented in Figure 1).
An IMAP/SMTP Injection makes it possible to access a mail server which otherwise would not be directly accessible from the internet. In some cases, these internal systems do not have the same level of infrastructure security and hardening that is applied to the frontend web servers. Therefore, mail server results may be more vulnerable to attacks by end users (see the scheme presented in Figure 1).

![IMAP SMTP Injection](images/Imap-smtp-injection.png)\
*Figure 4.7.10-1: Communication with the mail servers using the IMAP/SMTP Injection technique*

Figure 1 depicts the flow of traffic generally seen when using webmail technologies. Step 1 and 2 is the user interacting with the webmail client, whereas step 2 is the tester bypassing the webmail client and interacting with the back-end mail servers directly.
Figure 1 depicts the flow of traffic generally seen when using webmail technologies. Step 1 and 2 is the user interacting with the webmail client, whereas step 2 is the tester bypassing the webmail client and interacting with the backend mail servers directly.

This technique allows a wide variety of actions and attacks. The possibilities depend on the type and scope of injection and the mail server technology being tested.

Expand All @@ -37,7 +37,7 @@ Some examples of attacks using the IMAP/SMTP Injection technique are:

### Identifying Vulnerable Parameters

In order to detect vulnerable parameters, the tester has to analyze the application's ability in handling input. Input validation testing requires the tester to send bogus, or malicious, requests to the server and analyse the response. In a secure application, the response should be an error with some corresponding action telling the client that something has gone wrong. In a vulnerable application, the malicious request may be processed by the back-end application that will answer with a `HTTP 200 OK` response message.
In order to detect vulnerable parameters, the tester has to analyze the application's ability in handling input. Input validation testing requires the tester to send bogus, or malicious, requests to the server and analyse the response. In a secure application, the response should be an error with some corresponding action telling the client that something has gone wrong. In a vulnerable application, the malicious request may be processed by the backend application that will answer with a `HTTP 200 OK` response message.

It is important to note that the requests being sent should match the technology being tested. Sending SQL injection strings for Microsoft SQL server when a MySQL server is being used will result in false positive responses. In this case, sending malicious IMAP commands is modus operandi since IMAP is the underlying protocol being tested.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-11|
|WSTG-INPV-09|

## Summary

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ The wrapper can be used like `php://filter/convert.base64-encode/resource=FILE`

In PHP 7.2.0, the `zip://` wrapper was introduced to manipulate `zip` compressed files. This wrapper expects the following parameter structure: `zip:///filename_path#internal_filename`. The `filename_path` is the path to the malicious zip archive and `internal_filename` is the path of the malicious file placed inside the processed ZIP file. During the exploitation, it's common that the `#` would be encoded with its URL encoded value `%23`.

Abuse of this wrapper could allow an attacker to design a malicious ZIP file that could be uploaded to the server, for example as an avatar image or using any file upload system available on the target website (the `php:zip://` wrapper does not require the zip file to have any specific extension) to be executed by the LFI vulnerability.
Abuse of this wrapper could allow an attacker to design a malicious ZIP file that could be uploaded to the server, for example as an avatar image or using any file upload system available on the target site (the `php:zip://` wrapper does not require the zip file to have any specific extension) to be executed by the LFI vulnerability.

In order to test this vulnerability, the following procedure could be followed to attack the previous code example provided.

1. Create the PHP file to be executed, for example with the content `<?php phpinfo(); ?>` and save it as `code.php`.
2. Compress it as a new ZIP file called `target.zip`.
3. Rename the `target.zip` file to `target.jpg` to bypass the extension validation and upload it to the target website as your avatar image.
3. Rename the `target.zip` file to `target.jpg` to bypass the extension validation and upload it to the target site as your avatar image.
4. Supposing that the `target.jpg` file is stored locally on the server to the `../avatar/target.jpg` path, exploit the vulnerability with the PHP ZIP wrapper by injecting the following payload to the vulnerable URL: `zip://../avatar/target.jpg%23code` (remember that `%23` corresponds to `#`).

Since on our sample the `.php` extension is concatenated to our payload, the request to `http://vulnerable_host/preview.php?file=zip://../avatar/target.jpg%23code` will result in the execution of the `code.php` file existing in the malicious ZIP file.

##### PHP Data

Available since PHP 5.2.0, this wrapper expects the following usage: `data://text/plain;base64,BASE64_STR` where `BASE64_STR` is expected to be the Base64 encoded content of the file to be processed. It's important to consider that this wrapper would only be available if the option `allow_url_include` would be enabled.
Available since PHP 5.2.0, this wrapper expects the following usage: `data://text/plain;base64,BASE64_STR` where `BASE64_STR` is expected to be the base64 encoded content of the file to be processed. It's important to consider that this wrapper would only be available if the option `allow_url_include` would be enabled.

In order to test for LFI using this wrapper, the code to be executed should be Base64 encoded. For example, `<?php phpinfo(); ?>` would be encoded as: `PD9waHAgcGhwaW5mbygpOyA/Pg==` and the payload would be represented as: `data://text/plain;base64,PD9waHAgcGhwaW5mbygpOyA/Pg==`.
In order to test for LFI using this wrapper, the code to be executed should be base64 encoded. For example, `<?php phpinfo(); ?>` would be encoded as: `PD9waHAgcGhwaW5mbygpOyA/Pg==` and the payload would be represented as: `data://text/plain;base64,PD9waHAgcGhwaW5mbygpOyA/Pg==`.

##### PHP Expect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-12|
|WSTG-INPV-10|

## Summary

Expand Down Expand Up @@ -36,7 +36,7 @@ Example:

### Example

Consider the case of an application that contains a set of documents that you can browse from the Internet. If you fire up a personal proxy (such as ZAP or Burp Suite), you can obtain a POST HTTP like the following (`http://www.example.com/public/doc`):
Consider the case of an application that contains a set of documents that you can browse from the internet. If you fire up a personal proxy (such as ZAP or Burp Suite), you can obtain a POST HTTP like the following (`http://www.example.com/public/doc`):

```txt
POST /public/doc HTTP/1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

|ID |
|------------|
|WSTG-INPV-13|
|WSTG-INPV-11|

This content has been removed
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|ID |
|------------|
|WSTG-INPV-13|
|WSTG-INPV-12|

## Summary

Expand Down Expand Up @@ -82,7 +82,7 @@ Testers can perform a manual test using a web browser or other web API debugging

`https://vulnerable_host/userinfo?username=%25s%25s%25s%25n`

If the web site is vulnerable, the browser or tool should receive an error, which may include a timeout or an HTTP return code 500.
If the site is vulnerable, the browser or tool should receive an error, which may include a timeout or an HTTP return code 500.

The Java code returns the error

Expand Down
Loading