Transferring Ownership Might Break The Market
The market contract checks that the current owner is whitelisted for callbacks when a purchase is made, but transferring ownership does not verify the new owner is whitelisted. If a market uses a callback and ownership is transferred to a non-whitelisted address, all purchases revert, stopping the market.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-11-bond-judging/issues/41
Found by
xiaoming90
Summary
After the transfer of the market ownership, the market might stop working, and no one could purchase any bond token from the market leading to a loss of sale for the market makers.
Vulnerability Detail
The callbackAuthorized mapping contains a list of whitelisted market owners authorized to use the callback. When the users call the purchaseBond function, it will check at Line 390 if the current market owner is still authorized to use a callback. Otherwise, the function will revert.
https://github.com/sherlock-audit/2022-11-bond/blob/main/src/bases/BondBaseSDA.sol#L379
File: BondBaseSDA.sol
379: function purchaseBond(
380: uint256 id_,
381: uint256 amount_,
382: uint256 minAmountOut_
383: ) external override returns (uint256 payout) {
384: if (msg.sender != address(_teller)) revert Auctioneer_NotAuthorized();
385:
386: BondMarket storage market = markets[id_];
387: BondTerms memory term = terms[id_];
388:
389: // If market uses a callback, check that owner is still callback authorized
390: if (market.callbackAddr != address(0) && !callbackAuthorized[market.owner])
391: revert Auctioneer_NotAuthorized();
However, if the market owner transfers the market ownership to someone else. The market will stop working because the new market owner might not be on the list of whitelisted market owners (callbackAuthorized mapping). As such, no one can purchase any bond token.
https://github.com/sherlock-audit/2022-11-bond/blob/main/src/bases/BondBaseSDA.sol#L336
File: BondBaseSDA.sol
336: function pushOwnership(uint256 id_, address newOwner_) external override {
337: if (msg.sender != markets[id_].owner) revert Auctioneer_OnlyMarketOwner();
338: newOwners[id_] = newOwner_;
339: }
Impact
After the transfer of the market ownership, the market might stop working, and no one could purchase any bond token from the market leading to a loss of sale for the market makers.
Code Snippet
https://github.com/sherlock-audit/2022-11-bond/blob/main/src/bases/BondBaseSDA.sol#L379
https://github.com/sherlock-audit/2022-11-bond/blob/main/src/bases/BondBaseSDA.sol#L336
Tool used
Manual Review
Recommendation
Before pushing the ownership, if the market uses a callback, implement an additional validation check to ensure that the new market owner has been whitelisted to use the callback. This will ensure that transferring the market ownership will not break the market due to the new market owner not being whitelisted.
function pushOwnership(uint256 id_, address newOwner_) external override {
if (msg.sender != markets[id_].owner) revert Auctioneer_OnlyMarketOwner();
+ if (markets[id_].callbackAddr != address(0) && !callbackAuthorized[newOwner_])
+ revert newOwnerNotAuthorizedToUseCallback();
newOwners[id_] = newOwner_;
}
Discussion
Evert0x
Message from sponsor
Acknowledged. We added the check for the owner to be whitelisted for a callback on purchase to provide a shutdown mechanism in the event of a malicious callback. The ownership transfer functionality is meant to be used when a callback isn't being used to payout market purchases. E.g. create a market with an EOA from a script and transfer ownership to a multisig for payouts (would also require multisig to approve the teller for the capacity in payout tokens).
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 ownership transfer function does not validate that the new owner is authorised to use the callback when the market has a callback address set.
Impact
After ownership transfer, the market may stop working and no one could purchase bond tokens, leading to lost sales for market makers.
What the attacker needed
Market uses a callback; owner transfers ownership to non-whitelisted address
The fix
The ownership transfer function should check that the new owner is whitelisted for callbacks if the market uses a callback, and the sponsor acknowledged the issue but stated the check on purchase is intentional as a shutdown mechanism.
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 smart contract market lets people buy bonds. It also has a safety check: only certain approved owners can use a special callback feature. When the owner changes, the contract does not check if the new owner is approved. So if the new owner is not on the approved list, the market stops working and nobody can buy bonds.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.