From 3b6aa9ccbb8143e4ae95183aba08642f6dd20074 Mon Sep 17 00:00:00 2001 From: Tamara <69479754+TamaraRingas@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:41:20 +0200 Subject: [PATCH] fix: add sanity check for `intertimAsset == 0` in `approveRefund()` [sup 9337] (#656) --- src/router-plus/SuperformRouterPlusAsync.sol | 2 ++ test/unit/router-plus/SuperformRouterPlus.t.sol | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/router-plus/SuperformRouterPlusAsync.sol b/src/router-plus/SuperformRouterPlusAsync.sol index 254fcbf87..674bc6686 100644 --- a/src/router-plus/SuperformRouterPlusAsync.sol +++ b/src/router-plus/SuperformRouterPlusAsync.sol @@ -452,6 +452,8 @@ contract SuperformRouterPlusAsync is ISuperformRouterPlusAsync, BaseSuperformRou Refund memory r = refunds[routerPlusPayloadId_]; + if (r.interimToken == address(0)) revert INVALID_REFUND_DATA(); + approvedRefund[routerPlusPayloadId_] = true; /// @dev deleting to prevent re-entrancy diff --git a/test/unit/router-plus/SuperformRouterPlus.t.sol b/test/unit/router-plus/SuperformRouterPlus.t.sol index 92a1ea8da..800734a81 100644 --- a/test/unit/router-plus/SuperformRouterPlus.t.sol +++ b/test/unit/router-plus/SuperformRouterPlus.t.sol @@ -2506,6 +2506,12 @@ contract SuperformRouterPlusTest is ProtocolActions { SuperformRouterPlusAsync(ROUTER_PLUS_ASYNC_SOURCE).approveRefund(1); vm.stopPrank(); + /// @dev testing invalid refund data + vm.startPrank(deployer); + vm.expectRevert(ISuperformRouterPlusAsync.INVALID_REFUND_DATA.selector); + SuperformRouterPlusAsync(ROUTER_PLUS_ASYNC_SOURCE).approveRefund(3); + vm.stopPrank(); + /// @dev testing valid refund approval uint256 balanceBefore = MockERC20(refundToken).balanceOf(deployer); uint256 routerBalanceBefore = MockERC20(refundToken).balanceOf(address(ROUTER_PLUS_ASYNC_SOURCE));