Skip to content
Access control Audit finding Intermediate

Collateral could be transferred to an address, which is not SAFEHandler managed by the SAFEManager

The transferCollateral function in ODSafeManager did not check that the destination address was a valid safe handler, allowing collateral to be transferred to any ordinary address. This broke the invariant that each safe has a corresponding SAFEHandler and could let users interact with SAFEEngine directly, bypassing ODSafeManager.

nmirchev8 Follow

Originally disclosed on Code4rena

Submitted by nmirchev8

In the current implementation each safe has corresponding proxy contract inside ODSafeManager and corresponding SAFEHandler “proxy” which is deployed for each safe and used as safe’s address inside SAFEEngine. The problem is that inside ODSafeManager transferCollateral() function there is no check wether the provided address is a valid safe and so the collateral could be “transferred” to any ordinary address.

Impact

This could result in contracts missbehaviour, or lost of funds as it breaks the invariant of “Each safe has a corresponding SAFEHandler” and so other accounting errors could appear as the new owner of the contract can transfer it where he wants directly calling SafeEngine.sol contract, which is also unwanted behaviour (To execute safe operations, bypassing SafeManager.sol)

Proof of Concept

  1. Alice has a safe with X amount of collateral and want to transfer it to Bob and passes his address.
  2. The transaction passes and now inside SAFEEngine Bob’s amount of collateral has increased, but if he want to do something with safe/s he has to have a proxy and a safe, for which he would be owner. So those “funds” which are for accounting don’t have corresponding vault and safe. They are assigned to an EOA

Recommended Mitigation Steps

The issue is confirmed by sponsor, who suggested adding in a safeHandler exists check.

pi0neerpat (OpenDollar) confirmed

MiloTruck (Judge) commented:

The warden has demonstrated how due to a lack of validation on the _dst parameter in transferCollateral() and transferInternalCoins(), the internal accounting of collateral and coins in the SAFEEngine contract can accrue to any arbitrary EOA, such as an attacker’s own address. This can be exploited to call functions in the SAFEEngine contract directly, which should not be possible.

Since this report does not demonstrate how this could lead to a potential loss of funds for the protocol/users, I believe medium severity is appropriate.

hals (Warden) commented:

Hi, I think this is intended by design to transfer SAFE collateral to any address that doesn’t represent a SAFE (safeHandler).

MiloTruck (Judge) commented:

@pi0neerpat, could you confirm if users should be able to call transferCollateral() and transferInternalCoins() in ODSafeManager to transfer their internal coin/collateral balance in SAFEEngine to any arbitrary address?

The internal coins/collateral will not be stuck in the protocol as users can call exit() in CollateralJoin or CoinJoin to mint system coins or transfer out collateral.

However, allowing internal balances to accrue to any arbitrary address means that users can call functions in the SAFEEngine contract directly, instead of through ODSafeManager. This was my original reason for medium severity, so it would be great if you could clarify if this should not be allowed.

nmirchev8 (Warden) commented:

In such way users can call functions on SAFEEngine contract directly, which breaks the invariants provided by the team.

daopunk (OpenDollar) commented:

I agree that user calls directly to the SafeEngine should not be allowed, thus a check that the destination address is an existing safeHandler should be made.

MiloTruck (Judge) commented:

Will maintain medium severity since this is unintended behavior, as mentioned by the sponsor, and seems to violate the following invariant from the Audit’s README:

Users must exclusively use the ODProxy to interact with their safes.


The original report as published on Code4rena, by nmirchev8. 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

Likely the transferCollateral function lacked validation that the destination address is an existing safe handler.

Impact

This could cause contract misbehaviour or loss of funds by breaking the invariant that each safe has a corresponding SAFEHandler, and it allows users to call SAFEEngine functions directly, bypassing ODSafeManager.

What the attacker needed

A safe with collateral; ability to call transferCollateral

The fix

The issue was fixed by adding a check that the destination address is an existing safeHandler.

How it was found

  1. Alice has a safe with collateral and wants to transfer it to Bob, passing Bob's address.
  2. The transaction succeeds and Bob's collateral balance in SAFEEngine increases, but Bob has no corresponding safe or handler.

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 is a vault for collateral, and each safe should have a dedicated handler contract that manages it. The transfer function allowed sending collateral to any address, not just a valid handler, so the accounting could become inconsistent and users could bypass the manager contract.

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 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.