Skip to content
Access control Audit finding Intermediate

A Single Malicious Trusted Account Can Takeover Parent Contract

Any single trusted account can remove all other trusted accounts from the isTrusted mapping, effectively taking over the trusted group that controls all restricted functions in the parent contract. This could lead to loss of funds if a trusted account becomes malicious or is compromised.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood, also found by hickuphh3

The requiresTrust() modifier is used on the strategy, vault and factory contracts to prevent unauthorised accounts from calling restricted functions. Once an account is considered trusted, they are allowed to add and remove accounts by calling setIsTrusted() as they see fit.

However, if any single account has its private keys compromised or decides to become malicious on their own, they can remove all other trusted accounts from the isTrusted mapping. As a result, they are effectively able to take over the trusted group that controls all restricted functions in the parent contract.

Proof of Concept

abstract contract Trust {
    event UserTrustUpdated(address indexed user, bool trusted);

    mapping(address => bool) public isTrusted;

    constructor(address initialUser) {
        isTrusted[initialUser] = true;

        emit UserTrustUpdated(initialUser, true);
    }

    function setIsTrusted(address user, bool trusted) public virtual requiresTrust {
        isTrusted[user] = trusted;

        emit UserTrustUpdated(user, trusted);
    }

    modifier requiresTrust() {
        require(isTrusted[msg.sender], "UNTRUSTED");

        _;
    }
}

Recommended Mitigation Steps

Consider utilising Rari Capital’s updated Auth.sol contract found here. This updated contract gives the owner account authority over its underlying trusted accounts, preventing any single account from taking over the trusted group. The owner account should point to a multisig managed by the Sandclock team or by a community DAO.

naps62 (Sandclock) confirmed

dmvt (judge) changed severity and commented:

If this were to happen, funds would definitely be lost. Accordingly, this is a medium risk issue.

2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.

The original report as published on Code4rena, by leastwood. 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 setIsTrusted function allows any trusted account to modify the trusted list without any additional authorisation or restriction, so a single trusted account can remove all others.

Impact

If a trusted account is compromised or malicious, it can take over the trusted group and potentially cause loss of funds, though the report notes this is a medium risk because assets are not at direct risk without external requirements.

What the attacker needed

A trusted account is compromised or malicious

The fix

The fix is to use an updated Auth.sol contract that gives an owner account authority over trusted accounts, preventing any single account from taking over the trusted group.

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.

In this smart contract, a group of trusted accounts can call special functions. But each trusted account can also change who else is trusted. So if one trusted account turns bad, it can remove all the others and become the only one in control. That means it can then do anything the trusted group was allowed to do, like moving funds.

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 leastwood

View all

70 more disclosed reports, best first.

More from Sandclock 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.