Skip to content
Access control Audit finding Intermediate

The worker and reputer's payload may be tampered due to lack of check for the pubkey's ownership

The InsertBulkWorkerPayload and InsertBulkReputerPayload functions verify that a data bundle is signed by the private key corresponding to a given public key, but they do not check that the public key actually belongs to the claimed worker or reputer. An attacker can therefore sign a tampered data bundle with their own key and submit it as if it came from an innocent participant, causing incorrect rewards or punishments.

lemonmon Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-06-allora-judging/issues/124

Found by

lemonmon

Summary

InsertBulkWorkerPayload and InsertBulkReputerPayload does not check the ownership of the pubkey. As the result, the data from worker or reputer may be tampered.

Vulnerability Detail

Each worker signs their data and the elected lead node will send the bundle to the allora chain via InsertBulkWorkerPayload.

And the signature is check in the worker_data_bundle.Validate: It checks whether the InferenceForecastsBundle is signed by the private key from the given Pubkey. However, it was not checked whether the Pubkey belongs from the inferer, who is presumably signed the bundle. Without this check, an adversary may tamper with the data bundle and claim that the data is from an innocent inferer. The data will then recorded as the data from the inferer.

https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/x/emissions/types/worker_data_bundle.go#L44-L56

The same issue exists in the msg_server_losses:InsertBulkReputerPayload. It is checked whether the ValueBundle was signed with the private for the Pubkey, but it was not checked that the key should belong to the reputer. Therefore, the value bundle may be tampered, but the data will recorded as the reputer's data.

https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/x/emissions/types/reputer_value_bundle.go#L60-L71

The proof of work below demonstrates that the signature and the pubkey do not belong to the inferer:

Go
// based on msg_server_worker_payload_test.go
func (s *MsgServerTestSuite) TestMsgInsertBulkWorkerPayloadPoC() {
	ctx, msgServer := s.ctx, s.msgServer
	require := s.Require()

	workerPrivateKey := secp256k1.GenPrivKey()
	adversary := secp256k1.GenPrivKey()
  require.NotEqual(adversary, workerPrivateKey)

	workerMsg, topicId := s.setUpMsgInsertBulkWorkerPayload(workerPrivateKey)

	workerMsg = s.signMsgInsertBulkWorkerPayload(workerMsg, adversary)

	blockHeight := workerMsg.WorkerDataBundles[0].InferenceForecastsBundle.Forecast.BlockHeight

	forecastsCount0 := s.getCountForecastsAtBlock(topicId, blockHeight)

	_, err := msgServer.InsertBulkWorkerPayload(ctx, &workerMsg)
	require.NoError(err, "InsertBulkWorkerPayload should not return an error")

	forecastsCount1 := s.getCountForecastsAtBlock(topicId, blockHeight)

	require.Equal(forecastsCount0, 0)
	require.Equal(forecastsCount1, 1)
}

Impact

The worker and reputer's data may be tampered and as the result, they may be punished or rewarded incorrectly.

Code Snippet

https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/x/emissions/types/worker_data_bundle.go#L44-L56 https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/x/emissions/types/reputer_value_bundle.go#L60-L71

Tool used

Manual Review

Recommendation

Consider adding the check for the ownership of the pubkey.

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/allora-network/allora-chain/pull/458

The original report as published on Sherlock, by lemonmon. 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 validation logic checks the signature against the provided public key but fails to verify that the public key is owned by the claimed worker or reputer.

Impact

The worker and reputer's data may be tampered with, leading to incorrect rewards or punishments.

What the attacker needed

Ability to submit a signed payload to the chain

The fix

The protocol team fixed this issue by adding a check for the ownership of the public key.

How it was found

  1. Generate a private key for an adversary and a separate private key for a legitimate worker.
  2. Create a worker payload message for the legitimate worker.
  3. Sign the message with the adversary's private key instead of the worker's key.
  4. Submit the signed message via InsertBulkWorkerPayload.
  5. Observe that the message is accepted and the forecast count increases, proving the signature and pubkey do not belong to the inferer.

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 a blockchain-based system, workers and reputers submit data signed with their private key. The system checks the signature against a public key, but it never checks that the public key really belongs to the person claiming to be the sender. So an attacker can use their own key to sign fake data and pretend it came from someone else.

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 lemonmon

View all

4 more disclosed reports, best first.

More from Allora

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.