Skip to content
Access control Audit finding Intermediate

Lack of access control in `setWorkerPublicKey()` in BlueprintCore.sol which results users to lose funds

j3x Follow with sabanaku77

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-03-crestal-network-judging/issues/467

Found by

j3x, sabanaku77

Summary

The lack of access control in the setWorkerPublicKey function will cause a significant loss of funds for users as a malicious actor will register a fake Worker public key to intercept and disrupt deployment payments.

Root Cause

In BlueprintCore.sol at the setWorkerPublicKey function, the function is declared as public without any restrictions, allowing any address to register or update a public key in the workersPublicKey mapping and add themselves to the workerAddressesMp list.

Solidity
@> function setWorkerPublicKey(bytes calldata publicKey) public {
    if (workersPublicKey[msg.sender].length == 0) {
        workerAddressesMp[WORKER_ADDRESS_KEY].push(msg.sender);
    }
    workersPublicKey[msg.sender] = publicKey;
}

Internal Pre-conditions

  1. The setWorkerPublicKey function remains public and unchanged in the deployed contract.
  2. Users rely on the workerAddressesMp list or getWorkerPublicKey to select Workers for private deployments (via createProjectIDAndPrivateDeploymentRequest or createAgent).
  3. The createAgentWithToken function is callable, requiring payment (via payWithERC20) for agent creation linked to a Worker.

External Pre-conditions

  1. The Base blockchain (per the README) allows any address to send transactions to the contract, which is standard behavior for public networks.

Attack Path

  1. A malicious actor calls setWorkerPublicKey with a fake public key, registering their address in workersPublicKey and adding it to workerAddressesMp["worker_address_key"].
  2. A user queries getWorkerAddresses or getWorkerPublicKey and selects the malicious actor’s address as the privateWorkerAddress for a deployment.
  3. The user pays in ERC-20 tokens to create an agent, encrypting base64Proposal with the malicious Worker’s public key and triggering a deployment request.
  4. The malicious actor receives the deployment request (status set to Pickup) but does not deploy the agent, either keeping the encrypted data or ignoring the request, causing the deployment to fail.

Impact

  • The user suffers the loss of there ERC-20 tokens. The attacker gains no direct funds but may extract value from the encrypted base64Proposal (sensitive data), incurring only gas costs.
  • Also, the transfered token will go to feeCollectionWalletAddress and protocol didn't have a 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

  • Whitelist Approach: Add a modifier to limit calls to registered Workers, managed by the owner:
Solidity
mapping(address => bool) public registeredWorkers;
modifier onlyRegisteredWorker() {
    require(registeredWorkers[msg.sender], "Not a registered Worker");
    _;
}
function setWorkerPublicKey(bytes calldata publicKey) public onlyRegisteredWorker {
    if (workersPublicKey[msg.sender].length == 0) {
        workerAddressesMp[WORKER_ADDRESS_KEY].push(msg.sender);
    }
    workersPublicKey[msg.sender] = publicKey;
}
function registerWorker(address worker) public onlyOwner {
    registeredWorkers[worker] = true;
}

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/crestalnetwork/crestal-omni-contracts/pull/29

The original report as published on Sherlock, by j3x. 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.

What is known

A medium-severity access control bug in Crestal Network. Sherlock made it public on 26 March 2025. Found in the 755 audit contest (finding M-4), also found by 1 other warden.

About Access control

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by j3x

View all

3 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.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.