Vulnerability Details
SeasonGettersFacet
has several functions that rely on the decodedCaseData
to return the Relative Temperature Change(mT
) and Relative Grown Stalk to Liquidity change(mL
). Functions:
function getChangeFromCaseId(uint256 caseId) public view returns (uint32, int8, uint80, int80) {
LibCases.CaseData memory cd = LibCases.decodeCaseData(caseId);
return (cd.mT, cd.bT, cd.mL, cd.bL);
}
function getRelTemperatureChangeFromCaseId(uint256 caseId) external view returns (uint32 mt) {
(mt, , , ) = getChangeFromCaseId(caseId);
return mt;
}
function getAbsBeanToMaxLpRatioChangeFromCaseId(
uint256 caseId
) external view returns (uint80 ml) {
(, , ml, ) = getChangeFromCaseId(caseId);
return ml;
}
The problem is that those values will be always incorrect due to the code for those being commented on LibCases.decodeCaseData
function decodeCaseData(uint256 caseId) internal view returns (CaseData memory cd) {
bytes32 _caseData = getDataFromCase(caseId);
@>
cd.bT = int8(uint8(bytes1(_caseData << 32)));
@>
cd.bL = int80(uint80(bytes10(_caseData << 120)));
}
Impact
Tools Used
Manual Review
Recommendations
Uncomment the code for mL
and mT
.
function decodeCaseData(uint256 caseId) internal view returns (CaseData memory cd) {
bytes32 _caseData = getDataFromCase(caseId);
- // cd.mT = uint32(bytes4(_caseData)); Uncomment if you want to use mT
+ cd.mT = uint32(bytes4(_caseData));
cd.bT = int8(uint8(bytes1(_caseData << 32)));
- // cd.mL = uint80(bytes10(_caseData << 40)); Uncomment if you want to use mL
+ cd.mL = uint80(bytes10(_caseData << 40));
cd.bL = int80(uint80(bytes10(_caseData << 120)));
}