Weather Witness

First Flight #40
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

[EVMNINJA-WW03] No Validation of Weather Enum Values

Root + Impact

Description

When decoding the weather data from Chainlink Functions, there is no validation that the received value corresponds to a valid Weather enum value. If the Functions response contains an invalid value, it could be cast to an invalid enum state, potentially causing unexpected behavior.

uint8 weather = abi.decode(response, (uint8));
// Assuming Weather enum has values from 0 to N-1
require(weather < uint8(type(Weather).max), "Invalid weather value");
s_tokenIdToWeather[tokenId] = Weather(weather);

Risk

Likelihood:

Medium likelihood.

Impact:

Medium impact.

Proof of Concept

Recommended Mitigation

Add validation to ensure the decoded weather value is within the valid range for the Weather enum:

uint8 weather = abi.decode(response, (uint8));
// Assuming Weather enum has values from 0 to N-1
require(weather < uint8(type(Weather).max), "Invalid weather value");
s_tokenIdToWeather[tokenId] = Weather(weather);
Updates

Appeal created

bube Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

[Invalid] Weather enum is not checked

The implementation to get the current weather is written in `GetWeather.js`. The `weather_enum` will be always in the expected range.

Support

FAQs

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