Skip to content
Access control Audit finding Intermediate

Approved address can approve other addresses for an owner’s safe

The allowSAFE function used a modifier that allowed any previously approved address to grant further approvals on the owner's safe. An approved address could therefore give another address permission to act on the safe, which the owner did not intend.

MrPotatoMagic Follow with hals, Tendency and 10 others

Originally disclosed on Code4rena

Submitted by MrPotatoMagic, also found by hals, Tendency, HChang26, merlin, COSMIC-BEE-REACH, twcctop, tnquanghuy0512, Bughunter101, josephdara, Stormreckson, T1MOH, and klau5

An owner of a safe can give permissions/approval of their safe to another address (let’s say address B) through the allowSafe() function in the ODSafeManager.sol contract. But this other address (address B) also gets the power to approve other addresses for the owner’s safe. This is a permissioning problem in the allowSafe() function (specifically the safeAllowed() modifier) which creates a security risk for the owner’s safe.

Proof of Concept

Here is the whole process:

https://github.com/open-dollar/od-contracts/blob/f4f0246bb26277249c1d5afe6201d4d9096e52e6/src/contracts/proxies/ODSafeManager.sol#L105C1-L109C4

  1. Owner of the safe gives permission/approval to address _usr (address 0x01 for example purposes) for uint256 _safe through the allowSafe() function.
  2. On Line 107, safeCan[_owner][_safe][_usr] = _ok; is set to any value other than 0 to represent approval.
File: ODSafeManager.sol
105:   function allowSAFE(uint256 _safe, address _usr, uint256 _ok) external safeAllowed(_safe) {
106:     address _owner = _safeData[_safe].owner;
107:     safeCan[_owner][_safe][_usr] = _ok;
108:     emit AllowSAFE(msg.sender, _safe, _usr, _ok);
109:   }
  1. The previously set address _usr (address 0x01) can now call the allowSafe() function with parameters uint256 _safe which will be the owner’s safe and another address _usr (address 0x02), which will give address 0x02 permissions/approval for the owner’s safe.
  2. This issue arises because of how the checks are evaluated in the safeAllowed() modifier. Here is what happens:
  3. On Line 50, the owner of the safe is extracted.
  4. On Line 51, there are two conditions present that are separated by the && operator.
  5. On Line 51, the first check evaluates to true, since the msg.sender (address 0x01) is not the owner of the safe
  6. On Line 51, the second check evaluates to false, since the msg.sender (address 0x01) was previously approved by the owner in step 1 above.
  7. Since true && false = false, we do not revert and this gives address 0x02 permissions to the owner’s safe in the allowSafe() function.
File: ODSafeManager.sol
49:   modifier safeAllowed(uint256 _safe) {
50:     address _owner = _safeData[_safe].owner;
51:     if (msg.sender != _owner && safeCan[_owner][_safe][msg.sender] == 0) revert SafeNotAllowed();
52:     _;
53:   }

Recommended Mitigation Steps

Consider implementing a separate modifier for the allowSafe() function that only checks if the msg.sender is the owner. If true, then allow execution but if not then revert.

Solution:

File: ODSafeManager.sol
modifier onlySafeOwner(uint256 _safe) {
    address _owner = _safeData[_safe].owner;
    if (msg.sender != _owner) revert SafeNotAllowed();
    _;
}

pi0neerpat (OpenDollar) confirmed, but disagreed with severity and commented:

Medium vulnerability recommended. Safe access is still limited, requiring user confirmation. The design could be improved, as described here, to remove the unexpected behavior of allowing additional approvals beyond the initial recipient.

MiloTruck (Judge) decreased severity to Medium and commented:

The warden has demonstrated how incorrect use of the safeAllowed() modifier on the allowSAFE() function allows permissioned addresses that are not the safe owner to give permissions to other addresses, which is not intended.

As this finding is contingent on the owner granting permissions to an address that becomes malicious, I believe medium severity is appropriate.


The original report as published on Code4rena, by MrPotatoMagic. 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 allowSAFE function reused the safeAllowed modifier, which accepts any caller already approved for the safe, instead of checking that the caller is the owner.

Impact

An approved address could grant safe permissions to others without the owner's consent, though the program noted that safe access still requires user confirmation.

What the attacker needed

Owner approves an address; approved address acts maliciously

The fix

The allowSAFE function should use a separate modifier that only allows the safe owner to call it.

How it was found

  1. The owner calls allowSAFE to approve address 0x01 for their safe.
  2. Address 0x01 calls allowSAFE for the same safe and names address 0x02.
  3. The safeAllowed modifier sees that 0x01 is not the owner but is already approved, so it does not revert.
  4. Address 0x02 is now approved for the owner's safe.

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 safe owner can let another person (address B) use their safe. The code also let address B pass that permission on to a third person (address C). The owner never agreed to that, so the access control was too loose.

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 MrPotatoMagic

View all

17 more disclosed reports, best first.

More from Open Dollar

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.