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.
@> 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
- The
setWorkerPublicKeyfunction remains public and unchanged in the deployed contract. - Users rely on the
workerAddressesMplist orgetWorkerPublicKeyto select Workers for private deployments (via createProjectIDAndPrivateDeploymentRequest or createAgent). - The
createAgentWithTokenfunction is callable, requiring payment (via payWithERC20) for agent creation linked to a Worker.
External Pre-conditions
- The Base blockchain (per the README) allows any address to send transactions to the contract, which is standard behavior for public networks.
Attack Path
- A malicious actor calls
setWorkerPublicKeywith a fake public key, registering their address inworkersPublicKeyand adding it toworkerAddressesMp["worker_address_key"]. - A user queries
getWorkerAddressesorgetWorkerPublicKeyand selects the malicious actor’s address as the privateWorkerAddress for a deployment. - The user pays in ERC-20 tokens to create an agent, encrypting
base64Proposalwith the malicious Worker’s public key and triggering a deployment request. - 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
feeCollectionWalletAddressand 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:
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
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.