> 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/fr/web/business-logic/low-level-logic-flaw.md).

# Défaillance logique de bas niveau

### Application erronée des règles métier

**Description du laboratoire**

Ce labo contient un \*\*défaut logique dans le processus d'achat\*\*. En raison d'une mauvaise application des règles commerciales, il est possible de manipuler le calcul du panier afin d'acheter une "Lightweight l33t leather jacket" à un prix inattendu.

Identifiant fourni :

* **Utilisateur :** wiener
* **Mot de passe :** peter

**Analyse du comportement**

Lors de l'ajout d'un produit au panier, la requête suivante est utilisée :

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

Ce paramètre peut être envoyé **un grand nombre de fois** sans contrôle strict de la valeur cumulée.

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

La requête est envoyée à **Intruder** avec une charge utile nulle configurée dans **Continuer indéfiniment** mode, et un maximum de **1 requête concurrente**.

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

Après suffisamment d'itérations, le **prix total du panier devient négatif**.

<figure><img src="/files/30061c086ea3ed769d8a3e69e9e5f16cbf1e4486" alt=""><figcaption></figcaption></figure>

**Cause du problème**

La vulnérabilité provient d'un entier signé **débordement**. / L'application utilise un **entier signé sur 32 bits**, dont les limites sont :

* Valeur minimale : `-2 147 483 648`
* Valeur maximale : `2 147 483 647`

Lorsque le total dépasse la valeur maximale autorisée, il **se recalcule en valeurs négatives** en raison d'un dépassement arithmétique.

**Contrôles inadéquats**

Même si l'application empêche le paiement lorsque le total est inférieur à 0, **aucune vérification correcte n'est effectuée lors des calculs intermédiaires**.

Cela vous permet d'ajuster le panier jusqu'à obtenir un montant final positif mais très faible.

<figure><img src="/files/6afbaf0e9ba02cd2f6300c5e5356a944192f5b6b" alt=""><figcaption></figcaption></figure>

**Ajustement du calcul final**

Pour obtenir un montant \*\* supérieur à 0 $ et inférieur à 100 $\*\*, le calcul suivant est effectué :

* Coût de la veste : **$1,337**
* Valeur requise pour provoquer le débordement : \**14 018 329* \*
* Calcul :

  ```bash
  14 018 329 / 1337 ≈ 10 484 fois
  ```

Soumission par lots (`quantity = 99`):

```bash
10 484 / 99 ≈ 105 requêtes
```

**Composition finale du panier**

Pour obtenir un total valide après débordement :

* **32 123** vestes à 1337 $
* **21** chaussures Baby minding à 60,79 $
* **Total final :** **$54.63**


---

# 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/fr/web/business-logic/low-level-logic-flaw.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.
