Description:
Due to lack of updation of state vaiable LikeRegistry::userBalances
in the function LikeRegistry::likeUser()
, the userBalances never gets updated.
Also LikeRegistry::userBalances
variable is used to calculate the funds to send to freshly created multisig wallet.
As a result, 0 ether is send to the multisig wallet.
Impact:
Couple will not be able to spend any funds as there will be no money in wallet.
Proof of Concept:
In LikeRegistry.sol file, update this code
contract LikeRegistry is Ownable {
address public multisig;
...
function matchRewards(address from, address to) internal {
...
MultiSigWallet multiSigWallet = new MultiSigWallet(from, to);
+ @> multisig = address(multiSigWallet);
...
}
}
Now, Create file testMultiSig.t.sol
and add this code
How to run => forge test --mt testBalanceOfMultiSig -vv
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "../src/MultiSig.sol";
import "../src/SoulboundProfileNFT.sol";
import "../src/LikeRegistry.sol";
contract TestMultisig is Test {
MultiSigWallet multiSig;
SoulboundProfileNFT soulboundNFT;
LikeRegistry likeRegistry;
address Alice = address(0x123);
address Bob = address(0x456);
address owner = makeAddr("owner");
function setUp() public {
vm.prank(owner);
soulboundNFT = new SoulboundProfileNFT();
vm.prank(owner);
likeRegistry = new LikeRegistry(address(soulboundNFT));
}
function testBalanceOfMultiSig() public {
vm.prank(Alice);
soulboundNFT.mintProfile("Alice", 25, "ipfs://profileImage");
vm.prank(Bob);
soulboundNFT.mintProfile("Bob", 25, "ipfs://profileImage");
vm.deal(Alice, 10 ether);
vm.deal(Bob, 10 ether);
vm.prank(Alice);
(bool success,) = address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Bob));
vm.prank(Bob);
(bool success2,) =
address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Alice));
assert(address(likeRegistry.multisig()).balance == 0);
console.log(address(likeRegistry.multisig()).balance);
}
}
* Ran 1 test for test/testMultiSig.t.sol:TestMultisig
* [PASS] testBalanceOfMultiSig() (gas: 1442484)
* Logs:
* 0
*
* Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.16ms (807.30µs CPU time)
*/
Recommended Mitigation:
In LikeRegistry.sol please add
function likeUser(address liked) external payable {
...
if (likes[liked][msg.sender]) {
matches[msg.sender].push(liked);
matches[liked].push(msg.sender);
emit Matched(msg.sender, liked);
matchRewards(liked, msg.sender);
}
+ @> userBalances[msg.sender] += msg.value;
}