Skip to content
Business logic Audit finding Advanced

Get_state_proof() is called with the current version leading to the epoch_changes of the StateProof always being empty

When a block is executed, the state proof is requested using the version after the block rather than before it, so the epoch change branch is never taken. This makes the epoch_changes of the state proof always empty, which can produce an invalid block commitment.

HollaDieWaldfee Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#43312 [BC-Medium] get_state_proof() is called with the current version leading to the epoch_changes of the StateProof always being empty

Submitted on Apr 4th 2025 at 14:00:01 UTC by @HollaDieWaldfee for Attackathon | Movement Labs

Description

Brief/Intro

When executing a block, get_state_proof() is called but with the wrong version. As a result, the epoch_changes of the StateProof is always going to be empty, producing an invalid block commitment.

Vulnerability Details

After a block is executed, get_state_proof() is called with the version being the state_compute.version() after the new block is executed. This version is the current version and as a result, when get_state_proof_with_ledger_info() is called, it always enters the else-block which returns a StateProof with empty epoch_changes:

Rust
    fn get_state_proof_with_ledger_info(
        &self,
        known_version: u64,
        ledger_info_with_sigs: LedgerInfoWithSignatures,
    ) -> Result<StateProof> {
        gauged_api("get_state_proof_with_ledger_info", || {
            let ledger_info = ledger_info_with_sigs.ledger_info();
            ensure!(
                known_version <= ledger_info.version(),
                "Client known_version {} larger than ledger version {}.",
                known_version,
                ledger_info.version(),
            );
            let known_epoch = self.ledger_db.metadata_db().get_epoch(known_version)?;
            let end_epoch = ledger_info.next_block_epoch();
            let epoch_change_proof = if known_epoch < end_epoch {
                let (ledger_infos_with_sigs, more) =
                    self.get_epoch_ending_ledger_infos(known_epoch, end_epoch)?;
                EpochChangeProof::new(ledger_infos_with_sigs, more)
@>            } else {
                EpochChangeProof::new(vec![], /* more = */ false)
            };

            Ok(StateProof::new(ledger_info_with_sigs, epoch_change_proof))
        })
    }

Instead, get_state_proof() should be called with the version BEFORE the block is executed such that a change in the epoch can be detected in the if-case.

Impact Details

The epoch_changes of the state proof after executing a block is always going to be empty.
As a result, the block commitment that is calculated from the state proof can be invalid:

Rust
let commitment = Commitment::digest_state_proof(&proof);
Ok(BlockCommitment::new(block_height.into(), Id::new(*block_id.clone()), commitment))

References

(1): https://github.com/immunefi-team/attackathon-movement/blob/a2790c6ac17b7cf02a69aea172c2b38d2be8ce00/protocol-units/execution/maptos/opt-executor/src/executor/execution.rs#L63-L89

(2): https://github.com/immunefi-team/attackathon-movement-aptos-core/blob/627b4f9e0b63c33746fa5dae6cd672cbee3d8631/storage/aptosdb/src/db/include/aptosdb\\_reader.rs#L399-L424

Proof of Concept

Proof of Concept

  1. During the block execution flow, execute_block() is called. After the block is executed, get_state_proof() is called. However, this function is called with the wrong version, namely the version after the block is executed (reference (1)).
  2. As a result, get_state_proof_with_ledger_info() always returns a StateProof with empty epoch_changes since known_epoch == end_epoch and the function always enters the else-block.

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

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

Likely the state proof is requested with the post-execution version instead of the pre-execution version, so the known epoch equals the end epoch and the epoch change branch is skipped.

Impact

The epoch_changes of the state proof after executing a block is always empty, so the block commitment calculated from the state proof can be invalid.

What the attacker needed

None

The fix

get_state_proof() should be called with the version before the block is executed so an epoch change can be detected.

How it was found

  1. Execute a block through the block execution flow.
  2. Observe that get_state_proof() is called with the version after the block is executed.
  3. See that get_state_proof_with_ledger_info() returns a state proof with empty epoch_changes because known_epoch equals end_epoch.

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 blockchain node periodically groups blocks into periods called epochs, and when it hands out a proof about its state it should include a record of any epoch change. Here the code asks for that proof using a version number that is already past the change, so the check that would include the change always fails and the proof comes back with an empty list. That can make the commitment, a fingerprint of the block, wrong.

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.

More by HollaDieWaldfee

View all

39 more disclosed reports, best first.

More from Movement Labs

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.