Skip to content
Access control Audit finding Intermediate

Anyone can overwrite Reputer and Worker info attached to a LibP2PKey

The allora-chain registration process does not verify that the caller owns the LibP2PKey, allowing anyone to overwrite the reputer or worker information associated with any key. This can poison the allora-inference-base and disrupt the Allora network.

carrotsmuggler Follow with imsrybr0, lemonmon and 2 others

Originally disclosed on Sherlock

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

Found by

carrotsmuggler, imsrybr0, lemonmon, volodya, zigtur

Summary

The allora-chain does not verify that the caller owns the LibP2PKey. This allows anyone to modify the reputers and/or workers informations for a given key.

Vulnerability Detail

The Register message allows to register as a reputer or as a worker or as both (require 2 calls).

When a reputer is registered, an entry is added into k.reputers to map a LibP2PKey to reputer infos.

However, there are no checks to ensure that the provided LibP2PKey is owned by the caller. Moreover, if an existing entry exist for this LibP2PKey, it is overwritten.

The same applies to the worker

Impact

Anyone can overwrite the Owner attached to a LibP2PKey for reputers and workers.

This is highly problematic because these data are retrieved in the allora-inference-base codebase.

Code Snippet

Note: The reputer is used as example here, the same applies to the worker functionality.

Issue

The Register entrypoint takes the entry parameters and calls InsertReputer.

See msg_server_registrations.go#L41-L53.

Go
// Registers a new network participant to the network for the first time for worker or reputer
func (ms msgServer) Register(ctx context.Context, msg *types.MsgRegister) (*types.MsgRegisterResponse, error) {
	// ...

	nodeInfo := types.OffchainNode{
		NodeAddress:  msg.Sender,
		LibP2PKey:    msg.LibP2PKey,
		MultiAddress: msg.MultiAddress,
		Owner:        msg.Owner,
		NodeId:       msg.Owner + "|" + msg.LibP2PKey,
	}

	if msg.IsReputer {
		err = ms.k.InsertReputer(ctx, msg.TopicId, msg.Sender, nodeInfo) // @POC: Register node info
		if err != nil {
			return nil, err
		}
	} else {
		//...
	}
}

InsertReputer will not check if an existing entry exist for the given LibP2PKey and will overwrite it via Set. It will write to k.reputers.

See keeper.go#L124-L125 and keeper.go#L1432-L1443.

Go
type Keeper {
	// ...

	// map of reputer id to node data about that reputer
	reputers collections.Map[LibP2pKey, types.OffchainNode] // @POC: Map a `LibP2pKey` to node info
}

// Adds a new reputer to the reputer tracking data structures, reputers and topicReputers
func (k *Keeper) InsertReputer(ctx context.Context, topicId TopicId, reputer ActorId, reputerInfo types.OffchainNode) error {
	topicKey := collections.Join(topicId, reputer)
	err := k.topicReputers.Set(ctx, topicKey)
	if err != nil {
		return err
	}
	err = k.reputers.Set(ctx, reputerInfo.LibP2PKey, reputerInfo) // @POC: adds OR MODIFY an entry in `k.reputers`
	if err != nil {
		return err
	}
	return nil
}

Impact

allora-chain provides a query entrypoint to retrieve the reputer informations by providing the LibP2PKey. This entrypoint is GetReputerAddressByP2PKey. (See query_server_registrations.go#L37-L44 and keeper.go#L1503-L1504).

Go
// query_server_registrations.go#L37-L44
func (qs queryServer) GetReputerAddressByP2PKey(ctx context.Context, req *types.QueryReputerAddressByP2PKeyRequest) (*types.QueryReputerAddressByP2PKeyResponse, error) {
	address, err := qs.k.GetReputerAddressByP2PKey(sdk.UnwrapSDKContext(ctx), req.Libp2PKey)
	if err != nil {
		return nil, err
	}

	return &types.QueryReputerAddressByP2PKeyResponse{Address: address.String()}, nil
}

// keeper.go#L1503-L1504
func (k *Keeper) GetReputerAddressByP2PKey(ctx context.Context, p2pKey string) (sdk.AccAddress, error) {
	reputer, err := k.reputers.Get(ctx, p2pKey) // @POC: retrieves the entry that anyone can overwrite
	// ...
}

The allora-inference-base codebase retrieves reputer informations by calling GetReputerAddressByP2PKey on allora-chain. (See appchain.go#L545-L548)

Go
// Sending Losses to the AppChain
func (ap *AppChain) SendReputerModeData(ctx context.Context, topicId uint64, results aggregate.Results) {
	// ...

			// Get Peer $allo address
			res, err := ap.EmissionsQueryClient.GetReputerAddressByP2PKey(ctx, &emissionstypes.QueryReputerAddressByP2PKeyRequest{ // @POC: retrieves data from allora-chain
				Libp2PKey: peer.String(),
			})
	
	// ...

To summarize, an attacker can modify infos attached to any LibP2PKey to poison the allora-inference-base and break the Allora network.

Worker snippets

The given code snippets affect the reputer registration. However, the worker registration shows similar issue.

Here are the snippet links for the worker registration:

Then allora-inference-base retrieves info for workers:

Tool used

Manual Review

Recommendation

Allora-chain should verify that the provided key is owned by the caller.

The most efficient way to handle this issue seems to require the signature of the Msg.Owner address by the LibP2PKey. This solution will fix the issue for reputers and workers.

Discussion

sherlock-admin2

1 comment(s) were left on this issue during the judging contest.

0xmystery commented:

Reputer and workers info can be overwritten via LibP2PKey

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 carrotsmuggler. 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 registration function does not check that the caller owns the provided LibP2PKey before storing or overwriting the associated node information.

Impact

An attacker could overwrite the Owner attached to any LibP2PKey for reputers and workers, potentially poisoning the allora-inference-base and breaking the Allora network.

What the attacker needed

None

The fix

The protocol team fixed this issue by requiring the signature of the Msg.Owner address by the LibP2PKey.

How it was found

  1. Call the Register message with IsReputer set to true and a chosen LibP2PKey.
  2. The system inserts the reputer information into the map without verifying ownership.
  3. The existing entry for that LibP2PKey is overwritten with the attacker's data.

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 LibP2PKey is a public identifier used in a peer-to-peer network. The system lets anyone register a key without proving they own it, so an attacker can replace the details linked to someone else's key. This can break the network because other parts trust those details.

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 carrotsmuggler

View all

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