Off-chain JavaScript logic in Chainlink Functions does not validate HTTP status codes or verify that expected fields (e.g., lat, lon, weather) exist and are correctly typed in API responses. Consequently, malformed or non-200 responses can slip through, leading to reverted transactions, denial-of-service (DoS), or incorrect metadata updates.
In the GetWeather.js script, geocoding and weather API calls are made as follows:
No HTTP status validation.
The code only inspects response.error, which remains null for non-200 status codes.
No payload validation
It assumes that data.lat, data.lon, and data.weather[0].id always exist and have the correct types.
Denial-of-Service (DoS):
Non-200 or malformed responses will cause the Chainlink callback to revert. Repeated failures consume LINK and gas, potentially exhausting resources and halting future updates or mints.
Funds Loss:
Users may pay ETH for a mint, but if the callback reverts afterward, the NFT never mints and the ETH is retained.
Incorrect Metadata:
Invalid values (e.g., lat = undefined) could be coerced into default or fallback states, causing NFTs to display misleading weather conditions.
Resource Exhaustion:
Every failed callback burns gas and LINK, weakening protocol resilience over time.
Medium to High. Public APIs frequently return non-200 statuses (e.g., 429 rate limits, 404 invalid ZIP codes, 5xx server errors). Without explicit checks, failures will inevitably occur as usage scales—or can be triggered maliciously.
Supply an invalid ZIP code (e.g., "BADZIP,XX") to trigger a 404:
Because geoCodingResponse.error is null, the script continues with invalid coordinates.
The on-chain callback fails during decoding, consuming LINK and gas, and causes the mint or update to revert.
Add explicit HTTP status and payload validation to GetWeather.js, immediately after each request in geoCodingRequest and weatherRequest:
Status checks guard against unexpected HTTP statuses (404, 429, 500).
Type assertions ensure lat, lon, and weather[0].id exist and are correctly typed.
Early throws prevent downstream logic from executing on malformed inputs, saving gas and LINK while preserving correct on-chain behavior.
Implementing these checks will make the protocol robust against API anomalies, rate limits, and malicious inputs—safeguarding user funds and LINK budgets.
This is informational. It is user's responsibility to provide correct input arguments. If the user provides incorrect arguments, it will lead to incorrect results, lost funds or failed transaction.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.