Weather Witness

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

Incoherent condition for `weather_id === 800`

Root + Impact

Description

  • Normally, weather classification should follow a consistent approach to simplify interpretation and reduce errors.

  • However, in this implementation, a hardcoded check for weather_id === 800 is performed outside the general classification logic using weather_id_x, which can lead to inconsistent or missed classifications.

const weather_id = weatherResponse.data.weather[0].id;
const weather_id_x = parseInt(weather_id / 100);
// Inconsistent condition:
if (weather_id === 800) weather_enum = 0;
@> // This line uses a specific value (800), while the rest use weather_id_x for consistency

Risk

Likelihood:

  • This will occur whenever the weather condition is "clear" (id 800), which is a common condition in many regions.

  • If weather_id is mistakenly not equal to 800 exactly (e.g., forecast-specific codes like 801), the logic will skip the clear case and fall into the default (else block, returning 4 for "windy").

Impact:

  • Leads to incorrect weather categorization.

  • Can cause downstream logic relying on this enum to behave incorrectly (e.g., smart contract logic or payouts depending on weather conditions).

Proof of Concept

None

Recommended Mitigation

Consider changing the weather_id variable by weather_id_x and changing the 800 value to another one that is not used already.

Or restructure the condition tree for consistency:

- const weather_id_x = parseInt(weather_id / 100);
+ const weather_id_x = Math.floor(weather_id / 100); // use floor for clarity
- if (weather_id === 800) weather_enum = 0;
+ if (weather_id_x === 8) {
+ if (weather_id === 800) weather_enum = 0; // clear
+ else weather_enum = 1; // cloudy
+ }
Updates

Appeal created

bube Lead Judge 6 days ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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