Signature Replay attack possible on `updateWorkerDeploymentConfigWithSig()` in Blueprintcore.sol which leads to users lose the funds
The updateWorkerDeploymentConfigWithSig function lacks replay protection because the signed message does not include a nonce, timestamp, or chain ID. An attacker can replay a valid signature to repeatedly trigger payments from the user to the fee collection wallet, draining the user's approved funds.
0x73696d616f Follow with 0xYjs, AuditKiller and 14 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-03-crestal-network-judging/issues/391
Found by
0x73696d616f, 0xYjs, AuditKiller, Cybrid, IzuMan, calc1f4r, d33p, gegul, j3x, moray5554, patitonar, ph, pushkarm029, sabanaku77, seeques, shady4, zxriptor
Summary
The lack of replay protection in the updateWorkerDeploymentConfigWithSig function will cause a significant loss of funds for users as a malicious actor will replay a signed transaction to repeatedly transfer funds from the deployment owner to the fee collection wallet. The protocol didn't have the functionality to refund these funds to the respective users if this issue occurs. So anyway user is gonna lose their fund.
Root Cause
In BlueprintCore.sol at the updateWorkerDeploymentConfigWithSig function, the function verifies a signature using getRequestDeploymentDigest but does not include a nonce, timestamp, or chain ID in the signed message. This allows a valid signature to be reused indefinitely, triggering multiple calls to updateWorkerDeploymentConfigCommon and its payWithERC20 payment logic.
function updateWorkerDeploymentConfigWithSig(
address tokenAddress,
bytes32 projectId,
bytes32 requestID,
string memory updatedBase64Config,
bytes memory signature
) public {
bytes32 digest = getRequestDeploymentDigest(projectId, updatedBase64Config, "app.crestal.network");
address signerAddr = getSignerAddress(digest, signature);
updateWorkerDeploymentConfigCommon(tokenAddress, signerAddr, projectId, requestID, updatedBase64Config);
}
Internal Pre-conditions
- The
updateWorkerDeploymentConfigWithSigfunction remains public and unchanged in the deployed contract. - A user (deployment owner) has approved the
BlueprintCore.solcontract to spend their ERC-20 tokens viaapproveon the token contract. - The user has signed a valid message (with
projectId,updatedBase64Config, "app.crestal.network") and submitted it to update a deployment configuration for arequestIDwithstatusnot equal toInitorIssued. - The
paymentOpCostMp[tokenAddress][UPDATE_AGENT_OP]returns a non-zerocost.
External Pre-conditions
- The Base blockchain allows transaction replay if the signature remains valid, which is standard behavior unless mitigated.
- The ERC-20 token contract at
tokenAddresssupportssafeTransferFromand doesn’t prevent replay.
Attack Path
- A user (deployment owner) signs a message to update a deployment configuration (projectId, requestID, updatedBase64Config) and submits it via
updateWorkerDeploymentConfigWithSig, paying $token tofeeCollectionWalletAddressviapayWithERC20. - The transaction succeeds, updating the configuration and emitting
UpdateDeploymentConfig, with the signature recorded on-chain. - A malicious actor captures the signature and replays the transaction by calling
updateWorkerDeploymentConfigWithSigwith the same parameters (tokenAddress, projectId, requestID, updatedBase64Config, signature). - Each replay re-executes
updateWorkerDeploymentConfigCommon, transferring another $token from the user tofeeCollectionWalletAddress(if funds/allowance remain) and resetting status toPickupif it wasGeneratedProof, repeatable until the user’s funds are drained or allowance is revoked.
Impact
The user suffers an approximate loss of $token per replay. If replayed indefinitely (e.g., 20 times), the loss could reach 20x more, potentially draining 100% of approved funds. The attacker gains no direct funds but indirectly benefits feeCollectionWalletAddress, incurring only gas costs per replay.
The protocol didn't have the functionality to refund this token to the respective users if this issue occurs. So anyway user is gonna lose their fund.
PoC
No response
Mitigation
Add a nonce to the signed message and track it per user:
mapping(address => uint256) public userNonces;
function updateWorkerDeploymentConfigWithSig(
address tokenAddress,
bytes32 projectId,
bytes32 requestID,
string memory updatedBase64Config,
bytes memory signature
) public {
bytes32 digest = keccak256(abi.encode(
keccak256("UpdateDeploymentConfig(bytes32 projectId,string updatedBase64Config,string domain,uint256 nonce)"),
projectId,
keccak256(bytes(updatedBase64Config)),
keccak256(bytes("app.crestal.network")),
userNonces[msg.sender]
));
address signerAddr = getSignerAddress(digest, signature);
updateWorkerDeploymentConfigCommon(tokenAddress, signerAddr, projectId, requestID, updatedBase64Config);
userNonces[signerAddr]++;
}
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/crestalnetwork/crestal-omni-contracts/pull/17
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 signed message does not include a nonce, timestamp, or chain ID, so a valid signature can be reused indefinitely.
Impact
The user could lose an amount of tokens per replay, potentially draining 100% of approved funds, and the protocol has no refund mechanism.
What the attacker needed
User approved token spending; user signed a valid message; attacker can capture the signature
The fix
The protocol team fixed this issue by adding a nonce to the signed message and tracking it per user.
How it was found
- A user signs a message to update a deployment configuration and submits it via updateWorkerDeploymentConfigWithSig, paying tokens to the fee collection wallet.
- The transaction succeeds, updating the configuration and emitting UpdateDeploymentConfig, with the signature recorded on-chain.
- A malicious actor captures the signature and replays the transaction by calling updateWorkerDeploymentConfigWithSig with the same parameters.
- Each replay re-executes updateWorkerDeploymentConfigCommon, transferring another token amount from the user to the fee collection wallet, repeatable until funds are drained or allowance is revoked.
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 signature is like a digital autograph that proves you approved something. Here, the contract checks the autograph but doesn't note that it has already been used, so anyone can copy it and submit it again and again. Each time, the contract charges you a fee, so your money can be drained.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.