Translated ['pentesting-web/parameter-pollution.md'] to pt

This commit is contained in:
Translator 2024-11-12 12:22:26 +00:00
parent 4d9d979fbf
commit fbf40b0078
2 changed files with 103 additions and 18 deletions

View file

@ -604,7 +604,7 @@
* [OAuth to Account takeover](pentesting-web/oauth-to-account-takeover.md) * [OAuth to Account takeover](pentesting-web/oauth-to-account-takeover.md)
* [Open Redirect](pentesting-web/open-redirect.md) * [Open Redirect](pentesting-web/open-redirect.md)
* [ORM Injection](pentesting-web/orm-injection.md) * [ORM Injection](pentesting-web/orm-injection.md)
* [Parameter Pollution](pentesting-web/parameter-pollution.md) * [Parameter Pollution | JSON Injection](pentesting-web/parameter-pollution.md)
* [Phone Number Injections](pentesting-web/phone-number-injections.md) * [Phone Number Injections](pentesting-web/phone-number-injections.md)
* [PostMessage Vulnerabilities](pentesting-web/postmessage-vulnerabilities/README.md) * [PostMessage Vulnerabilities](pentesting-web/postmessage-vulnerabilities/README.md)
* [Blocking main page to steal postmessage](pentesting-web/postmessage-vulnerabilities/blocking-main-page-to-steal-postmessage.md) * [Blocking main page to steal postmessage](pentesting-web/postmessage-vulnerabilities/blocking-main-page-to-steal-postmessage.md)

View file

@ -1,6 +1,6 @@
# Poluição de Parâmetros # Parameter Pollution | JSON Injection
## Poluição de Parâmetros ## Parameter Pollution
{% hint style="success" %} {% hint style="success" %}
Aprenda e pratique Hacking AWS:<img src="../.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../.gitbook/assets/arte.png" alt="" data-size="line">\ Aprenda e pratique Hacking AWS:<img src="../.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../.gitbook/assets/arte.png" alt="" data-size="line">\
@ -12,7 +12,7 @@ Aprenda e pratique Hacking GCP: <img src="../.gitbook/assets/grte.png" alt="" da
* Confira os [**planos de assinatura**](https://github.com/sponsors/carlospolop)! * Confira os [**planos de assinatura**](https://github.com/sponsors/carlospolop)!
* **Junte-se ao** 💬 [**grupo do Discord**](https://discord.gg/hRep4RUj7f) ou ao [**grupo do telegram**](https://t.me/peass) ou **siga**-nos no **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Junte-se ao** 💬 [**grupo do Discord**](https://discord.gg/hRep4RUj7f) ou ao [**grupo do telegram**](https://t.me/peass) ou **siga**-nos no **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Compartilhe truques de hacking enviando PRs para os repositórios do** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud). * **Compartilhe truques de hacking enviando PRs para o** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repositórios do github.
</details> </details>
{% endhint %} {% endhint %}
@ -65,8 +65,8 @@ Esse exemplo reforça ainda mais a necessidade de um manuseio seguro de parâmet
A forma como as tecnologias web lidam com parâmetros HTTP duplicados varia, afetando sua suscetibilidade a ataques HPP: A forma como as tecnologias web lidam com parâmetros HTTP duplicados varia, afetando sua suscetibilidade a ataques HPP:
* **Flask:** Adota o primeiro valor de parâmetro encontrado, como `a=1` em uma string de consulta `a=1&a=2`, priorizando a instância inicial sobre duplicatas subsequentes. * **Flask:** Adota o primeiro valor de parâmetro encontrado, como `a=1` em uma string de consulta `a=1&a=2`, priorizando a instância inicial em relação a duplicatas subsequentes.
* **PHP (no Apache HTTP Server):** Contrariamente, prioriza o último valor de parâmetro, optando por `a=2` no exemplo dado. Esse comportamento pode inadvertidamente facilitar explorações de HPP ao honrar o parâmetro manipulado do atacante em vez do original. * **PHP (no Apache HTTP Server):** Por outro lado, prioriza o último valor de parâmetro, optando por `a=2` no exemplo dado. Esse comportamento pode inadvertidamente facilitar explorações de HPP ao honrar o parâmetro manipulado do atacante em vez do original.
## Poluição de parâmetros por tecnologia ## Poluição de parâmetros por tecnologia
@ -94,8 +94,8 @@ Os resultados foram retirados de [https://medium.com/@0xAwali/http-parameter-pol
<figure><img src="../.gitbook/assets/image (1258).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*llG22MF1gPTYZYFVCmCiVw.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*llG22MF1gPTYZYFVCmCiVw.jpeg</a></p></figcaption></figure> <figure><img src="../.gitbook/assets/image (1258).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*llG22MF1gPTYZYFVCmCiVw.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*llG22MF1gPTYZYFVCmCiVw.jpeg</a></p></figcaption></figure>
1. POST RequestMapping == PostMapping & GET RequestMapping == GetMapping. 1. POST RequestMapping == PostMapping & GET RequestMapping == GetMapping.
2. POST RequestMapping & PostMapping reconhecem name\[]. 2. POST RequestMapping & PostMapping reconhecem name[].
3. Preferir name se name E name\[] existirem. 3. Preferir name se name E name[] existirem.
4. Concatenar parâmetros, por exemplo, first,last. 4. Concatenar parâmetros, por exemplo, first,last.
5. POST RequestMapping & PostMapping reconhecem parâmetros de consulta com Content-Type. 5. POST RequestMapping & PostMapping reconhecem parâmetros de consulta com Content-Type.
@ -103,58 +103,143 @@ Os resultados foram retirados de [https://medium.com/@0xAwali/http-parameter-pol
<figure><img src="../.gitbook/assets/image (1259).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*JzNkLOSW7orcHXswtMHGMA.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*JzNkLOSW7orcHXswtMHGMA.jpeg</a></p></figcaption></figure> <figure><img src="../.gitbook/assets/image (1259).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*JzNkLOSW7orcHXswtMHGMA.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*JzNkLOSW7orcHXswtMHGMA.jpeg</a></p></figcaption></figure>
1. Reconhece name\[]. 1. Reconhece name[].
2. Concatenar parâmetros, por exemplo, first,last. 2. Concatenar parâmetros, por exemplo, first,last.
### GO 1.22.7 <a href="#id-63dc" id="id-63dc"></a> ### GO 1.22.7 <a href="#id-63dc" id="id-63dc"></a>
<figure><img src="../.gitbook/assets/image (1260).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*NVvN1N8sL4g_Gi796FzlZA.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*NVvN1N8sL4g_Gi796FzlZA.jpeg</a></p></figcaption></figure> <figure><img src="../.gitbook/assets/image (1260).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*NVvN1N8sL4g_Gi796FzlZA.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*NVvN1N8sL4g_Gi796FzlZA.jpeg</a></p></figcaption></figure>
1. NÃO reconhece name\[]. 1. NÃO reconhece name[].
2. Preferir o primeiro parâmetro. 2. Preferir o primeiro parâmetro.
### Python 3.12.6 E Werkzeug 3.0.4 E Flask 3.0.3 <a href="#b853" id="b853"></a> ### Python 3.12.6 E Werkzeug 3.0.4 E Flask 3.0.3 <a href="#b853" id="b853"></a>
<figure><img src="../.gitbook/assets/image (1261).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*Se5467PFFjIlmT3O7KNlWQ.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*Se5467PFFjIlmT3O7KNlWQ.jpeg</a></p></figcaption></figure> <figure><img src="../.gitbook/assets/image (1261).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*Se5467PFFjIlmT3O7KNlWQ.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*Se5467PFFjIlmT3O7KNlWQ.jpeg</a></p></figcaption></figure>
1. NÃO reconhece name\[]. 1. NÃO reconhece name[].
2. Preferir o primeiro parâmetro. 2. Preferir o primeiro parâmetro.
### Python 3.12.6 E Django 4.2.15 <a href="#id-8079" id="id-8079"></a> ### Python 3.12.6 E Django 4.2.15 <a href="#id-8079" id="id-8079"></a>
<figure><img src="../.gitbook/assets/image (1262).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*rf38VXut5YhAx0ZhUzgT8Q.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*rf38VXut5YhAx0ZhUzgT8Q.jpeg</a></p></figcaption></figure> <figure><img src="../.gitbook/assets/image (1262).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*rf38VXut5YhAx0ZhUzgT8Q.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*rf38VXut5YhAx0ZhUzgT8Q.jpeg</a></p></figcaption></figure>
1. NÃO reconhece name\[]. 1. NÃO reconhece name[].
2. Preferir o último parâmetro. 2. Preferir o último parâmetro.
### Python 3.12.6 E Tornado 6.4.1 <a href="#id-2ad8" id="id-2ad8"></a> ### Python 3.12.6 E Tornado 6.4.1 <a href="#id-2ad8" id="id-2ad8"></a>
<figure><img src="../.gitbook/assets/image (1263).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*obCn7xahDc296JZccXM2qQ.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*obCn7xahDc296JZccXM2qQ.jpeg</a></p></figcaption></figure> <figure><img src="../.gitbook/assets/image (1263).png" alt=""><figcaption><p><a href="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*obCn7xahDc296JZccXM2qQ.jpeg">https://miro.medium.com/v2/resize:fit:1100/format:webp/1*obCn7xahDc296JZccXM2qQ.jpeg</a></p></figcaption></figure>
1. NÃO reconhece name\[]. 1. NÃO reconhece name[].
2. Preferir o último parâmetro. 2. Preferir o último parâmetro.
## Injeção JSON
### Chaves duplicadas
```ini
obj = {"test": "user", "test": "admin"}
```
A interface pode acreditar na primeira ocorrência enquanto o backend usa a segunda ocorrência da chave.
### Colisão de Chaves: Truncamento de Caracteres e Comentários
Certos caracteres não serão interpretados corretamente pela interface, mas o backend os interpretará e usará essas chaves, isso pode ser útil para **contornar certas restrições**:
```json
{"test": 1, "test\[raw \x0d byte]": 2}
{"test": 1, "test\ud800": 2}
{"test": 1, "test"": 2}
{"test": 1, "te\st": 2}
```
Note como nesses casos o front end pode pensar que `test == 1` e o backend pensará que `test == 2`.
Isso também pode ser usado para contornar restrições de valor como:
```json
{"role": "administrator\[raw \x0d byte]"}
{"role":"administrator\ud800"}
{"role": "administrator""}
{"role": "admini\strator"}
```
### **Usando Truncamento de Comentários**
{% code overflow="wrap" %}
```ini
obj = {"description": "Duplicate with comments", "test": 2, "extra": /*, "test": 1, "extra2": */}
```
{% endcode %}
Aqui usaremos o serializador de cada parser para visualizar sua respectiva saída.
Serializador 1 (por exemplo, a biblioteca GoJay do GoLang) produzirá:
* `description = "Duplicado com comentários"`
* `test = 2`
* `extra = ""`
Serializador 2 (por exemplo, a biblioteca JSON-iterator do Java) produzirá:
* `description = "Duplicado com comentários"`
* `extra = "/*"`
* `extra2 = "*/"`
* `test = 1`
Alternativamente, o uso direto de comentários também pode ser eficaz:
```ini
obj = {"description": "Comment support", "test": 1, "extra": "a"/*, "test": 2, "extra2": "b"*/}
```
A biblioteca GSON do Java:
```json
{"description":"Comment support","test":1,"extra":"a"}
```
A biblioteca simdjson do Ruby:
```json
{"description":"Comment support","test":2,"extra":"a","extra2":"b"}
```
### **Precedência Inconsistente: Desserialização vs. Serialização**
```ini
obj = {"test": 1, "test": 2}
obj["test"] // 1
obj.toString() // {"test": 2}
```
### Float e Inteiro
O número
```undefined
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
```
pode ser decodificado em múltiplas representações, incluindo:
```undefined
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9.999999999999999e95
1E+96
0
9223372036854775807
```
Which might create inconsistências
## Referências ## Referências
* [https://medium.com/@shahjerry33/http-parameter-pollution-its-contaminated-85edc0805654](https://medium.com/@shahjerry33/http-parameter-pollution-its-contaminated-85edc0805654) * [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) * [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)
* [https://medium.com/@0xAwali/http-parameter-pollution-in-2024-32ec1b810f89](https://medium.com/@0xAwali/http-parameter-pollution-in-2024-32ec1b810f89) * [https://medium.com/@0xAwali/http-parameter-pollution-in-2024-32ec1b810f89](https://medium.com/@0xAwali/http-parameter-pollution-in-2024-32ec1b810f89)
* [https://bishopfox.com/blog/json-interoperability-vulnerabilities](https://bishopfox.com/blog/json-interoperability-vulnerabilities)
<figure><img src="https://pentest.eu/RENDER_WebSec_10fps_21sec_9MB_29042024.gif" alt=""><figcaption></figcaption></figure> <figure><img src="https://pentest.eu/RENDER_WebSec_10fps_21sec_9MB_29042024.gif" alt=""><figcaption></figcaption></figure>
{% embed url="https://websec.nl/" %} {% embed url="https://websec.nl/" %}
{% hint style="success" %} {% hint style="success" %}
Aprenda e pratique Hacking AWS:<img src="../.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../.gitbook/assets/arte.png" alt="" data-size="line">\ Learn & practice AWS Hacking:<img src="../.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../.gitbook/assets/arte.png" alt="" data-size="line">\
Aprenda e pratique Hacking GCP: <img src="../.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="../.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte) Learn & practice GCP Hacking: <img src="../.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="../.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
<details> <details>
<summary>Support HackTricks</summary> <summary>Support HackTricks</summary>
* Confira os [**planos de assinatura**](https://github.com/sponsors/carlospolop)! * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Junte-se ao** 💬 [**grupo do Discord**](https://discord.gg/hRep4RUj7f) ou ao [**grupo do telegram**](https://t.me/peass) ou **siga**-nos no **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Compartilhe truques de hacking enviando PRs para os repositórios do** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud). * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
</details> </details>
{% endhint %} {% endhint %}