Beatland Festival

AI First Flight #4
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Missing String Length Validation in `createMemorabiliaCollection()`

Root + Impact

Description

  • The `createMemorabiliaCollection()` function does not validate the length of `name` and `baseUri` string parameters. Extremely long strings could cause gas issues during storage and retrieval operations.

    ```solidity

    function createMemorabiliaCollection(

    string memory name,

    string memory baseUri,

    uint256 priceInBeat,

    uint256 maxSupply,

    bool activateNow

    ) external onlyOrganizer returns (uint256) {

    require(bytes(name).length > 0, "Name required"); // @> No maximum length check

    require(bytes(baseUri).length > 0, "URI required"); // @> No maximum length check

    // ...

    }

    ```


Risk

Likelihood:

  • * Organizer can set any string length

    * Accidental or malicious use of extremely long strings

    * Storage operations become expensive

Impact:

  • * High gas costs for storing and reading long strings

    * Potential DoS if strings are extremely long

    * Poor user experience

Proof of Concept

```diff
+uint256 constant MAX_NAME_LENGTH = 100;
+uint256 constant MAX_URI_LENGTH = 200;
function createMemorabiliaCollection(...) external onlyOrganizer returns (uint256) {
require(bytes(name).length > 0, "Name required");
+ require(bytes(name).length <= MAX_NAME_LENGTH, "Name too long");
require(bytes(baseUri).length > 0, "URI required");
+ require(bytes(baseUri).length <= MAX_URI_LENGTH, "URI too long");
// ...
}
```

Recommended Mitigation

```diff
+uint256 constant MAX_NAME_LENGTH = 100;
+uint256 constant MAX_URI_LENGTH = 200;
function createMemorabiliaCollection(...) external onlyOrganizer returns (uint256) {
require(bytes(name).length > 0, "Name required");
+ require(bytes(name).length <= MAX_NAME_LENGTH, "Name too long");
require(bytes(baseUri).length > 0, "URI required");
+ require(bytes(baseUri).length <= MAX_URI_LENGTH, "URI too long");
// ...
}
```
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge 16 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!