addDerivative function is used to add a specified contract address as a new derivative. However, since the function doesn't perform any address validation, it may allow the same address to be defined twice or to be defined zero address by mistake. This could mislead investors' calculations and lead to undesirable consequences in the contract. Therefore, it's important to add address validation to the function to prevent the same address from being defined multiple times or zero address to be applied.
Lines of code
https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L182-L186
Vulnerability details
Explanation
addDerivative function is used to add a specified contract address as a new derivative. However, since the function doesn't perform any address validation, it may allow the same address to be defined twice or to be defined zero address by mistake. This could mislead investors' calculations and lead to undesirable consequences in the contract. Therefore, it's important to add address validation to the function to prevent the same address from being defined multiple times or zero address to be applied.
Proof of Concept
https://github.com/code-423n4/2023-03-asymmetry/blob/main/contracts/SafEth/SafEth.sol#L182-L186
Tools Used
Manuel review & Slither & MythX
Recommended Mitigation Steps
The following implementation can be applied to fix the issue.