Skip to content
Access control Audit finding Intermediate

Admin Privilege - Owner can rug via ThecosomataETH.withdraw

The ThecosomataETH contract's withdraw function lets the owner transfer any ERC20 token, including the protocol's own BTRFLY and WETH, so the owner could steal deposited funds. An attacker with owner privileges could front-run the keeper and take the funds.

Alex the Entreprenerd Follow

Originally disclosed on Code4rena

Submitted by Alex the Entreprenerd, also found by gzeon

Due to the generalized nature of withdraw the function is a clear rug-vector, allowing the owner to steal all funds.

Ideally, you should add some validation logic to limit the tokens or the amounts that the owner can withdraw.

Additionally, it’s important that you disclose the level of admin privilege and the risk it can cause to your users and depositors.

Recommended Mitigation Steps

Disclose the admin privilege in your docs. Refactor the code to reduce it.

kphed (Redacted Cartel) disputed and commented:

The owner is our protocol multisig which has proven itself to be a trustworthy steward of funds (e.g. manages the Redacted treasury funds).

The withdraw method is simply a utility to remove any ERC20 tokens that are unintentionally received. There won’t be any funds to steal since it’s not intended for the Thecosomata contract to custody funds for any extended period of time: our keepers will constantly poll the contract so that any BTRFLY received gets paired with ETH and added to our Curve LP immediately - any excess is burned.

Alex the Entreprenerd (judge) closed as Invalid and commented:

It should be noted that I have submitted the finding, and in being judge of the contest am forfeiting my potential winnings.

Personally, I don’t believe a multisig gives any particular security guarantee to depositors beside the fact that it takes X amount of people to agree on how to move funds.

The sponsor is making it clear that the owner in this case is also the depositor of funds. This means that the multi-sig is self custodying the funds into the contract.

As such, the finding doesn’t prove any additional security risk beside those that comes with a multi-sig.

For those reasons, the finding is invalid.

kphed (Redacted Cartel) commented:

Thanks for following up with your thoughts @Alex the Entreprenerd.

NOTE: Mistakenly made comment below because I thought this was referring to the BribeVault contract.

The sponsor is making it clear that the owner in this case is also the depositor of funds. This means that the multi-sig is self custodying the funds into the contract.

Just to clear up any miscommunication or misunderstandings, we’ve never stated that the owner is the depositor of funds - the funds are deposited by bribers. The owner/admin only whitelists contracts that have permission to call the BribeVault’s deposit methods but those contracts do not custody funds beyond the deposit transactions (this is also only the case when a briber deposits a native token).

Alex the Entreprenerd (judge) reopened as Valid and commented:

Thank you for the clarification @kphed.

If the bribers are not the same as the owner then the owner technically has the ability of withdrawing funds at any time, which puts the depositors under the risk of the owner rugging.

Typically a Vault Protocol (Yearn, Badger) would have a check for “protectedTokens”, in this case BTRFLY and WETH to prevent taking that type of operation.

As it stands, the multisig can move the funds at any time, technically can frontrun the keeper and steal the funds.

Also notice that you said that there will be a keeper for performUpkeep but the modifier is onlyOwner which either means you’ll have an EOA as the owner, or you may want to change the access control checker (or remove it as Chainlink docs would require you to).

With the information I have, I’m inclined to revert back to medium severity.

While there’s always the counter-argument that the multisig or governance will not rug, the only guarantee for it is the inability to rug by structuring the smart contract in a way that makes it impossible to move funds (e.g. add a check against moving BTRFLY and WETH, allow sweeping of other “random” tokens)

kphed (Redacted Cartel) commented:

Sorry, disregard my last comment, I mistakenly read your comment as one directed towards BribeVault (which also has a method to withdraw tokens). You’re correct, BTRFLY is minted by our protocol for ThecosomataETH. That said, we still don’t consider the possibility of admin-rugging a real concern.

Typically a Vault Protocol (Yearn, Badger) would have a check for “protectedTokens”, in this case BTRFLY and WETH to prevent taking that type of operation.

This is a potential idea, thanks, I’ll share it with the team.

Also notice that you said that there will be a keeper for performUpkeep but the modifier is onlyOwner which either means you’ll have an EOA as the owner, or you may want to change the access control checker (or remove it as Chainlink docs would require you to).

Tagging @drahrealm as he’s implementing ThecosomataETH. Your comment about onlyOwner is a good one though - it does appear to be a mistake or can be improved tremendously (e.g. use AccessControl and add a role limited to calling this and not the withdraw method).

Alex the Entreprenerd (judge) commented:

Would highly recommend limiting the withdrawal to specific tokens (ideally exclude important tokens), this would provide strong security guarantees against a rug.

Also limiting roles can help reduce trust, however, it wouldn’t address the underlying issue that “someone” can move the funds.

With the information I have, I believe Medium Severity to be appropriate, and believe the sponsor has set motion to minimize trust as well as add additional security guarantees.


The original report as published on Code4rena, by Alex the Entreprenerd. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

The withdraw function has no restriction on which tokens can be withdrawn, so the owner can move protected tokens like BTRFLY and WETH.

Impact

The owner (a multisig) could front-run the keeper and withdraw all BTRFLY and WETH held by the contract, putting depositors at risk of a rug pull.

What the attacker needed

Owner privileges (multisig)

The fix

The withdrawal should be limited to specific tokens, excluding important tokens like BTRFLY and WETH, and admin privileges should be disclosed.

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 smart contract has an owner who can call special functions. Here, the owner could call withdraw to move any token out of the contract, including the valuable tokens users deposited. That means the owner could take everyone's funds, which is called a rug.

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.

More by Alex the Entreprenerd

View all

7 more disclosed reports, best first.

More from Redacted Cartel contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.