Ripple - Single Asset Vault - Smart Contract Assessment - Ripple


Prepared by:

Halborn Logo

HALBORN

Last Updated 06/27/2025

Date of Engagement: February 17th, 2025 - March 13th, 2025

Summary

100% of all REPORTED Findings have been addressed

All findings

7

Critical

2

High

1

Medium

2

Low

1

Informational

1


1. Introduction

Ripple engaged Halborn to conduct a security assessment on XRP Ledger (XRPL) feature amendments beginning on February 17, 2025 and ending on March 13, 2025, focusing on PR #5224


The feature introduces a Single Asset Tokenized Vault, a new on-chain primitive that allows for aggregating assets (XRP, IOU, or MPT) from one or more depositors and represents ownership through MPToken shares. The vault serves as a foundational building block for diverse purposes such as lending markets, aggregators, yield-bearing tokens, and asset management by decoupling the liquidity provision functionality from specific protocol logic. The implementation includes core functionality for vault creation, deposits, withdrawals, and clawback operations, with support for both public and private vaults through permissioned domains.

2. Assessment Summary

The team at Halborn assigned a full-time security engineer to assess the security of the node. The security engineer is a blockchain and smart-contract security expert in advanced penetration testing, smart-contract hacking, and deep knowledge of multiple blockchain protocols.


The scope of this audit encompasses:

    • Single Asset Vault Ledger Entry Implementation

    • Core Vault Transaction Types (Create, Set, Delete, Deposit, Withdraw, Clawback)

    • Share Token Management and Access Controls

    • Asset Handling and Transfer Mechanisms

    • Vault State Management and Accounting

3. Test Approach and Methodology


Halborn performed a combination of manual review of the code and automated security testing to balance efficiency, timeliness, practicality, and accuracy in regard to the scope of the Batch Transaction feature security assessment. The following phases and tools were used:

    • Research into the architecture and mechanics of the Single Asset Vault through review of the specification, including asset management, share tokenization, and vault ownership models.

    • Manual code review and walkthrough to identify potential vulnerabilities in vault operations, share calculations, and asset transfers.

    • Security control testing for vault access restrictions, private vault permissions, and non-transferable share enforcement.

    • Documentation analysis covering vault creation parameters, transaction flows, and security considerations.

    • Edge case testing for asset freezes, transfer fees, and maximum vault capacity limits.

    • Functional testing of transaction processing flows and error handling mechanisms.

    • Review of error handling and recovery mechanisms.


4. RISK METHODOLOGY

Every vulnerability and issue observed by Halborn is ranked based on two sets of Metrics and a Severity Coefficient. This system is inspired by the industry standard Common Vulnerability Scoring System.
The two Metric sets are: Exploitability and Impact. Exploitability captures the ease and technical means by which vulnerabilities can be exploited and Impact describes the consequences of a successful exploit.
The Severity Coefficients is designed to further refine the accuracy of the ranking with two factors: Reversibility and Scope. These capture the impact of the vulnerability on the environment as well as the number of users and smart contracts affected.
The final score is a value between 0-10 rounded up to 1 decimal place and 10 corresponding to the highest security risk. This provides an objective and accurate rating of the severity of security vulnerabilities in smart contracts.
The system is designed to assist in identifying and prioritizing vulnerabilities based on their level of risk to address the most critical issues in a timely manner.

4.1 EXPLOITABILITY

Attack Origin (AO):
Captures whether the attack requires compromising a specific account.
Attack Cost (AC):
Captures the cost of exploiting the vulnerability incurred by the attacker relative to sending a single transaction on the relevant blockchain. Includes but is not limited to financial and computational cost.
Attack Complexity (AX):
Describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability. Includes but is not limited to macro situation, available third-party liquidity and regulatory challenges.
Metrics:
EXPLOITABILITY METRIC (mem_e)METRIC VALUENUMERICAL VALUE
Attack Origin (AO)Arbitrary (AO:A)
Specific (AO:S)
1
0.2
Attack Cost (AC)Low (AC:L)
Medium (AC:M)
High (AC:H)
1
0.67
0.33
Attack Complexity (AX)Low (AX:L)
Medium (AX:M)
High (AX:H)
1
0.67
0.33
Exploitability EE is calculated using the following formula:

E=meE = \prod m_e

4.2 IMPACT

Confidentiality (C):
Measures the impact to the confidentiality of the information resources managed by the contract due to a successfully exploited vulnerability. Confidentiality refers to limiting access to authorized users only.
Integrity (I):
Measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of data stored and/or processed on-chain. Integrity impact directly affecting Deposit or Yield records is excluded.
Availability (A):
Measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability. This metric refers to smart contract features and functionality, not state. Availability impact directly affecting Deposit or Yield is excluded.
Deposit (D):
Measures the impact to the deposits made to the contract by either users or owners.
Yield (Y):
Measures the impact to the yield generated by the contract for either users or owners.
Metrics:
IMPACT METRIC (mIm_I)METRIC VALUENUMERICAL VALUE
Confidentiality (C)None (I:N)
Low (I:L)
Medium (I:M)
High (I:H)
Critical (I:C)
0
0.25
0.5
0.75
1
Integrity (I)None (I:N)
Low (I:L)
Medium (I:M)
High (I:H)
Critical (I:C)
0
0.25
0.5
0.75
1
Availability (A)None (A:N)
Low (A:L)
Medium (A:M)
High (A:H)
Critical (A:C)
0
0.25
0.5
0.75
1
Deposit (D)None (D:N)
Low (D:L)
Medium (D:M)
High (D:H)
Critical (D:C)
0
0.25
0.5
0.75
1
Yield (Y)None (Y:N)
Low (Y:L)
Medium (Y:M)
High (Y:H)
Critical (Y:C)
0
0.25
0.5
0.75
1
Impact II is calculated using the following formula:

I=max(mI)+mImax(mI)4I = max(m_I) + \frac{\sum{m_I} - max(m_I)}{4}

4.3 SEVERITY COEFFICIENT

Reversibility (R):
Describes the share of the exploited vulnerability effects that can be reversed. For upgradeable contracts, assume the contract private key is available.
Scope (S):
Captures whether a vulnerability in one vulnerable contract impacts resources in other contracts.
Metrics:
SEVERITY COEFFICIENT (CC)COEFFICIENT VALUENUMERICAL VALUE
Reversibility (rr)None (R:N)
Partial (R:P)
Full (R:F)
1
0.5
0.25
Scope (ss)Changed (S:C)
Unchanged (S:U)
1.25
1
Severity Coefficient CC is obtained by the following product:

C=rsC = rs

The Vulnerability Severity Score SS is obtained by:

S=min(10,EIC10)S = min(10, EIC * 10)

The score is rounded up to 1 decimal places.
SeverityScore Value Range
Critical9 - 10
High7 - 8.9
Medium4.5 - 6.9
Low2 - 4.4
Informational0 - 1.9

5. SCOPE

Files and Repository
(a) Repository: rippled
(b) Assessed Commit ID: 9d619b9
(c) Items in scope:
  • "include/xrpl/json/json_value.h"
  • "include/xrpl/protocol/AMMCore.h"
  • "include/xrpl/protocol/Asset.h"
↓ Expand ↓
Out-of-Scope:
Remediation Commit ID:
Out-of-Scope: New features/implementations after the remediation commit IDs.

6. Assessment Summary & Findings Overview

Critical

2

High

1

Medium

2

Low

1

Informational

1

Security analysisRisk levelRemediation Date
Insufficient Amount Validation in Vault OperationsCriticalSolved - 03/12/2025
Vault Fails to Account for IOU Transfer Fees Leading to Negative User BalancesCriticalSolved - 04/01/2025
Unsafe Arithmetic Operations in Vault Asset ManagementHighNot Applicable - 04/01/2025
Missing Validation Allows Creation of Private Vaults for XRP Native AssetMediumRisk Accepted - 04/01/2025
Missing Validation Allows Setting of Contradictory Vault FlagsMediumRisk Accepted - 04/01/2025
Missing Non-Transferable Share Validation in Vault WithdrawalsLowRisk Accepted - 04/01/2025
Avoid Unnecessary Processing Overhead via Early Authorization CheckInformationalSolved - 04/01/2025

7. Findings & Tech Details

7.1 Insufficient Amount Validation in Vault Operations

//

Critical

Description

In VaultWithdraw, VaultDeposit and Clawback, the amount validation logic has a vulnerability that could lead to incorrect vault state updates.

There is no validation to prevent negative amounts from being processed. The doApply() functions in transactions directly use the input amount without validating its sign, allowing an attacker to manipulate the vault's state.


Proof of Concept
        tx = vault.withdraw(
            {.depositor = depositor,
             .id = keylet.key,
             .amount = asset(-50)});
        tx[sfAmount] = "-999999999";
        std::cout << "tx: " << tx << std::endl;
        env(tx, ter(tecINSUFFICIENT_FUNDS));

BVSS
Recommendation

Add a check early in the preflight functions of the affected transactions types to verify that sfAmount is greater than zero.

Remediation Comment

SOLVED: The preflight function that verifies sfAmount is greater than zero.

Remediation Hash

7.2 Vault Fails to Account for IOU Transfer Fees Leading to Negative User Balances

//

Critical

Description

The vault implementation does not properly handle IOU transfer fees during deposit/withdraw operations, which can result in unexpected negative balances for users. When an IOU has a transfer fee (e.g., 25%), the vault calculates shares based on the pre-fee amount but the actual transferred amount is reduced by the fee:

testcase("Deposit transfer fee");
env(rate(issuer, 1.25));  // Set 25% transfer fee
env.close();

// Alice deposits 100 USD into vault
auto txDeposit = vault.deposit({
    .depositor = alice,
    .id = keylet.key,
    .amount = asset(100)
});
env(txDeposit);
env.close(); 
// @audit balance becomes negative (-25 USD) due to fee not being accounted for
  1. User attempts to deposit 100 USD

  2. 25% transfer fee is applied (25 USD)

  3. Only 75 USD actually reaches the vault

  4. But the vault calculates shares based on 100 USD

  5. Results in a negative balance for the user

Impact

  • Users can end up with unexpected negative balances

  • Incorrect share allocation relative to the actual deposited amount

  • Possible economic imbalance between assets and shares


Proof of Concept
        using namespace test::jtx;
        testcase("Test IOU fees");

        Env env{*this};
        Account const alice{"alice"};
        Account const issuer{"issuer"};
        env.fund(XRP(1000), alice, issuer);
        env.close();

        auto asset = issuer["USD"];
        auto vault = env.vault();
        
        auto [tx, keylet] = vault.create({.owner = alice, .asset = asset});
        env(tx);
        env.close();
        env.trust(asset(1000), alice);
        env.close();
        
        env(pay(issuer, alice, asset(100)));
        env.close();
        std::cout << "aliceInitialBalance: " << env.balance(alice, asset) << std::endl;

        {
            testcase("Deposit transfer fee");
            
            env(rate(issuer, 1.25));
            env.close();

            // Alice deposits 100 USD into vault
            auto txDeposit = vault.deposit({
                .depositor = alice,
                .id = keylet.key,
                .amount = asset(100)
            });
            env(txDeposit);
            env.close();             
            std::cout << "vault after deposit: " << *env.le(keylet) << std::endl;
        }


BVSS
Recommendation
  • Handle transfer fees in deposit/withdraw calculations

  • Add validation to prevent negative balance scenarios


Remediation Comment

SOLVED: The Ripple team implemented enforcement measures to ensure that the account balance never falls below 0.

Remediation Hash

7.3 Unsafe Arithmetic Operations in Vault Asset Management

//

High

Description

Multiple instances of unsafe arithmetic operations have been identified across the vault management transactions that could lead to integer overflow or underflow conditions. These operations directly modify critical vault state variables without proper safeguards.


vault->at(sfAssetTotal) -= assets;    // Possible underflow
vault->at(sfAssetAvailable) -= assets;
vault->at(sfAssetTotal) += assets;    // Possible overflow
vault->at(sfAssetAvailable) += assets;
vault->at(sfAssetTotal) -= assets;    // Possible underflow
vault->at(sfAssetAvailable) -= assets;
assetTotal -= vault->at(sfLossUnrealized); // Could underflow if loss > assetTotal


BVSS
Recommendation

Implement safe arithmetic operations across all vault transactions.

Remediation Comment

NOT APPLICABLE: The Ripple team stated the following:


"The type used on both sides of -= and += is Number, which implements checks for overflow and underflow and will throw an exception in such a situation. The exception will be intercepted in the transactor and turned into a well-defined transaction error tefEXCEPTION and the transaction will be aborted. I think a unit test for such a case might be impossible, as it would require the total issuance of the asset to exceed the Number limits."

7.4 Missing Validation Allows Creation of Private Vaults for XRP Native Asset

//

Medium

Description

The current implementation lacks validation to prevent the creation of private vaults for XRP native assets, which contradicts the protocol specification. According to the specification, XRP vaults cannot be private, but there is no enforcement of this rule in the code.


Proof of Concept
        Env env(*this);
        Account const alice{"alice"};
        env.fund(XRP(10000), alice);
        env.close();

        auto vault = env.vault();
        Asset xrpAsset = xrpIssue();

        // Try to create vault with XRP and private flag
        auto [tx, keylet] = vault.create({
            .owner = alice,
            .asset = xrpAsset,
        });
        tx[sfFlags] = tfVaultPrivate;

        // Should fail since XRP vaults cannot be private
        env(tx, ter(temMALFORMED));
        env.close();

BVSS
Recommendation

Add validation in the VaultCreate transaction's preflight or preclaim check to prevent creation of private vaults for XRP.

Remediation Comment

RISK ACCEPTED: The Ripple team stated the following:

"Seem to be based on an obsolete version of XLS-0065d or perhaps pre-proposal discussion. Creating private vaults for native XRP is allowed, by design."

7.5 Missing Validation Allows Setting of Contradictory Vault Flags

//

Medium

Description

In VaultCreate, there is no validation to prevent setting contradictory flags during vault creation. Specifically, the code allows setting both tfVaultPrivate and tfVaultShareNonTransferable flags simultaneously, which creates a logical contradiction in the vault's behavior.

Setting both private and non-transferable flags creates an ambiguous state:

  1. Private vaults require authorization for transfers

  2. Non-transferable shares cannot be transferred at all


Proof of Concept
        testcase("Test contradictory flags");
        {
            Env env(*this);
            Account const alice{"alice"};
            Account const issuer{"issuer"};
            env.fund(XRP(10000), alice, issuer);
            env.close();

            auto vault = env.vault();
            Asset iouAsset = issuer["USD"];

            // Try to create vault with both private and non-transferable flags
            auto [tx, keylet] = vault.create({
                .owner = alice,
                .asset = iouAsset,
            });
            tx[sfFlags] = tfVaultPrivate | tfVaultShareNonTransferable;

            // Should fail since private vaults must have transferable shares
            env(tx, ter(temMALFORMED));
            env.close();
        }

BVSS
Recommendation

Add validation in the preflight or preclaim check to prevent setting contradictory flags.

Remediation Comment

RISK ACCEPTED: The Ripple team stated the following:

"Flags tfVaultPrivate and tfVaultShareNonTransferable are not mutually exclusive. The authorization for tfVaultPrivate is enforced only in VaultDeposit, while tfVaultShareNonTransferable is enforced on all transfers of MPT shares of the vault (other than back to the vault, since the flag does not apply to the issuer). This means that, if shares are non-transferable and the vault is private, only the original investors can withdraw assets back from the vault, and only using the amount of MPT shares they originally received in exchange for their assets. This means the vault functionality is limited, but it does not make the vault useless as such. If the vault is private, but shares are transferable, then the original investors can transfer the MPT shares to someone else (who can also transfer the shares etc.) and the ultimate holder of the shares will be able to withdraw the assets (matching the amount of shares held) from the vault, despite not being allowed to invest themselves. This is by design."

7.6 Missing Non-Transferable Share Validation in Vault Withdrawals

//

Low

Description

In VaultWithdraw, there is no validation to enforce the tfVaultShareNonTransferable flag restriction before transferring shares. According to the specification in section 1.1.3.

The accountSend function doesn't have checks for tfVaultShareNonTransferable.

BVSS
Recommendation

Add validation to check the non-transferable flag before allowing share transfers.

Remediation Comment

RISK ACCEPTED: The Ripple team stated the following:

"Flag tfVaultShareNonTransferable does not impact transfer of shares to/from the issuer, which in this case is the vault pseudo-account, so there is nothing to enforce. The purpose of the flag is to enforce that the MPT shares of the vault cannot be transferred by the investors other than back to the vault, in which case the investors receive a matching amount of assets back. Similarly, the withdraw operation now allows the assets to be sent to a 3rd party via Destination field, without regard to this flag. This is by design."

7.7 Avoid Unnecessary Processing Overhead via Early Authorization Check

//

Informational

Description

In the Vault withdrawal implementation, authorization checks are performed late in the transaction processing flow via accountSend rather than being rejected at an early stage.
Currently, unauthorized withdrawal attempts are processed through multiple stages of transaction validation before being rejected, rather than being caught early in the preflight or preclaim stages. This creates unnecessary processing overhead.

BVSS
Recommendation

Move authorization checks to the preflight or preclaim stage in VaultWithdraw.

Remediation Comment

SOLVED: The Ripple team introduced extra checks on VaultWithdraw.

Remediation Hash

Halborn strongly recommends conducting a follow-up assessment of the project either within six months or immediately following any material changes to the codebase, whichever comes first. This approach is crucial for maintaining the project’s integrity and addressing potential vulnerabilities introduced by code modifications.

© Halborn 2025. All rights reserved.