createProject can be frontrun
The createProject function in a smart contract can be called by anyone, allowing a malicious user to front-run a legitimate project creation and become the owner of the collection. As owner, the attacker can withdraw the payment token.
Submitted by wuwe1, also found by defsec, and kirk-baird
This is dangerous in scam senario because the malicious user can frontrun and become the owner of the collection. As owner, one can withdraw paymentToken. (note that _collections.isForSale can be change by frontrunner)
Proof of Concept
- Anyone can call
createProject.
function createProject(
string memory _projectId,
Collection[] memory _collections
) external onlyAvailableProject(_projectId) {
require(
_collections.length > 0,
'CoreFactory: should have more at least one collection'
);
Recommended Mitigation Steps
Two ways to mitigate.
- Consider use white list on project creation.
- Ask user to sign their address and check the signature against
msg.sender. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol#L102
sofianeOuafir (Joyn) confirmed and commented:
This is an issue and we intend to fix it!
deluca-mike (judge) commented:
The solutions listed in #34 and #35 are better.
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 createProject function lacks access control, allowing any address to call it and become the owner of a project ID before the legitimate creator.
Impact
A malicious user could front-run project creation to become the owner and withdraw the payment token, potentially stealing funds.
What the attacker needed
Attacker can submit transactions; attacker can pay higher gas
How it was found
- Observe a pending createProject transaction from a legitimate user.
- Submit a createProject transaction with the same project ID but with attacker-controlled parameters and a higher gas price to front-run.
- The attacker's transaction is mined first, making the attacker the owner of the collection.
- As owner, the attacker can withdraw the paymentToken.
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.
In blockchain, transactions wait in a public pool before being processed. An attacker can see a pending transaction and pay a higher fee to get their own transaction processed first. Here, an attacker sees a legitimate project creation and quickly creates the same project first, becoming the owner and gaining control of funds.
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.