Attacker can drain all the projects within minutes, if admin account has been exposed #264
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
valid
Lines of code
https://github.com/code-423n4/2022-08-rigor/blob/5ab7ea84a1516cb726421ef690af5bc41029f88f/contracts/HomeFi.sol#L156-L169
https://github.com/code-423n4/2022-08-rigor/blob/5ab7ea84a1516cb726421ef690af5bc41029f88f/contracts/HomeFi.sol#L199-L208
Vulnerability details
Impact
In case where the admin wallet has been hacked, the attacker can drain all funds out of the project within minutes. All the attacker needs is the admin to sign a single meta/normal tx.
Even though the likelihood of the admin wallet being hacked might be low, given that the impact is critical - I think this makes it at least a medium bug.
Examples of cases where the attacker can gain access to admin wallet:
Since the forwarder has the power to do everything in the system , once an attacker manages to replace it with a malicious forwarder, he can do whatever he wants withing minutes:
Even when signatures are required, you can bypass it by using the
approveHash
function.Proof of Concept
Here's a PoC for taking over and running the
Project.setComplete()
function (I haven't included a whole process of changing SC etc. since that would be too time consuming, but there shouldn't be a difference between functions, all can be impersonated once you control the forwarder).The PoC was added to projectTests.ts#L1109, and is based on the 'should be able to complete a task' test.
Recommended Mitigation Steps
Limit
approveHash
to contracts only - I understood from the sponsor that it is used for contracts to sign hashes. So limiting it to contracts only can help prevent stealing funds (from projects that are held by EOA) in case that the forwarder has been compromised (this is effective also in case there's some bug in the forwarder contract).msg.sender
instead of_msgSender()
, this will also have a similar effect (it will allow also EOA to use the function, but not via forwarder).Make the process of replacing the forwarder or the admin a 2 step process with a delay between the steps (except for disabling the forwarder, in case the forwarder was hacked). This will give the admin the option to take steps to stop the attack, or at least give the users time to withdraw their money.
HomeFi
onlyAdmin
modifier (i.e. usgmsg.sender
instead of_msgSender()
), given that it's not going to be used that often it may be worth giving up the comfort for hardening securityThe text was updated successfully, but these errors were encountered: