> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/pt-br/web/business-logic/high-level-logic-vulnerability.md).

# Vulnerabilidade Lógica de Alto Nível

### Vulnerabilidade de Lógica de Alto Nível

**Descrição do laboratório**

Este laboratório não valida corretamente os dados fornecidos pelo usuário. É possível explorar uma falha lógica no processo de compra para alterar o preço final dos itens. / O objetivo é comprar o \*\*

Identificador fornecido:

* **Usuário**: wiener
* **Senha**: peter

**Análise do funcionamento do carrinho**

Quando um produto é adicionado ao carrinho, a requisição enviada se parece com isto:

```bash
productId=1&redir=PRODUCT&quantity=1
```

O `quantidade` parâmetro é controlado diretamente pelo cliente e não é verificado corretamente no lado do servidor.

**Operando a falha lógica**

Se a quantidade for alterada usando um valor negativo, por exemplo:

```bash
productId=1&redir=PRODUCT&quantity=-1
```

O valor total do carrinho está diminuindo, resultando em um preço negativo (por exemplo, \*\* $1337\*\*).

<figure><img src="/files/8f46941673f45d0336f4fd5d845c9be23d312016" alt=""><figcaption></figcaption></figure>

No entanto, ao validar o carrinho, a aplicação bloqueia esse caso com a mensagem:

> *O preço total do carrinho não pode ser menor que zero*

<figure><img src="/files/4594508d46c629915a5fb03563878d194c8b59e0" alt=""><figcaption></figcaption></figure>

**Contornando a restrição**

Para explorar a vulnerabilidade:

Adicione o **jaqueta alvo** com uma quantidade válida:

```bash
productId=1&redir=PRODUCT&quantity=1
```

Em seguida, adicione outro produto com uma quantidade negativa para reduzir o total:

```bash
productId=2&redir=PRODUCT&quantity=-100
```

Isso resulta em um total fortemente negativo (por ex. **-$6241.00**).

<figure><img src="/files/f0f07013a0c642639a1b8072c2af3365988ac307" alt=""><figcaption></figcaption></figure>

Ajuste a quantidade negativa (por ex. `-17`) para que o total final permaneça **positivo**, mas muito baixo (menos de US$ 100).

<figure><img src="/files/1be42d2787b69428e47477d349cd223352e6559a" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/pt-br/web/business-logic/high-level-logic-vulnerability.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
