Submitted by lsaudit, also found by klau5, twicek, tnquanghuy0512, 0xPsuedoPandit, xAriextz, 0xhacksmithh, Stormreckson, and ZanyBonzy
Function transferSAFEOwnership() is only callable by Only Vault721: require(msg.sender == address(vault721), 'SafeMngr: Only Vault721'); and its purpose is to give the safe ownership to a dst address.
However, transferSAFEOwnership() does not reset safeCan mapping which is used by safeAllowed modifier.
This leads to some security issues. The modifier safeAllowed is used to verify if user has permission to the safe. Multiple of functions which perform critical operations on the safe use this modifier to verify is user has permission to call that operation on a given safe.
Since transferSAFEOwnership() transfer ownership to a different address, it should also reset all previously set privileges by the previous owner. However, safeCan mapping is not being reset in transferSAFEOwnership()
Firstly, lets take a look how safeAllowed modifier is defined:
File: ODSafeManager.sol
For this PoC, lets consider user A, whos the owner of safe 123.
He gives access to the safe to X, Y, so he calls:
allowSAFE(123, X, 1), allowSAFE(123, Y, 1);
File: ODSafeManager.sol
After calling this function, safeCan mapping looks like this: safeCan[A][123][X] = 1 and safeCan[A][123][Y] = 1.
Now, theres a call to transfer safe ownership to _dst B: transferSAFEOwnership(123, B).
File: ODSafeManager.sol
It modifies only _usrSafes, _usrSafesPerCollat and  _safeData mappings and does not modify safeCan mapping.
After transferSAFEOwnership(123, B) call, those mappings look like this:
Now, at some point in the future, the safe goes back to user A. Function transferSAFEOwnership() is being called once again: transferSAFEOwnership(123, A).
User A get access to the safe. However, he does not remember that he previously sets access to users X and Y. Those mappings:
are still there - meaning that X and Y has still access to that safe, even though the safe was just transferred back to A and safes permissions should be cleared.
Now, when user X or Y will try to call any function with safeAllowed modifier - they will be allowed, since safeAllowed will return true for them, because X and Y are still in safeCan mapping.
Whenever transfer ownership - make sure to reset safeCan[old_owner][safe] mapping.
pi0neerpat (OpenDollar) confirmed and commented:
MiloTruck (Judge) commented:
For this audit, 25 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by MrPotatoMagic received the top score from the judge.
The following wardens also submitted reports: hals, phoenixV110, immeas, lsaudit, mrudenko, 0xMosh, Tendency, okolicodes, 0xhacksmithh, Baki, spark, twicek, m4k2, fibonacci, Al-Qa-qa, kutugu, Bughunter101, xAriextz, 0xPsuedoPandit, Stormreckson, T1MOH, 8olidity, Krace, and eeshenggoh.
