The `PreMarkets` contract contains several critical functions (`updateOfferStatus`, `updateStockStatus`) that lack proper access control mechanisms. This vulnerability allows any user to call these functions and alter the state of offers and stocks, leading to potential financial loss and disruption of the marketplace.
Scenario 1: Changing Offer Status
An attacker can change the status of an offer without legitimate permission, causing financial loss or operational disruption.
-1. Attacker Finds a Function Without Access Control:
The attacker finds that the updateOfferStatus function lacks adequate access control.
-2. Attacker Calls the Function:
The attacker calls the updateOfferStatus function with parameters that benefit them, for example:
-3. Consequences:
Legitimate offers can be settled without the owner's consent.
The attacker can claim funds they shouldn't have.
The integrity of the market is compromised, and other users lose trust.
Scenario 2: Invalidating an Offer
An attacker can cancel a legitimate offer, causing loss to the offer owner.
-1. Attacker Finds a Function Without Access Control:
The attacker finds that the updateOfferStatus function lacks adequate access control.
-2. Attacker Calls Function:
Attacker calls updateOfferStatus function to cancel the offer:
-3. Consequences:
Valid offer is canceled without owner's consent.
Offer owner loses the opportunity to complete the transaction.
Attacker can disrupt market operations and cause financial losses to other users.
Scenario 3: Changing Stock Status
Attacker can change stock status without legitimate permission, causing uncertainty and losses in the market.
-1. Attacker Finds Function Without Access Control:
Attacker finds that updateStockStatus function does not have adequate access control.
-2. Attacker Calls Function:
Attacker calls updateStockStatus function to change stock status:
-3. Consequences:
Legitimate stock is marked as completed without owner's consent.
Attackers can cause uncertainty in the market and damage user trust.
Cancel legitimate offers without the owner's consent.
Update the status of offers and stocks, potentially settling or finishing them prematurely.
Disrupt the normal operation of the marketplace, causing financial losses to users and damaging the integrity of the platform.
Manual review
Use OpenZeppelin's Ownable or AccessControl to restrict access to critical functions.
If more granular control is needed, implement custom access control modifiers to restrict access based on specific roles or conditions.
forge test --match-path test/ExploitTest.t.sol
[⠊] Compiling...
[⠃] Compiling 2 files with Solc 0.8.26
[⠊] Solc 0.8.26 finished in 2.76s
Compiler run successful!
Ran 3 tests for test/ExploitTest.t.sol:ExploitTest
[PASS] testExploitCancelOffer() (gas: 45198)
[PASS] testExploitUpdateOfferStatus() (gas: 45231)
[PASS] testExploitUpdateStockStatus() (gas: 36291)
Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 141.40ms (50.02ms CPU time)
Ran 1 test suite in 160.57ms (141.40ms CPU time): 3 tests passed, 0 failed, 0 skipped (3 total tests)
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.