Executors/Proxies can game the rewards system by using a pubkey that will be sorted first
The rewards system sorts executor and proxy public keys in ascending order before allocating gas rewards, so an attacker can generate keys that sort first and always be prioritized for rewards even when providing the same value as others.
Source: https://github.com/sherlock-audit/2024-12-seda-protocol-judging/issues/257
Found by
g, zxriptor
Summary
The reveals and proxy pubkeys are sorted in ascending order every time data requests are filtered and tallied. The same ordering is used when metering gas for Proxies and Executors. Proxies and Executors that are sorted first will be prioritized for rewards distribution.
Root Cause
In FilterAndTally():185-197, the reveals are sorted in ascending order by their executor's key while the ProxyPubkeys of each reveal are also sorted in ascending order.
keys := make([]string, len(req.Reveals))
i := 0
for k := range req.Reveals {
keys[i] = k
i++
}
sort.Strings(keys)
reveals := make([]types.RevealBody, len(req.Reveals))
for i, k := range keys {
reveals[i] = req.Reveals[k]
sort.Strings(reveals[i].ProxyPubKeys)
}
When metering gas for proxies, the proxies are allocated gas in the same order until there is no remaining execution gas. Proxies with pubkeys that are ordered first will be prioritized.
The same behavior applies when metering gas for executors.
Internal Pre-conditions
None
External Pre-conditions
None
Attack Path
- A Proxy/Executor will generate and use public keys that will be ordered first when sorted.
- When gas rewards are allocated and distributed, they will always be prioritized over others.
Impact
The rewards system can be gamed so that certain Executors/Proxies will always be prioritized for rewards even when all participating proxies/executors provide the same value.
PoC
None
Mitigation
Consider randomizing the order of the executors' and proxies' public keys when allocating their rewards.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/sedaprotocol/seda-chain/pull/538
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 code sorts executor and proxy public keys in ascending order before allocating gas rewards, without randomisation, allowing participants to choose keys that sort first.
Impact
The rewards system can be gamed so that certain Executors/Proxies will always be prioritized for rewards even when all participating proxies/executors provide the same value.
What the attacker needed
Ability to generate public keys; participation as a Proxy or Executor
The fix
The protocol team fixed this issue by randomizing the order of the executors' and proxies' public keys when allocating their rewards.
How it was found
- A Proxy/Executor generates and uses public keys that will be ordered first when sorted.
- When gas rewards are allocated and distributed, they are always prioritized over others.
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 rewards system, participants are paid based on the order they are processed. If the system always processes them alphabetically by their public key, someone can create a key that starts with early letters to always get paid first. This lets them unfairly take rewards ahead of others who did the same work.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.