CVE-2026-141545 — Capminal Capminal-contracts — CWE-682
Capminal Contracts are the open-source smart contracts powering the Capminal protocol. Prior to commit 3e26129, capminal-contracts calculates the amount of CAPU minted by ScapStaking.lockAndMintCapu using the mint rate at the pre-mint supply for the entire transaction. A user can therefore receive more CAPU than intended in a single large mint, because the calculation does not account for the increasing mint rate as supply grows. This issue is fixed in commit 3e26129.
Capminal Contracts are the open-source smart contracts powering the Capminal protocol. Prior to commit 3e26129, capminal-contracts calculates the amount of CAPU minted by ScapStaking.lockAndMintCapu using the mint rate at the pre-mint supply for the entire transaction. A user can therefore receive more CAPU than intended in a single large mint, because the calculation does not account for the increasing mint rate as supply grows. This issue is fixed in commit 3e26129.
🎯 What is this vulnerability?
This vulnerability is a Business Logic Error (CWE-682) specifically classified as an Inaccurate Calculation or State Dependency Flaw within a smart contract.
Technical Flaw:
The function ScapStaking.lockAndMintCapu in the capminal-contracts repository calculates the amount of CAPU tokens to be minted based on a "mint rate." The critical flaw is that this calculation uses the pre-mint supply (the total supply of CAPU before the current transaction is executed) to determine the rate for the entire transaction.
In many staking or inflationary token models, the mint rate is often inversely proportional to the current supply (e.g., rate = constant / currentSupply) or follows a curve that changes as supply increases. Because the contract does not update the supply variable incrementally during the calculation of a large mint, or it uses a static snapshot of the supply for the whole operation, an attacker can exploit the discrepancy between the calculated rate (based on low supply) and the actual economic impact (which should account for the rising supply during the mint).
Essentially, if the mint rate decreases as supply increases, using the pre-mint supply (which is lower) results in a higher calculated rate than what should apply to the latter portion of the mint. This allows an attacker to mint more tokens than the protocol's economic model intends for a single large transaction.
CVSS Vector Analysis:
- AV:N/AC:L/PR:N/UI:N: The vulnerability is exploitable over the network (blockchain) with low complexity, no privileges, and no user interaction. This is standard for smart contract logic bugs.
- VI:H (Integrity High): The primary impact is on the integrity of the token supply. The attacker can alter the total supply of CAPU beyond intended limits.
- VC:N/VA:N: No direct impact on confidentiality or availability.
- Target Identification: The attacker identifies that a specific dApp or DeFi protocol is using the
capminal-contractslibrary. This can be done by:
* Checking the deployed contract bytecode on a block explorer (e.g., Etherscan) and matching it against known vulnerable versions of - Version Verification: The attacker verifies that the deployed contract version is prior to commit
3e26129. This can be confirmed by checking the contract's source code if verified, or by analyzing the function selector and logic behavior via static analysis tools like Slither or Mythril. - Parameter Analysis: The attacker analyzes the
lockAndMintCapufunction to understand the input parameters (e.g.,amountToLock,recipient) and the internal logic for calculatingcapuToMint.
⚡ Attack Chain
1. Discovery & Reconnaissance
capminal-contracts.
* Monitoring transaction logs for calls to the ScapStaking contract.
2. Exploitation
The attacker crafts a single transaction that callsScapStaking.lockAndMintCapu with a large amountToLock value. The goal is to maximize the discrepancy between the pre-mint supply-based rate and the actual supply growth during the mint.Illustrative PoC (Solidity Script):
Note: The exact function signature and variable names are illustrative based on the CVE description. The attacker must reverse-engineer the specific contract interface.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IScapStaking {
function lockAndMintCapu(uint256 amountToLock, address recipient) external payable;
function getCapuSupply() external view returns (uint256);
}
contract Exploit {
IScapStaking public staking;
constructor(address stakingAddress) {
staking = IScapStaking(stakingAddress);
}
function exploit() external {
// 1. Check current supply
uint256 currentSupply = staking.getCapuSupply();
require(currentSupply > 0, "Supply is zero");
// 2. Calculate a large amount to lock.
// The attacker chooses an amount that triggers the maximum discrepancy.
// This value depends on the specific mint rate formula in the contract.
// For example, if rate = 1000000 / supply, a large mint will use the
// initial low supply for the entire calculation, yielding a higher rate
// than if the supply were updated incrementally.
uint256 largeAmount = 1000 ether; // Illustrative value
// 3. Call the vulnerable function
// The contract will calculate capuToMint using the pre-mint supply
// for the entire largeAmount, resulting in an inflated mint.
staking.lockAndMintCapu{value: largeAmount}(largeAmount, address(this));
// 4. Check the new supply
uint256 newSupply = staking.getCapuSupply();
// The difference (newSupply - currentSupply) will be higher than intended
// by the protocol's economic model.
}
}Execution:
1. The attacker deploys the Exploit contract or sends a direct transaction from an EOA.
2. The transaction is submitted to the blockchain with sufficient gas and value (if lockAndMintCapu requires a payment).
3. The contract executes lockAndMintCapu. Internally, it calculates capuToMint using the preMintSupply.
4. The contract mints capuToMint tokens to the recipient.
5. The total supply of CAPU increases by capuToMint, which is higher than the "fair" amount calculated with an incremental supply update.
3. Post-exploitation
🌍 Real World Impact
Practical Consequences:
🛡️ Remediation & Mitigation
Exact Affected Versions and Upgrade Recommendation
capminal-contracts prior to commit 3e26129.3e26129 and later.ScapStaking contract to a version that includes the fix from commit 3e26129. This typically involves deploying a new contract version and migrating state or using a proxy pattern if the original contract is upgradeable. If the contract is not upgradeable, a migration plan must be executed, which may involve pausing the protocol, migrating user balances, and deploying the fixed contract.Actionable Workarounds
1. Pause Minting: If the protocol has a pause mechanism, immediately pause theScapStaking contract or the specific lockAndMintCapu function to prevent further exploitation.
2. Limit Mint Size: If a pause is not possible, implement a temporary limit on the maximum amountToLock per transaction to reduce the impact of the discrepancy. This is a partial mitigation and does not fix the root cause.
3. Access Control: Restrict access to lockAndMintCapu to only trusted addresses or a whitelist of users. This is a strong mitigation but may impact usability.Detection
ScapStaking contract for calls to lockAndMintCapu with unusually large amountToLock values.Example Alert Rule (Pseudo-code for Blockchain Monitor):
def check_mint_anomaly(tx):
if tx.to == SCAP_STAKING_ADDRESS:
if tx.function == "lockAndMintCapu":
pre_mint_supply = get_supply_before(tx)
expected_mint = calculate_expected_mint(tx.args.amountToLock, pre_mint_supply)
actual_mint = get_minted_amount(tx)
if actual_mint > expected_mint * 1.1: # 10% tolerance
alert("Potential CWE-682 Exploit: Mint amount exceeds expected value")⚠️ Urgency
3e26129), so there is no reason to delay patching.Action Plan:
1. Immediate: Pause the vulnerable function if possible.
2. Short-term (24-48 hours): Deploy the fixed version of the contract.
3. Medium-term: Audit the entire codebase for similar calculation errors and implement comprehensive testing for edge cases in minting logic.
[🤖 CVE Professor AI Security Engine]
FOFA Query