Introduction
We express our gratitude to the CredioLabs team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Untangled Prime is a treasury control system on Stellar (Soroban) that lets an institution keep its funds in its own custody account while an agent moves part of them under rules installed on an OpenZeppelin smart account. A policy interpreter evaluates each rule as stored data, an execution adapter runs batches of calls atomically or after a wait, a custody gate pays only its listed payees from a token allowance, and a seat contract lets short-lived session keys sign for an owner key. The audit covered the policy-interpreter, execution-adapter, custody-gate and prime-seat contracts.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for CredioLabs |
| Audited By | Kerem Solmaz |
| Approved By | Hamza Sajid |
| Website | https://untangled.finance→ |
| Whitepaper | N/A |
| Changelog | 02/11/2026 - Preliminary Report |
| 09/11/2026 - Final Report | |
| Platform | Stellar (Soroban) |
| Language | Rust |
| Tags | Signatures, Centralization, Decentralized Finance (DeFi) |
| Methodology | https://docs.hacken.io/methodologies/smart-contracts→ |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for CredioLabs
- Audited By
- Kerem Solmaz
- Approved By
- Hamza Sajid
- Website
- https://untangled.finance→
- Whitepaper
- N/A
- Changelog
- 02/11/2026 - Preliminary Report
- 09/11/2026 - Final Report
- Platform
- Stellar (Soroban)
- Language
- Rust
- Tags
- Signatures, Centralization, Decentralized Finance (DeFi)
Review Scope | |
|---|---|
| Repository | https://github.com/untangledfinance/oz-policy-builder→ |
| Initial Commit | 3048a91 |
| 1st Remediation Commit | 6a270fd5 |
| Final Commit | 266a1c4 |
Review Scope
- Initial Commit
- 3048a91
- 1st Remediation Commit
- 6a270fd5
- Final Commit
- 266a1c4
Audit Summary
The system users should acknowledge all the risks summed up in the risks section of the report
Documentation quality
No whitepaper is published; the repository provides an audit overview, an architecture document, a detailed Stellar design document, per-contract READMEs and a STRIDE threat model.
The documentation states the trust boundaries, the accepted residual risks and the known limitations of each component, which makes the intended behavior clear.
Source files carry extensive inline comments that state design intent and the assumptions each function relies on.
Several statements in the documentation and in code comments do not match the implementation at the audited commit, and some threat model entries are marked as holding where the code does not enforce them.
Most of the statements that did not match the implementation were corrected during remediation.
Code quality
The contracts are built with
soroban-sdk27.0.2 and use the standard Soroban storage, authorization and cross-contract call primitives.Every release profile enables
overflow-checks, and the arithmetic in the scoped code uses checked operations; nounsafecode is present.The custody-gate, prime-seat and execution-adapter contracts are small and have no admin, setter or upgrade path; the policy-interpreter separates decoding, evaluation and storage into distinct modules.
Issues in authorization logic, replay protection and stored-state handling were identified and reported.
Test coverage
Code coverage of the project at the audited commit is 97.60% (line coverage), measured with cargo llvm-cov on each contract's own test suite.
The suites include unit tests, integration tests against compiled contracts, and a separate suite against the OpenZeppelin 0.8.0 smart account.
Line coverage at the audited commit is 98.36% for the policy-interpreter, 97.90% for the execution-adapter, 100.00% for the prime-seat and 66.67% for the custody-gate, which has eight dedicated tests at the remediation commit.
System Overview
Untangled Prime lets an institution put part of a treasury to work through an agent while the funds stay in a custody account and can reach only destinations the institution approved. The Prime account is an OpenZeppelin smart account whose context rules delegate each per-call decision to the policy-interpreter. The custody account is a separate Stellar account that approves a token allowance, with an amount and an expiry, to the custody-gate. The system has no native token, and the in-scope contracts are four independent crates with no admin or upgrade path.
The policy-interpreter is a policy contract for the OpenZeppelin account. install stores, for an account and rule id, a predicate written in the interpreter's own grammar, a hash of the rule's signers, the rule's scope and a master signer set that administers the rule, after checking the grammar version, size limits and predicate hash. Each rule has a persistent version stored under its own key, which survives uninstall and which install, bind_executor and uninstall consume from a value the master set signs, so an old signed administrative call cannot be replayed. enforce runs on every call the rule authorizes: it decodes the stored predicate, checks the signer hash and evaluates the predicate against the call, where read leaves may call other contracts for live values. A rule may follow a rule installed by another account and evaluate that rule's predicate live. A rule that lists no signer is keyless: it must be bound to an executor with bind_executor, and the executor must authorize the exact account and call, so the predicate alone bounds what any caller can do through it. bind_executor refuses the rule's own account and the interpreter itself as the executor. A keyless rule scoped to the executor it is bound to must permit only that executor's run, or an immediate batch whose shape it fixes, including the number of grants in the batch. A keyless follower scoped to its executor is committed at bind_executor to the followed rule's call targets and functions, and enforce refuses its calls if the followed rule is re-installed with different ones; amounts still follow the source rule. uninstall removes a rule and rotate_master_signer_set replaces its administrators. Limits are fixed at deployment.
The execution-adapter runs a batch of calls in one transaction, because Soroban allows one host function call per transaction. Its address is derived from the Prime account, an optional gate, a minimum wait and a run window. With a gate, every call target, every call argument and every argument inside an authorization in a batch must be one of the gate's payees; only the contract an authorization asks to approve may be on the gate's allowed list without being a payee. A batch may be stored with a wait and then run by any account within the run window under a keyless run rule of the Prime. The current custody can cancel a stored batch and rebind the adapter to a successor gate; a rebind raises a floor below which run refuses every batch, so batches stored under the previous custody can no longer run. Without a gate, the adapter checks no address, refuses any wait, refuses a caller-supplied authorization whose followed context is another contract's execute or run, and vouches to the policy-interpreter that each context came through the call.
The custody-gate holds a fixed configuration: the custody account, a list of allowed addresses, a list of payees that the constructor requires to be a subset of the allowed addresses, one permitted caller and that caller's code hash. Its pull function, callable only by that caller, moves tokens from custody to a payee with transfer_from, within the allowance custody granted.
The prime-seat lets session keys sign for one owner of one Prime account. The owner key, an ed25519 key held by an MPC service in the reference integration, signs grants that name the account, the seat, a session key and a window of at most seven days, or that end a key. Each session key has a persistent generation that every end increments, and grant messages carry it once it is above zero, so an old end cannot revoke a key granted again later. Anyone may submit a grant. A live session key then signs the account's authorization digest, which the seat checks through verify for the account's rule 0 and through __check_auth for other rules.
The contracts publish events for rule, batch, rebind and session key changes.
In the main flow, the OpenZeppelin account selects the rule for a call, authenticates its signers and calls enforce on the policy-interpreter. For a bound rule, the execution-adapter authorizes the account and the call, then invokes the batch, which may include a pull on the custody-gate. External integrations are the OpenZeppelin smart account, the token contracts the gate moves, venue contracts such as Blend called inside batches, and contracts named by read leaves, all outside the scope. The off-chain policy synthesizer and the CLI and MCP tools in the repository were not part of this review.
Privileged roles
Prime account owners (policy-interpreter, execution-adapter): the owners act through the Prime account's rule 0 at its signer threshold. They authorize
install,bind_executorandrotate_master_signer_seton the interpreter andexecute,runandcancelon the adapter. Through the rules they install, they decide which batches agents and keyless callers may run. A compromised owner quorum could move funds up to the custody allowance to any destination the gate lists, and the Prime's own funds anywhere. The only protection is the account's signer threshold.Policy admins, the master signer set (policy-interpreter): the master set is stored with each rule at the first
installand must co-sign re-installs,bind_executor,uninstallandrotate_master_signer_set. Itsbind_executoranduninstallsignatures carry the rule version and cannot be replayed.uninstallneeds only the master set, without the account's authorization, and deletes the rule and its executor binding, which makes a keyless rule refuse every call and stops every rule that follows it. The set is limited to 16 signers and is not protected by a timelock.Rule operators (policy-interpreter): the signers listed in a keyed rule. One authenticated signer is enough for the interpreter, which applies no threshold of its own, and the rule's predicate bounds every action. A compromised operator can act up to the predicate's limits.
Bound executor (policy-interpreter, execution-adapter): the executor stored for a keyless rule must authorize the exact account and call before the rule permits it. An execution-adapter without a gate vouches for any caller, so for such an executor the predicate is the only bound.
Followed rule administrators (policy-interpreter): the master set of a rule that other accounts follow can re-install it with a different predicate or uninstall it. A change reaches every follower on its next authorization without the follower's consent, and an uninstall makes every follower refuse its calls.
Custody (execution-adapter, custody-gate): the custody account fixed in the gate grants the token allowance the gate spends, can
cancelstored batches while its gate is bound, and canrebindthe adapter to a successor gate whose custody then holds these powers. A rebind also voids the batches stored under the previous custody. Custody is a Stellar account with its own signer threshold.Gate caller (custody-gate): one adapter address with a fixed code hash can call
pulland move any token custody approved, up to the allowance, to any payee. The caller and the list are fixed at construction and cannot be changed.Seat owner key (prime-seat): the ed25519 key fixed at construction signs grants that create and end session keys, each for at most seven days. A compromised owner key can create session keys that vote in rule 0 and act in other rules that list the seat.
Session key (prime-seat): a live session key signs for its seat through
verifyand__check_authuntil its window ends, and can sign its own end.Deployer (all four contracts): the constructors take no authorization. The execution-adapter constructor requires its address to match the derivation from its parameters, and the custody-gate constructor refuses a payee that is not on the allowed list; otherwise the gate, seat and interpreter accept any configuration. A wrong allowed or payees list, custody, caller, owner key or interpreter limit cannot be corrected, because the contracts have no admin or upgrade path, and the only remedy is a new deployment.
Potential Risks
Coarse-grained Authorization Model Risks: A context rule on the Prime account that lists no signer and is bound to an execution-adapter instance deployed without a gate authorizes whoever calls the adapter's immediate batch function. In that path the adapter vouches to the policy-interpreter that each context came through the call, and the rule is then bounded by its predicate alone. No identity, no address list and no gate stand between an arbitrary caller and the actions the predicate permits. The policy-interpreter requires a keyless rule on the adapter to pin the shape of the whole batch (function, zero wait, number of calls, number of grants, each call's target and function), but it does not pin recipients or amounts. Any recipient or amount the predicate leaves open is open to any account. Funds or allowances sent to a no-gate adapter can be moved by anyone the Prime's rules let call it. A signer-gated rule on the same no-gate adapter that does not pin the number of vouched grants to zero lets its signer reach the account's keyless rules bound to that adapter outside their intended flow. The contracts do not enforce the separation between keyed and keyless rules on a shared no-gate adapter, because the policy-interpreter cannot see an account's other rules. The client's threat model records this design as E-17, E-34 and E-36.
Administrative Key Control Risks: The address list fixed in a custody-gate at deployment serves two purposes. It is the set of addresses an execution-adapter batch may name as call targets, and it is the set of addresses the gate's draw function may pay from the custody allowance. The Prime account must be on that list, because venue calls name it. A batch approved under the Prime's rule 0 (the account owners, two of three signers in the documented setup) can therefore draw custody funds into the Prime account, up to the allowance custody granted the gate. Once there, the funds are controlled by the Prime's own rules, which the same rule 0 signers can install and change, so they can forward the funds anywhere their mandate permits. Agent rules with bounded predicates cannot do this, but the rule 0 signers are a trusted party for the full custody allowance, not only for the Prime's own balance. The custody-gate now keeps a payees list separate from the addresses a batch may name, but the Prime account must remain a payee because venue calls pass it as an argument, so the exposure remains. The policy-interpreter must be kept off the payees list at deployment, because its read leaves call other contracts as the interpreter, and the contracts do not enforce this.
Dependency on External Logic for Implemented Logic: Soroban archives any contract instance, persistent entry or uploaded code whose lifetime runs out, and an archived entry must be restored before use. Only the execution-adapter extends its own instance and its stored batches. The custody-gate instance is extended by no call. The prime-seat extends its grant entries to the maximum lifetime but never its instance or code. The policy-interpreter extends a rule entry, together with the rule's version entry, only when a permitted call uses it within its last 100 ledgers, and never extends its instance or code. Continued operation of these three contracts therefore depends on an external keep-alive process that the audited code does not provide. If an instance archives, every draw, authorization or batch that depends on it fails closed: no funds move without authorization, but liquidations, scheduled moves and cancellations through the bound gate stop until someone restores the entry. Restoration is permissionless and fee-based, so recovery is possible without the owners. A position that needs timely action can still be harmed by the delay. The client's threat model records this as D-02, D-08 and D-10.
Single Points of Failure and Control: A policy-interpreter rule can follow another rule installed by a different account, so one source rule governs the predicate of every follower. The source rule's own administrators can uninstall it at any time. Every follower then refuses all calls (error 206) until each following account installs a replacement rule through its own owners. One administrative action on the source can therefore halt the authorizations of every account that follows it. The same administrators can also re-install the source with a looser predicate, and the change reaches every follower on its next authorization without the followers' consent. A re-install also widens a keyed follower, including what its agent signers may do; the client documents attaching a second policy that holds the follower's own cap as the mitigation. For a keyless follower, the call targets and functions are fixed when it is bound, but the source's administrators still control the amounts, so on an execution-adapter with no gate any account can move the follower's funds within whatever amounts the new predicate allows. Following a rule therefore makes the source rule's administrators trusted parties for both the availability and the limits of the follower's mandate. The client's threat model records these trust assumptions as D-01, D-15, E-08, E-38 and T-29.
Interactions with External DeFi Protocols: A batch stored in a gated execution-adapter can be run by any account once its wait has passed, at any ledger from its ready ledger up to the end of the adapter's run window, which is fixed at deployment. The run path requires no key: the Prime account approves it through a keyless rule scoped to the adapter. The submitter therefore chooses the exact ledger at which the stored venue calls execute, such as a Blend pool submission. The call parameters are fixed when the batch is stored, but the venue state they meet (pool utilization, prices, available liquidity) is the state at the ledger the submitter picks. A submitter can time the run within the window to the conditions least favorable to the Prime account, or delay it until the window closes. The adapter's code comments and the client's threat model document this keeper model, in which the keeper is an untrusted party.
Insufficient Permissioning and Documentation: When the prime-seat answers an authorization for a rule other than rule 0, it checks only the first context of its own authorization entry: that this context is a call on the pinned Prime account whose first argument is the account's digest. It reads no function name and does not inspect any further contexts in the entry. Those contexts are accepted on the strength of the session key's signature over the whole entry. The seat's authority over additional contexts therefore rests entirely on what the session key holder signs and on the Prime account's own rules for those contexts, not on a check in the seat. A session key holder is trusted for every context it signs within its grant window. The client's threat model records this design as E-22 and accepts it.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2026-2024 | Unpinned Grants In pins_own Let Anonymous Liquidators Drain Keyless Rule Balances | fixed | Medium | |
| F-2026-2027 | Missing Version Check In bind_executor And uninstall Lets Replayed Signatures Re-Arm Or Delete Rules | fixed | Low | |
| F-2026-2024 | Follower Targets In pins_own Let Followed Rule Owner Bypass Follower's Own Keyless Fences And Drain Its Tokens | mitigated | Low | |
| F-2026-2024 | Missing Predicate Commitment In predicate Lets Followed Rule Owner Widen Keyed Follower Fence | accepted | Low | |
| F-2026-2024 | Unvalidated Executor In bind_executor Lets A Rule Bound To Its Own Account Permit Without Any Grant | fixed | Low | |
| F-2026-2015 | Interpreter Address Accepted As pull Payee Lets Any Address Sweep Custody Funds Through A read | fixed | Low | |
| F-2026-2027 | Missing Events For Rule, Batch And Session Key Changes Across The Contracts | fixed | Observation | |
| F-2026-2027 | Repeated Read Target Re-Serialisation In decodestored Raises enforce And bindexecutor Cost | fixed | Observation | |
| F-2026-2027 | Redundant Host Work And Unused SDK Feature In Execution Adapter | fixed | Observation | |
| F-2026-2026 | Header Comments In prime-seat Overstate Revocation Permanence And Delegated Frame Checking | fixed | Observation |
Appendix 1. Definitions
Severities
When auditing smart contracts, Hacken is using a risk-based approach that considers Likelihood, Impact, Exploitability and Complexity metrics to evaluate findings and score severities.
Reference on how risk scoring is done is available through the repository in our Github organization:
Severity | Description |
|---|---|
Critical | Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation. |
High | High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation. |
Medium | Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category. |
Low | Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution. |
Severity
- Critical
Description
- Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation.
Severity
- High
Description
- High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation.
Severity
- Medium
Description
- Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category.
Severity
- Low
Description
- Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution.
Potential Risks
The "Potential Risks" section identifies issues that are not direct security vulnerabilities but could still affect the project’s performance, reliability, or user trust. These risks arise from design choices, architectural decisions, or operational practices that, while not immediately exploitable, may lead to problems under certain conditions. Additionally, potential risks can impact the quality of the audit itself, as they may involve external factors or components beyond the scope of the audit, leading to incomplete assessments or oversight of key areas. This section aims to provide a broader perspective on factors that could affect the project's long-term security, functionality, and the comprehensiveness of the audit findings.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
|---|---|
| Repository | https://github.com/untangledfinance/oz-policy-builder→ |
| Initial Commit | 3048a911103121c9cf3d20ba4c760b82c0be5f52 |
| 1st Remediation Commit | 6a270fd5d87a330e9a5cbb971f865d293e0b5327 |
| Final Commit | 266a1c40c0e74fd25d1c5b3c516c1f0cea615a1e |
| Whitepaper | - |
| Requirements | README.md |
| Technical Requirements | docs/architecture.md, docs/stellar.md, docs/audit-overview.md, OZ Policy Builder - STRIDE Threat Model |
Scope Details
- Initial Commit
- 3048a911103121c9cf3d20ba4c760b82c0be5f52
- 1st Remediation Commit
- 6a270fd5d87a330e9a5cbb971f865d293e0b5327
- Final Commit
- 266a1c40c0e74fd25d1c5b3c516c1f0cea615a1e
- Whitepaper
- -
- Requirements
- README.md
- Technical Requirements
- docs/architecture.md, docs/stellar.md, docs/audit-overview.md, OZ Policy Builder - STRIDE Threat Model
Assets in Scope
Appendix 3. Additional Valuables
Additional Recommendations
The smart contracts in the scope of this audit could benefit from the introduction of automatic emergency actions for critical activities, such as unauthorized operations like ownership changes or proxy upgrades, as well as unexpected fund manipulations, including large withdrawals or minting events. Adding such mechanisms would enable the protocol to react automatically to unusual activity, ensuring that the contract remains secure and functions as intended.
To improve functionality, these emergency actions could be designed to trigger under specific conditions, such as:
Detecting changes to ownership or critical permissions.
Monitoring large or unexpected transactions and minting events.
Pausing operations when irregularities are identified.
These enhancements would provide an added layer of security, making the contract more robust and better equipped to handle unexpected situations while maintaining smooth operations.
Frameworks and Methodologies
This security assessment was conducted in alignment with recognised penetration testing standards, methodologies and guidelines, including the NIST SP 800-115 – Technical Guide to Information Security Testing and Assessment →, and the Penetration Testing Execution Standard (PTES) →, These assets provide a structured foundation for planning, executing, and documenting technical evaluations such as vulnerability assessments, exploitation activities, and security code reviews. Hacken’s internal penetration testing methodology extends these principles to Web2 and Web3 environments to ensure consistency, repeatability, and verifiable outcomes.