Closed code423n4 closed 2 years ago
WatchPug
https://github.com/code-423n4/2021-12-amun/blob/98f6e2ff91f5fcebc0489f5871183566feaec307/contracts/bridge/contracts/amunBasketBridge/PolygonERC20Wrapper.sol#L67-L68
_mint(_msgSender(), amount); _burn(_msgSender(), amount);
PolygonERC20Wrapper.sol#withdraw() and PolygonERC20Wrapper.sol#withdrawTo() will call _mint and _burn with the same amount, which will SLOAD and SSTORE _balances[account] and _totalSupply multiple times, but resting to the original state at the end.
PolygonERC20Wrapper.sol#withdraw()
PolygonERC20Wrapper.sol#withdrawTo()
_mint
_burn
SLOAD
SSTORE
_balances[account]
_totalSupply
We believe it's not gas efficient.
Consider emitting Transfer events directly.
Transfer
This is do to how polygon bridge works
This is intended behaviour, marking invalid.
invalid
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-amun/blob/98f6e2ff91f5fcebc0489f5871183566feaec307/contracts/bridge/contracts/amunBasketBridge/PolygonERC20Wrapper.sol#L67-L68
PolygonERC20Wrapper.sol#withdraw()
andPolygonERC20Wrapper.sol#withdrawTo()
will call_mint
and_burn
with the same amount, which willSLOAD
andSSTORE
_balances[account]
and_totalSupply
multiple times, but resting to the original state at the end.We believe it's not gas efficient.
Recommendation
Consider emitting
Transfer
events directly.