Skip to content
Smart contracts Audit finding Intermediate

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.

Solidity
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

  1. The updateWorkerDeploymentConfigWithSig function remains public and unchanged in the deployed contract.
  2. A user (deployment owner) has approved the BlueprintCore.sol contract to spend their ERC-20 tokens via approve on the token contract.
  3. The user has signed a valid message (with projectId, updatedBase64Config, "app.crestal.network") and submitted it to update a deployment configuration for a requestID with status not equal to Init or Issued.
  4. The paymentOpCostMp[tokenAddress][UPDATE_AGENT_OP] returns a non-zero cost.

External Pre-conditions

  1. The Base blockchain allows transaction replay if the signature remains valid, which is standard behavior unless mitigated.
  2. The ERC-20 token contract at tokenAddress supports safeTransferFrom and doesn’t prevent replay.

Attack Path

  1. A user (deployment owner) signs a message to update a deployment configuration (projectId, requestID, updatedBase64Config) and submits it via updateWorkerDeploymentConfigWithSig, paying $token to feeCollectionWalletAddress via payWithERC20.
  2. The transaction succeeds, updating the configuration and emitting UpdateDeploymentConfig, with the signature recorded on-chain.
  3. A malicious actor captures the signature and replays the transaction by calling updateWorkerDeploymentConfigWithSig with the same parameters (tokenAddress, projectId, requestID, updatedBase64Config, signature).
  4. Each replay re-executes updateWorkerDeploymentConfigCommon, transferring another $token from the user to feeCollectionWalletAddress (if funds/allowance remain) and resetting status to Pickup if it was GeneratedProof, 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:

Solidity
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

The original report as published on Sherlock, by 0x73696d616f. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

  1. A user signs a message to update a deployment configuration and submits it via updateWorkerDeploymentConfigWithSig, paying tokens to the fee collection wallet.
  2. The transaction succeeds, updating the configuration and emitting UpdateDeploymentConfig, with the signature recorded on-chain.
  3. A malicious actor captures the signature and replays the transaction by calling updateWorkerDeploymentConfigWithSig with the same parameters.
  4. 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.

More by 0x73696d616f

View all

172 more disclosed reports, best first.

More from Crestal Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.