> For the complete documentation index, see [llms.txt](https://doc.auditx.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.auditx.net/auditx-ecosystem/services/types-of-vulnerabilities-detected/integer-overflows-underflows.md).

# Integer Overflows/Underflows

**Integer Overflows** and **Underflows** occur when mathematical operations exceed the storage limits of a variable, causing unexpected behavior. These vulnerabilities allow attackers to manipulate values in ways that can break contract logic.

**Integer Overflows** and **Underflows** occur when mathematical operations exceed the storage limits of a variable, causing unexpected behavior. These vulnerabilities allow attackers to manipulate values in ways that can break contract logic.

#### **How They Work** <a href="#how-they-work" id="how-they-work"></a>

1. **Integer Overflow:** When a value exceeds the maximum limit of its data type, it wraps around to the minimum value. Example:

   ```
   solidity

   uint8 x = 255; // Max value for uint8
   x += 1;       // Overflow: x becomes 0
   ```
2. **Integer Underflow:** When a value is reduced below the minimum limit of its data type, it wraps around to the maximum value. Example:

   ```
   solidity

   uint8 x = 0; // Min value for uint8
   x -= 1;     // Underflow: x becomes 255
   ```

#### **Real-Life Impact** <a href="#real-life-impact" id="real-life-impact"></a>

Attackers exploit overflows/underflows to:

* Mint extra tokens.
* Bypass balance checks.
* Gain unauthorized access to funds.


---

# 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://doc.auditx.net/auditx-ecosystem/services/types-of-vulnerabilities-detected/integer-overflows-underflows.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.
