Prepared by:
HALBORN
Last Updated 06/27/2025
Date of Engagement: February 17th, 2025 - March 13th, 2025
100% of all REPORTED Findings have been addressed
All findings
7
Critical
2
High
1
Medium
2
Low
1
Informational
1
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.
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
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.
EXPLOITABILITY METRIC () | METRIC VALUE | NUMERICAL 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 |
IMPACT METRIC () | METRIC VALUE | NUMERICAL 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 |
SEVERITY COEFFICIENT () | COEFFICIENT VALUE | NUMERICAL VALUE |
---|---|---|
Reversibility () | None (R:N) Partial (R:P) Full (R:F) | 1 0.5 0.25 |
Scope () | Changed (S:C) Unchanged (S:U) | 1.25 1 |
Severity | Score Value Range |
---|---|
Critical | 9 - 10 |
High | 7 - 8.9 |
Medium | 4.5 - 6.9 |
Low | 2 - 4.4 |
Informational | 0 - 1.9 |
Critical
2
High
1
Medium
2
Low
1
Informational
1
Security analysis | Risk level | Remediation Date |
---|---|---|
Insufficient Amount Validation in Vault Operations | Critical | Solved - 03/12/2025 |
Vault Fails to Account for IOU Transfer Fees Leading to Negative User Balances | Critical | Solved - 04/01/2025 |
Unsafe Arithmetic Operations in Vault Asset Management | High | Not Applicable - 04/01/2025 |
Missing Validation Allows Creation of Private Vaults for XRP Native Asset | Medium | Risk Accepted - 04/01/2025 |
Missing Validation Allows Setting of Contradictory Vault Flags | Medium | Risk Accepted - 04/01/2025 |
Missing Non-Transferable Share Validation in Vault Withdrawals | Low | Risk Accepted - 04/01/2025 |
Avoid Unnecessary Processing Overhead via Early Authorization Check | Informational | Solved - 04/01/2025 |
//
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.
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));
Add a check early in the preflight functions of the affected transactions types to verify that sfAmount
is greater than zero.
SOLVED: The preflight function that verifies sfAmount
is greater than zero.
//
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
User attempts to deposit 100 USD
25% transfer fee is applied (25 USD)
Only 75 USD actually reaches the vault
But the vault calculates shares based on 100 USD
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
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;
}
Handle transfer fees in deposit/withdraw calculations
Add validation to prevent negative balance scenarios
SOLVED: The Ripple team implemented enforcement measures to ensure that the account balance never falls below 0.
//
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
Implement safe arithmetic operations across all vault transactions.
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."
//
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.
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();
Add validation in the VaultCreate transaction's preflight or preclaim check to prevent creation of private vaults for XRP.
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."
//
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:
Private vaults require authorization for transfers
Non-transferable shares cannot be transferred at all
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();
}
Add validation in the preflight or preclaim check to prevent setting contradictory flags.
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."
//
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.
Add validation to check the non-transferable flag before allowing share transfers.
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."
//
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.
Move authorization checks to the preflight
or preclaim
stage in VaultWithdraw.
SOLVED: The Ripple team introduced extra checks on VaultWithdraw.
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.
// Download the full report
Ripple - Single Asset Vault - Smart Contract Assessment
* Use Google Chrome for best results
** Check "Background Graphics" in the print settings if needed