Incorrect Gas Cost Used for BLS12381 Subgroup Check Causes ~70% Undercharge
The BLS12381 public-key subgroup check native function charged the deserialisation gas constant instead of the subgroup-check constant, so each call was billed roughly 70% less than intended. A malicious user could repeatedly perform the more expensive subgroup check while paying the cheaper deserialisation price, consuming node resources cheaply.
Originally disclosed on Immunefi
- Disclosed after under an hour
#41669 [BC-Medium] Incorrect Gas Cost Used for BLS12381 Subgroup Check Causes ~70% Undercharge
Submitted on Mar 17th 2025 at 12:59:39 UTC by @Minato7namikazi for Attackathon | Movement Labs
- Report ID: #41669
- Report Type: Blockchain/DLT
- Report severity: Medium
- Target: https://github.com/immunefi-team/attackathon-movement-aptos-core/tree/main
- Impacts:
- A bug in the respective layer 0/1/2 network code that results in unintended smart contract behavior with no concrete funds at direct risk
- Increasing network processing node resource consumption by at least 30% without brute force actions, compared to the preceding 24 hours
Description
Details
In attackathon-movement-aptos-core/move_framework/src/natives/cryptography/bls12381.rs
In bls12381_pk_subgroub_check, the code charges BLS12381_PER_PUBKEY_DESERIALIZE instead of using BLS12381_PER_PUBKEY_SUBGROUP_CHECK. This causes the gas cost for subgroup-checking public keys to be incorrectly computed.
This is a clear issue since the gas cost should reflect the actual operation being performed - subgroup checking is a different operation from deserialization with different computational costs.
The function bls12381_pk_subgroub_check is specifically for checking subgroup membership
The gas parameters struct clearly defines separate costs for deserialization (per_pubkey_deserialize) and subgroup checking (per_pubkey_subgroup_check)
Impact
Looking at the gas schedule configuration in the Aptos framework, which defines the gas costs for various native operations in the blockchain.
BLS12381_PER_PUBKEY_DESERIALIZE= 400,684 gas unitsBLS12381_PER_PUBKEY_SUBGROUP_CHECK= 1,360,120 gas units
The bug is charging 400,684 gas units when it should be charging 1,360,120 gas units
This means users are being undercharged by 959,436 gas units (1,360,120 - 400,684) for each public key subgroup check operation
The gas cost being charged is only ~29.5% of what it should be
This represents a significant undercharging of approximately 70.5% less gas than what should be charged
Subgroup checking is a more computationally expensive operation than deserialization
The gas schedule was designed to reflect this higher computational cost (hence the ~3.4x higher gas cost)
This could potentially be exploited by malicious users to perform expensive subgroup check operations while paying much less gas than they should
Proof of Concept
- Generate a BLS12381 public key that requires subgroup checking
- If we Call bls12381_pk_subgroub_check and measure the gas consumption it will show 400,684 units
- In the gas schedule the BLS12381_PER_PUBKEY_SUBGROUP_CHECK should be 1,360,120 units
- We Demonstrated the 959,436 gas unit deficit (70.5% undercharge) between actual vs expected cost
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 a copy-paste or wrong-constant mistake: the subgroup-check function referenced the per-public-key deserialisation gas constant rather than the subgroup-check constant.
Impact
Users could perform expensive subgroup-check operations while paying only about 29.5% of the intended gas, potentially increasing node resource consumption; the report claims no concrete funds are at direct risk.
What the attacker needed
Ability to submit BLS12381 subgroup-check calls
The fix
The function should charge the subgroup-check gas constant instead of the deserialisation constant.
How it was found
- Generate a BLS12381 public key that requires subgroup checking
- Call the subgroup-check function and measure the gas consumed
- Compare the measured cost with the configured subgroup-check cost
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.
Blockchains charge 'gas' for each operation so that heavy work costs more and cannot be spammed cheaply. Here the code that checks a cryptographic key was billed at the price of a cheaper, different operation, so callers paid far less than the real cost of the work. That lets someone make the network do expensive calculations at a discount.
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.