The function updateValset does not have enough sanity checks
The updateValset function lets the current validator set install a new set without checking that the new set's combined voting power exceeds the power threshold, and without limiting how many validators the new set may contain. An attacker or careless operator could therefore push the bridge into a state where no proposal can ever reach the threshold, or where validating a proposal costs more gas than a block allows, effectively freezing the contract.
Submitted by hrkrshnn, also found by pauliax and shw
In the updateValset function, the current set of validators adds a new set.
It is missing the check that the combined power of all new validators is above the state_powerThreshold. If this is false, then the contract is effectively stuck. Consider adding an on-chain check for this.
It is also worth adding a that the size of the new validator check is less than a certain number.
Here is a rough calculation explaining how 10000 validators (an extreme example) is too much:
- Let us say that the new set of validators have the property that at least, say,
Nvalidators are needed to get the total threshold abovestate_powerThreshold. - Since each validating signature requires a call to
ecrecover, costing at least3000gas, the minimum gas needed for getting a proposal overstate_powerThresholdwould beN * 3000 N * 3000cannot be more than theblock.gaslimitCurrently, this putsNto be less than10000
Another approach to solve the above potential problems is to do the updating as a two step process:
- The current set of validators proposes a pending set of validators.
- And the pending set of validators need to do the transition to become the new set of validators. Going through the same threshold checks.
This guarantees that the new set of validators has enough power to pass threshold and doesn’t have gas limit issues in doing so.
Semi duplicate of #63, #37 which describes the power sum issue
Also a semi duplicate of #9 which describes the block size issue
these are both valid and should be assigned congruent severity with the duplicates.
Context
Gravity Bridge is a Cosmos-based bridge, and the finding concerns the Solidity side of it: the Gravity.sol contract that holds the validator set and the power accounting used to authorise state transitions. The relevant function is updateValset, which is how the current set of validators installs a new set of validators. The report links to the function at a specific commit of the cosmos-gravity-bridge repository.
The feature exists because the bridge's security model is stake-weighted: a proposal passes when the combined power of the validators who signed it exceeds state_powerThreshold. updateValset is the entry point that replaces the signing set, so whatever it accepts becomes the set whose signatures will be counted from then on.
Setup
The report describes no accounts, roles, tooling or deployed environment. It is a code review of the linked updateValset implementation, and the reasoning is about gas costs and threshold arithmetic rather than about a live request and response. The only concrete precondition is the one the contract itself imposes: a new validator set is submitted by the current set of validators, and the contract tracks a state_powerThreshold against which validator power is compared.
Finding it
The researcher looked at updateValset and noticed that it is missing a check that the combined power of all new validators is above state_powerThreshold. In other words, the function accepts a new set without verifying that the set is capable of ever meeting the threshold that governs proposals.
That omission matters because of what happens afterwards. If the new set's total power is at or below state_powerThreshold, no proposal signed by that set can ever cross the threshold, and the contract is effectively stuck. The report states this directly: if the condition is false, the contract is effectively stuck.
A second, related concern is the size of the new validator set. The report recommends adding a check that the size of the new validator set is less than a certain number, and then gives a rough calculation for why an extreme size such as 10000 validators is too much.
Exploitation
The report does not present an exploitation sequence, requests or responses. What it presents is the arithmetic that makes the missing checks dangerous. The reasoning runs as follows:
- Assume the new set of validators has the property that at least
Nvalidators are needed to get the total threshold abovestate_powerThreshold. - Each validating signature requires a call to
ecrecover, costing at least3000gas, so the minimum gas needed to get a proposal overstate_powerThresholdisN * 3000. N * 3000cannot be more thanblock.gaslimit. At the time of writing this putsNat less than10000.
The report's rough calculation suggests that a set needing more than the block gas limit's worth of ecrecover calls would be unable to get a proposal over the threshold. The 10000 figure is explicitly described as an extreme example, and the calculation is described as rough.
Root cause
updateValset performs the replacement of the validator set without sanity checks on the incoming set. Two properties of the new set are unchecked:
- Its combined power relative to
state_powerThreshold. A set whose total power does not exceed the threshold can never authorise anything, so accepting it leaves the contract effectively stuck. - Its size. Because each signature costs at least
3000gas throughecrecover, a set large enough that the number of signatures needed to pass the threshold exceeds what fits in a block cannot pass a proposal either.
Impact
The impact is that the contract is effectively stuck.: a validator set that cannot meet state_powerThreshold, or that is too large to gather enough signatures within the block gas limit, leaves the contract effectively stuck. The report frames both as potential problems to be solved, and the maintainer treats them as valid and asks for severity congruent with the duplicates.
Fix
The report proposes two things. First, add an on-chain check in updateValset that the combined power of all new validators is above state_powerThreshold. Second, add a check that the size of the new validator set is below a certain number.
As an alternative, it suggests making the update a two-step process:
- The current set of validators proposes a pending set of validators.
- The pending set of validators must then perform the transition to become the new set, going through the same threshold checks.
That design guarantees that the new set has enough power to pass the threshold and does not have gas limit issues in doing so.
In the maintainer's confirmation, jkilpatr (Althea) notes that the report is a semi duplicate of #63 and #37, which describe the power sum issue, and also a semi duplicate of #9, which describes the block size issue, and states that these are both valid and should be assigned congruent severity with the duplicates.
Variants to test
- Look for set-replacement functions in staking, bridge and multisig contracts that accept a new signer or validator list without comparing its total weight to the threshold used for proposals. A positive result is a set that can be installed but whose maximum achievable signature weight never exceeds the threshold.
- Check whether the number of signers required to pass the threshold, multiplied by the per-signature verification cost, can exceed the block gas limit. A positive result is a set that is accepted on chain but for which no valid proposal transaction can be mined.
- Review two-step or pending-set designs for the same gap: if the pending set is only checked for format and not for threshold capability, the guarantee the design is supposed to provide is absent.
Hunting notes
This class of bug hides in administrative functions that replace trust anchors: validator set updates, owner and signer rotation, oracle set changes and committee updates. The signal during review is a function that writes a new set and validates only superficial properties such as ordering, uniqueness or non-emptiness, while the security-critical property, the set's ability to meet the signing threshold, is checked elsewhere or not at all. Gas-based limits are easy to miss because they depend on the per-signature verification cost and the block gas limit rather than on any explicit constant in the contract.
The report establishes impact by reasoning from the contract's own threshold semantics to the stuck state, and by quantifying the gas ceiling with a rough calculation. The maintainer treats it as a semi duplicate of the related reports on the power sum and block size issues and asks for congruent severity.
What happened, in plain words
Gravity Bridge is a piece of software that lets digital assets move between two different blockchain networks. One side of it is a smart contract written in a language called Solidity, which runs on a blockchain. That contract, Gravity.sol, keeps track of who is allowed to approve things: a list of validators. A validator is a participant whose approval counts towards a decision. Each validator carries a certain amount of voting power, and a proposal is accepted only when the combined power of the validators who signed it is greater than a fixed number called state_powerThreshold.
The function updateValset is the piece of code that swaps the current list of validators for a new one. The researcher who looked at it found that this swap happens without checking two important things about the incoming list: whether its total power is actually above the threshold, and whether the list is small enough that enough signatures can fit into a single block of transactions. If either check is missing, a new list can be installed and the contract can end up effectively stuck. The report calls this being "effectively stuck".
This is a code review finding, not a live attack. There are no requests, no responses and no victim. The reasoning is about arithmetic: voting power compared to a threshold, and the cost of checking signatures compared to the space available in a block.
Background you need first
A few ideas come up again and again, so here they are from zero.
Blockchain and smart contract. A blockchain is a shared record book that many computers keep copies of. A smart contract is a small program stored on that record book; anyone can call it, and its rules run exactly as written. Gravity.sol is such a program.
Solidity. The programming language smart contracts on this network are written in. The report links to one function inside a Solidity file.
Validator. A participant whose approval is counted when the contract decides whether to accept a proposal. Think of a committee where each member holds a different number of votes.
Voting power and threshold. Each validator has a weight, its power. A proposal passes only if the total power of the validators who signed it is above a fixed cut-off, state_powerThreshold. It is like a club rule that a motion passes only when members holding more than half of all shares vote for it.
Validator set. The current list of validators and their powers. updateValset replaces this list.
Gas. Every operation a smart contract performs costs a small amount of a unit called gas, and the person calling the contract pays for it. Gas is like the metered electricity a machine uses: simple operations cost little, expensive ones cost more.
Block gas limit. A block is a batch of transactions added to the chain at once. There is a maximum amount of gas all transactions in one block may use together, the block gas limit. Anything that would need more gas than that cannot be included in a single block, so it cannot happen at all. Think of a lift with a maximum load: a load heavier than the limit simply never goes up.
ecrecover. A built-in operation that takes a signature and works out which account produced it. Checking one signature this way costs at least 3000 gas, according to the report.
Sanity check. A simple guard that rejects obviously unusable input before it is stored. Like a form that refuses a date of birth in the year 3000.
The context: what the feature does
Gravity Bridge is a Cosmos-based bridge, and this finding concerns the Solidity side of it: the Gravity.sol contract that holds the validator set and the power accounting used to authorise state transitions. The relevant function is updateValset, which is how the current set of validators installs a new set of validators. The report links to the function at a specific commit of the cosmos-gravity-bridge repository.
The feature exists because the bridge's security model is stake-weighted: a proposal passes when the combined power of the validators who signed it exceeds state_powerThreshold. updateValset is the entry point that replaces the signing set, so whatever it accepts becomes the set whose signatures will be counted from then on.
In plain terms: the contract has one job that matters here, deciding whether enough voting power has signed off on something. The list of who holds that power is not fixed; it can be replaced through updateValset. Whatever list goes in through that door is the list the contract will trust from that moment on. That is why the door deserves careful checks.
The setup: what the researcher needed
The report describes no accounts, roles, tooling or deployed environment. It is a code review of the linked updateValset implementation, and the reasoning is about gas costs and threshold arithmetic rather than about a live request and response. The only concrete precondition is the one the contract itself imposes: a new validator set is submitted by the current set of validators, and the contract tracks a state_powerThreshold against which validator power is compared.
So there is nothing to install and nothing to log into. The researcher read the source code of one function and reasoned about what it does and does not check. This is a common way to find bugs in smart contracts: the code is public, so anyone can read it and ask what happens if the input is unusual.
Finding it: the missing checks
The researcher looked at updateValset and noticed that it is missing a check that the combined power of all new validators is above state_powerThreshold. In other words, the function accepts a new set without verifying that the set is capable of ever meeting the threshold that governs proposals.
That omission matters because of what happens afterwards. If the new set's total power is at or below state_powerThreshold, no proposal signed by that set can ever cross the threshold, and the contract is effectively stuck. The report states this directly: if the condition is false, the contract is effectively stuck.
Picture the club again. The rule says a motion needs more than half of all shares to pass. If the membership list is replaced with people who together hold only a third of the shares, then no motion can ever pass again, no matter how many of them agree. The club has not been robbed; it has simply been made unable to decide anything. That is the first problem.
A second, related concern is the size of the new validator set. The report recommends adding a check that the size of the new validator set is less than a certain number, and then gives a rough calculation for why an extreme size such as 10000 validators is too much.
Exploitation: the arithmetic behind the danger
The report does not present an exploitation sequence, requests or responses. What it presents is the arithmetic that makes the missing checks dangerous. The reasoning runs as follows:
- Assume the new set of validators has the property that at least
Nvalidators are needed to get the total threshold abovestate_powerThreshold. - Each validating signature requires a call to
ecrecover, costing at least3000gas, so the minimum gas needed to get a proposal overstate_powerThresholdisN * 3000. N * 3000cannot be more thanblock.gaslimit. At the time of writing this putsNat less than10000.
The report's rough calculation suggests that a set needing more than the block gas limit's worth of ecrecover calls would be unable to get a proposal over the threshold. The 10000 figure is explicitly described as an extreme example, and the calculation is described as rough.
Walking through it slowly:
- Step 1 sets up a number,
N. It is the smallest number of validators whose signatures together would push the total power over the threshold. If power is spread thinly across many validators,Nis large; if a few validators hold most of the power,Nis small. - Step 2 attaches a price to each of those signatures. The contract has to run
ecrecoveronce per signature to work out who signed, and each run costs at least3000gas. So the cheapest possible bill for collectingNsignatures isN * 3000gas. - Step 3 compares that bill with the block gas limit. A transaction cannot use more gas than a whole block allows, so if
N * 3000is bigger than the limit, the transaction carrying those signatures can never be mined. With the numbers in the report, this putsNat less than10000.
The 10000 is a rough ceiling, not a magic constant, and the report says so. The point is the shape of the problem: a validator list can be accepted on chain that is, in practice, unable to ever approve anything, because gathering the required signatures would not fit in a block.
Root cause: why the code allows it
updateValset performs the replacement of the validator set without sanity checks on the incoming set. Two properties of the new set are unchecked:
- Its combined power relative to
state_powerThreshold. A set whose total power does not exceed the threshold can never authorise anything, so accepting it leaves the contract effectively stuck. - Its size. Because each signature costs at least
3000gas throughecrecover, a set large enough that the number of signatures needed to pass the threshold exceeds what fits in a block cannot pass a proposal either.
Impact: what goes wrong
The impact is that the contract is effectively stuck.: a validator set that cannot meet state_powerThreshold, or that is too large to gather enough signatures within the block gas limit, leaves the contract effectively stuck. The report frames both as potential problems to be solved, and the maintainer treats them as valid and asks for severity congruent with the duplicates.
Fix: what the report proposes
The report proposes two things. First, add an on-chain check in updateValset that the combined power of all new validators is above state_powerThreshold. Second, add a check that the size of the new validator set is below a certain number.
As an alternative, it suggests making the update a two-step process:
- The current set of validators proposes a pending set of validators.
- The pending set of validators must then perform the transition to become the new set, going through the same threshold checks.
That design guarantees that the new set has enough power to pass the threshold and does not have gas limit issues in doing so.
In the maintainer's confirmation, jkilpatr (Althea) notes that the report is a semi duplicate of #63 and #37, which describe the power sum issue, and also a semi duplicate of #9, which describes the block size issue, and states that these are both valid and should be assigned congruent severity with the duplicates.
"Semi duplicate" here means the same underlying problem was reported more than once, from slightly different angles. The maintainer agreed both problems are real and asked that this report receive the same severity as the reports it overlaps with.
Variants to test: where else to look
- Look for set-replacement functions in staking, bridge and multisig contracts that accept a new signer or validator list without comparing its total weight to the threshold used for proposals. A positive result is a set that can be installed but whose maximum achievable signature weight never exceeds the threshold.
- Check whether the number of signers required to pass the threshold, multiplied by the per-signature verification cost, can exceed the block gas limit. A positive result is a set that is accepted on chain but for which no valid proposal transaction can be mined.
- Review two-step or pending-set designs for the same gap: if the pending set is only checked for format and not for threshold capability, the guarantee the design is supposed to provide is absent.
In everyday terms, these are three questions to ask of any system that lets an administrator replace the people whose approval counts. Can the new group ever reach the required total? Can their signatures physically fit in one batch? And if the design uses a waiting period or a pending list, does that waiting period actually test the group's ability to approve, or does it only check that the list looks tidy?
Hunting notes: how to spot this class of bug
This class of bug hides in administrative functions that replace trust anchors: validator set updates, owner and signer rotation, oracle set changes and committee updates. The signal during review is a function that writes a new set and validates only superficial properties such as ordering, uniqueness or non-emptiness, while the security-critical property, the set's ability to meet the signing threshold, is checked elsewhere or not at all. Gas-based limits are easy to miss because they depend on the per-signature verification cost and the block gas limit rather than on any explicit constant in the contract.
The report establishes impact by reasoning from the contract's own threshold semantics to the stuck state, and by quantifying the gas ceiling with a rough calculation. The maintainer treats it as a semi duplicate of the related reports on the power sum and block size issues and asks for congruent severity.
A trust anchor, in plain words, is whatever the system relies on to decide who is in charge. If you can replace the trust anchor with something that cannot function, you have broken the system without touching its funds. That is why administrative functions deserve the same scrutiny as the parts that move money.
Glossary
- Block: a batch of transactions added to a blockchain together.
- Block gas limit: the maximum total gas all transactions in one block may use.
- Blockchain: a shared record book kept in copies by many computers.
- Bridge: software that moves assets between two blockchain networks.
- Cosmos: a family of blockchain networks that Gravity Bridge connects with.
ecrecover: a built-in operation that works out which account produced a signature; each call costs at least3000gas.- Gas: the metered unit of computational cost in a smart contract; the caller pays for it.
- Gravity Bridge: a Cosmos-based bridge whose Solidity contract is examined here.
Gravity.sol: the Solidity smart contract that holds the validator set and power accounting.- Maintainer: the person or team responsible for the code, here jkilpatr (Althea), who responded to the report.
- Multisig: a setup where several signers must approve an action together.
- Oracle: an outside source of data that a contract relies on.
- Proposal: an action put forward for validators to approve by signing.
- Sanity check: a simple guard that rejects obviously unusable input.
- Semi duplicate: a report describing the same underlying problem as another report, from a slightly different angle.
- Severity: the rating given to a finding to express how serious it is.
- Signature: cryptographic proof that a particular account approved something.
- Smart contract: a small program stored on a blockchain whose rules run as written.
- Solidity: the programming language used to write the contract in this report.
- Stake-weighted: a model where voting power is proportional to how much each participant has at stake.
state_powerThreshold: the fixed cut-off that the combined power of signing validators must exceed for a proposal to pass.- Threshold: a minimum total that must be exceeded for something to be accepted.
- Transaction: a request sent to a blockchain to run an operation, paid for in gas.
- Trust anchor: whatever a system relies on to decide who is in charge.
updateValset: the function that replaces the current validator set with a new one.- Validator: a participant whose approval counts towards a decision.
- Voting power: the weight a validator's approval carries.