Swivel.setFee() is implemented wrongly.
Originally disclosed on Code4rena
Submitted by hansfriese, also found by jonatascm
Swivel.setFee() is implemented wrongly. Swivel.feenominators won’t be set as expected.
Proof of Concept
This function has a parameter “i” for the index of the new fee denomination but it isn’t used during the update.
Tools Used
Solidity Visual Developer of VSCode
Recommended Mitigation Steps
This line should be modified like below.
feenominators[i[x]] = d[x];
JTraversa (Swivel) disagreed with severity and commented:
Given this allows us to change fees post initialization, and doesn’t lead to the leakage of value or loss of funds, but a potential issue for admins solely (in a rare edge case where fees would even need to be changed), I might consider this low risk?
I agree with the warden here given that this is an incorrect implementation of the intended functionality. The warden’s suggestion shows that the function was not working as intended; if in production, for instance, this was not caught then calls to
setFeewould not work as intended and not set any fees across the markets. Instead, it would only populate the zero index of the 2nd-demensional arrayuint16[4] public feenominators;losing these values[zcTokenInitiate, zcTokenExit, vaultInitiate, vaultExit]and breaking functionality.
Yeah I was kind of on the fence on this one thinking the method wouldn’t impact the current feenominators in the way you’ve stated, but because it actually could have an impact, and the event itself also would be misleading, removing the disagreement.
Addressed: https://github.com/Swivel-Finance/gost/pull/419.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity business logic bug in Swivel v3 contest. Code4rena made it public on 29 September 2022. Found in the 2022-07-swivel audit contest (finding M-02).
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.