erasureprotocol / erasure-protocol

Information wants to be expensive
https://erasure.world/
MIT License
164 stars 27 forks source link

💣 Griefing RatioType is not type safe, improper decoding #282

Closed fulldecent closed 4 years ago

fulldecent commented 4 years ago

Griefing.RatioType is defined as an enum.

enum RatioType { NaN, Inf, Dec }

Some usage is correct per the ABI but is not type safe.

struct AgreementParams {
    uint120 ratio;
    uint8 ratioType;
    uint128 countdownLength;
}

Additionally this can lead to incorrect decoding of transaction data.

... abi.decode(agreementParams, (uint256, uint8, uint256));

Best practice is to use safe types when they are defined.

Recommendation: use safe types, correct incorrect type usage

Additional notes:

Reference: