> For the complete documentation index, see [llms.txt](https://reports.immunefi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://reports.immunefi.com/ethereum-protocol-or-attackathon/37186-bc-insight-missing-validation-for-fixed-size-bytes-types-in-abi-parsing.md).

# #37186 \[BC-Insight] Missing Validation for Fixed-Size bytes Types in ABI Parsing

**Submitted on Nov 27th 2024 at 22:43:54 UTC by @CertiK for** [**Attackathon | Ethereum Protocol**](https://immunefi.com/audit-competition/ethereum-protocol-attackathon)

* **Report ID:** #37186
* **Report Type:** Blockchain/DLT
* **Report severity:** Insight
* **Target:** <https://github.com/ledgerwatch/erigon>
* **Impacts:**
  * (Specifications) A bug in specifications with no direct impact on client implementations

## Description

## Brief/Intro

In the NewType function within type.go, there is a lack of validation for the size of fixed-length bytes types.

## Vulnerability Details

According to the argument encoding for the solidity, the bytes should limited to 32 bytes:\
<https://docs.soliditylang.org/en/v0.8.23/abi-spec.html>

\| bytes: binary type of M bytes, 0 < M <= 32.

However, such limitation is missing in the accounts/abi/type.go:

```
   case "bytes":
       if varSize == 0 {
           typ.T = BytesTy
       } else {
           typ.T = FixedBytesTy
           typ.Size = varSize
       }
```

Also, it should be noted the validation has been added in Geth: <https://github.com/ethereum/go-ethereum/pull/26075>

## Impact Details

Without validation, the code might accept invalid bytes types with sizes outside the allowed range and break the spec.

## References

* <https://docs.soliditylang.org/en/v0.8.23/abi-spec.html>
* <https://github.com/ethereum/go-ethereum/pull/26075>

## Proof of Concept

## Proof of Concept

```
func TestNewFixedBytesOver32(t *testing.T) {
   _, err := NewType("bytes64", "", nil)
   if err == nil {
       t.Errorf("fixed bytes with size over 32 is mistakenly allowed")
   }
}
```

```
--- FAIL: TestNewFixedBytesOver32 (0.00s)
   /Users/xxx/erigon/accounts/abi/type_test.go:376: fixed bytes with size over 32 is mistakenly allowed
FAIL
FAIL    github.com/erigontech/erigon/accounts/abi   0.321s
FAIL
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://reports.immunefi.com/ethereum-protocol-or-attackathon/37186-bc-insight-missing-validation-for-fixed-size-bytes-types-in-abi-parsing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
