Node runner who is already known to be malicious cannot be banned before corresponding smart wallet is created
The only way to mark a node runner as banned was through the wallet rotation function, which reverts if the node runner has no smart wallet yet. A node runner already known to be malicious could therefore keep interacting with the protocol until a wallet was created and the DAO noticed and acted.
Submitted by rbserver
https://github.com/code-423n4/2022-11-stakehouse/blob/main/contracts/liquid-staking/LiquidStakingManager.sol#L356-L377 https://github.com/code-423n4/2022-11-stakehouse/blob/main/contracts/liquid-staking/LiquidStakingManager.sol#L507-L509 https://github.com/code-423n4/2022-11-stakehouse/blob/main/contracts/liquid-staking/LiquidStakingManager.sol#L426-L492
Currently, the rotateNodeRunnerOfSmartWallet function provides the only way to set bannedNodeRunners to true for a malicious node runner. However, before the node runner calls the registerBLSPublicKeys function to create a smart wallet, calling the rotateNodeRunnerOfSmartWallet function reverts. This means that for a node runner, who is already known to be malicious such as someone controlling a hacker address, calling the isNodeRunnerBanned function always return false before the registerBLSPublicKeys function is called for the first time, and executing require(isNodeRunnerBanned(msg.sender) == false, "Node runner is banned from LSD network") when calling the registerBLSPublicKeys function for the first time is not effective. As the monitoring burden can be high, the malicious node runner could interact with the protocol maliciously for a while already after the registerBLSPublicKeys function is called until the DAO notices the malicious activities and then calls the rotateNodeRunnerOfSmartWallet function. When the DAO does not react promptly, some damages to the protocol could be done already.
function rotateNodeRunnerOfSmartWallet(address _current, address _new, bool _wasPreviousNodeRunnerMalicious) external {
...
if (msg.sender == dao && _wasPreviousNodeRunnerMalicious) {
bannedNodeRunners[_current] = true;
emit NodeRunnerBanned(_current);
}
...
}
function isNodeRunnerBanned(address _nodeRunner) public view returns (bool) {
return bannedNodeRunners[_nodeRunner];
}
function registerBLSPublicKeys(
bytes[] calldata _blsPublicKeys,
bytes[] calldata _blsSignatures,
address _eoaRepresentative
) external payable nonReentrant {
...
require(isNodeRunnerBanned(msg.sender) == false, "Node runner is banned from LSD network");
address smartWallet = smartWalletOfNodeRunner[msg.sender];
if(smartWallet == address(0)) {
// create new wallet owned by liquid staking manager
smartWallet = smartWalletFactory.createWallet(address(this));
emit SmartWalletCreated(smartWallet, msg.sender);
// associate node runner with the newly created wallet
smartWalletOfNodeRunner[msg.sender] = smartWallet;
nodeRunnerOfSmartWallet[smartWallet] = msg.sender;
_authorizeRepresentative(smartWallet, _eoaRepresentative, true);
}
...
}
Proof of Concept
Please add the following test in test\foundry\LSDNFactory.t.sol. This test will pass to demonstrate the described scenario.
function testMaliciousNodeRunnerCannotBeBannedBeforeCorrespondingSmartWalletIsCreated() public {
vm.prank(address(factory));
manager.updateDAOAddress(admin);
// Simulate a situation where accountOne is known to be malicious already.
// accountOne is not banned at this moment.
assertEq(manager.bannedNodeRunners(accountOne), false);
// Calling the rotateNodeRunnerOfSmartWallet function is the only way to ban accountOne;
// however, calling it reverts because accountOne has not called the registerBLSPublicKeys function to create a smart wallet yet.
// This means that it is not possible to prevent accountOne from interacting with the protocol until her or his smart wallet is created.
vm.prank(admin);
vm.expectRevert("Wallet does not exist");
manager.rotateNodeRunnerOfSmartWallet(accountOne, accountTwo, true);
}
Tools Used
VSCode
Recommended Mitigation Steps
A function, which should be only callable by the DAO, that can directly set bannedNodeRunners for a node runner can be added.
vince0656 (Stakehouse) confirmed
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the ban flag could only be set as a side effect of rotating an existing smart wallet, so there was no direct DAO-only path to ban an address before its first registration.
Impact
A node runner already known to be malicious could interact with the protocol until the DAO noticed and rotated the wallet, so some damage could be done if the DAO did not react promptly.
What the attacker needed
DAO role on the manager; target address has no smart wallet yet
The fix
A DAO-only function should be added that can directly set the banned flag for a node runner.
How it was found
- Have the DAO address set on the manager.
- Confirm the known malicious account is not currently banned.
- As the DAO, call the wallet rotation function for that account with the malicious flag set.
- Observe the call reverts because the account has no smart wallet yet.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A node runner is someone who operates part of a staking network. The contract kept a list of banned node runners, but the only code that added someone to that list also required that person to already have a wallet in the system, so a known bad actor could not be blocked in advance.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.