The witch.sol contract gets access to a vault via the grab function in case of liquidation. If the witch.sol contract cant sell the debt within a certain amount of time, a second grab can occur.
After the second grab, the information of the original owner of the vault is lost, and the vault cant be returned to the original owner once the debt has been sold.
The grab function stores the previous owner in vaultOwners[vaultId], and then the contract itself is the new owner (via cauldron.grab and cauldron._give).
The vaultOwners[vaultId] is overwritten at the second grab
The function buy of Witch.sol tried to give the vault back to the original owner, which wont succeed after a second grab. See the issue page for proof of concept and referenced code
Assuming its useful to give back the vault to the original owner,  recommend making a stack/array of previous owners if multiple instances of the witch.sol contract would be used. Or, check if the witch is already the owner (in the grab function) and keep thevaultOwners[vaultId] if that is the case.
albertocuestacanada (Yield) confirmed:
albertocuestacanada (Yield) commented:
Editors note: An alternative submission for this bug was not included in this report but can be found in Issue #30.
