Closed
Description
Lines of code
Vulnerability details
Impact
Users will not be able to transfer KIBToken to themselves after the mitigation.
This is not ERC20 compliant.
Proof of Concept
Function KIBToken._transfer() will revert when to == from
:
function _transfer(address from, address to, uint256 amount) internal override {
...
if (to == from) {
revert Errors.CANNOT_TRANSFER_TO_SELF();
}
...
}
Tools Used
VS Code
Recommended Mitigation Steps
We should allow users to transfer KIBToken to themselves, but not perform incorrect calculations
diff --git a/src/kuma-protocol/KIBToken.sol b/src/kuma-protocol/KIBToken.sol
index d1977a5..b9cae75 100644
--- a/src/kuma-protocol/KIBToken.sol
+++ b/src/kuma-protocol/KIBToken.sol
@@ -270,9 +270,6 @@ contract KIBToken is IKIBToken, ERC20PermitUpgradeable, UUPSUpgradeable {
if (to == address(0)) {
revert Errors.ERC20_TRANSER_TO_THE_ZERO_ADDRESS();
}
- if (to == from) {
- revert Errors.CANNOT_TRANSFER_TO_SELF();
- }
_refreshCumulativeYield();
_refreshYield();
@@ -280,6 +277,11 @@ contract KIBToken is IKIBToken, ERC20PermitUpgradeable, UUPSUpgradeable {
if (startingFromBalance < amount) {
revert Errors.ERC20_TRANSFER_AMOUNT_EXCEEDS_BALANCE();
}
+ if (from == to) {
+ emit Transfer(from, to, amount);
+ return;
+ }
+
uint256 newFromBalance = startingFromBalance - amount;
uint256 newToBalance = this.balanceOf(to) + amount;