hacktricks/pentesting-web/parameter-pollution.md

73 lines
5.2 KiB
Markdown
Raw Normal View History

# Parameter Pollution
2022-04-28 16:01:33 +00:00
<details>
2023-12-31 01:25:17 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2023-12-31 01:25:17 +00:00
Other ways to support HackTricks:
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2023-12-31 01:25:17 +00:00
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/carlospolopm)**.**
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-02-04 16:10:29 +00:00
# HTTP Parameter Pollution (HPP) Overview
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
HTTP Parameter Pollution (HPP) is an attack technique involving the manipulation of HTTP parameters to alter a web application's expected behavior. This kind of attack is relatively straightforward but can be remarkably effective. Although the parameter manipulation occurs server-side and is not visible to the user, the resulting behavior changes can be observed on the client side.
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
##Example of HTTP Parameter Pollution (HPP)
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
Consider a standard transaction URL for a banking application:
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
**URL:** `https://www.victim.com/send/?from=accountA&to=accountB&amount=10000`
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
This URL initiates a transaction of 10,000 from accountA to accountB. However, introducing another `from` parameter like so:
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
**Manipulated URL:** `https://www.victim.com/send/?from=accountA&to=accountB&amount=10000&from=accountC`
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
might result in the transaction being deducted from accountC instead of accountA. This exemplifies how HPP can be used to manipulate parameters. Notably, this vulnerability is not confined to GET requests but can also be exploited in POST requests across various functionalities such as password changes, 2FA, or API key transmissions.
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
It's important to recognize that parameter parsing is dependent on the specific web technology in use. Tools like [Wappalyzer](https://addons.mozilla.org/en-US/firefox/addon/wappalyzer/) can be used to identify web technologies and understand their parameter parsing behaviors.
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
## PHP
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
A notable instance of exploiting HPP involved the following steps:
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
1. **OTP Manipulation:**
- A login page requesting an OTP was the target.
- After sending an OTP request, the subsequent HTTP request was intercepted using Burp Suite.
- Another email was added to the request, effectively duplicating the `email` parameter.
- The OTP intended for the first email was mistakenly sent to the second email, allowing unauthorized access to the first account.
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
This incident underscores how the application backend processed the `email` parameters, utilizing the first for OTP generation and the second for OTP delivery.
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
# Parameter Parsing in Flask & PHP
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
Different web technologies parse parameters uniquely. For instance, with a query like `a=1&a=2`, Flask and PHP will interpret the parameter differently:
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
- **Flask:** Takes the first occurrence (a=1).
- **PHP (on Apache HTTP Server):** Takes the last occurrence (a=2).
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
This difference in parameter handling can significantly impact application behavior and vulnerability to HPP attacks. More details on this can be found in [this writeup](https://github.com/google/google-ctf/tree/master/2023/web-under-construction/solution).
2020-07-30 08:34:18 +00:00
2024-02-04 16:10:29 +00:00
# References
* [https://medium.com/@shahjerry33/http-parameter-pollution-its-contaminated-85edc0805654](https://medium.com/@shahjerry33/http-parameter-pollution-its-contaminated-85edc0805654)
* [https://github.com/google/google-ctf/tree/master/2023/web-under-construction/solution](https://github.com/google/google-ctf/tree/master/2023/web-under-construction/solution)
2022-04-28 16:01:33 +00:00
<details>
2023-12-31 01:25:17 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2023-12-31 01:25:17 +00:00
Other ways to support HackTricks:
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2023-12-31 01:25:17 +00:00
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/carlospolopm)**.**
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>