Brickken Protocol v2 Audit
OpenZeppelin Security
Findings
Total issues: 29 (18 resolved, 1 partially resolved)
Critical: 0 (0 resolved) · High: 0 (0 resolved) · Medium: 5 (4 resolved, 1 partially resolved) · Low: 12 (6 resolved)
Notes & Additional Information
12 notes raised (8 resolved)
Client Reported Issues
0 reported issues (0 resolved)
Scope
OpenZeppelin audited the brickken/brickken-protocol-v2 repository at commit 8394e34.
In scope were the following files:
contracts
├── factory
│ ├── Factory.sol
│ ├── FactoryManager.sol
│ └── deployer
│ ├── FactoryDTOERC7943Deployer.sol
│ ├── FactorySTOERC7943Deployer.sol
│ └── FactoryTokenDeployer.sol
├── feeManager
│ └── FeeManager.sol
├── handlers
│ └── payments
│ ├── DTOHandler.sol
│ ├── PaymentHandler.sol
│ ├── PaymentHandlerStorage.sol
│ ├── PaymentLedger.sol
│ └── STOHandler.sol
├── tokens
│ ├── ERC20
│ │ ├── BasicERC20.sol
│ │ ├── MaxSupplyERC20.sol
│ │ └── StableERC20.sol
│ ├── ERC7943
│ │ ├── DTO7943.sol
│ │ ├── ERC7943.sol
│ │ └── STO7943.sol
│ └── extensions
│ ├── ERC1643Documents.sol
│ ├── ERC20Authorization.sol
│ ├── ERC20Checkpoints.sol
│ └── RoleMigration.sol
├── universal-escrow
│ ├── EscrowIssuance.sol
│ ├── EscrowSettlement.sol
│ ├── EscrowStorage.sol
│ └── UniversalEscrowUpgradeable.sol
└── utils
├── Errors.sol
├── PaymentTokenBase.sol
├── Permit.sol
├── Roles.sol
├── SignatureAuth.sol
└── TokenScopedRoles.solUpdate: The fixes mentioned in this report were merged at commit 7c23f70, tagged as v2.0.5, which represents the final state of the audited codebase. On top of the fixes, this commit only introduces changes to code comments and formatting in the in-scope files.
System Overview
Brickken Protocol v2 is a set of smart contracts for tokenizing real-world assets. It lets Brickken clients (issuers and borrowers) create compliance-controlled security tokens, raise money by selling them, and then pay token holders back. Equity tokens (STO) receive dividends, while debt tokens (DTO) receive capital plus interest. Each raise or payment uses a single ERC-20 payment token (e.g., USDC), and the protocol does not rely on price oracles.
Unlike the previous version, which deployed separate contracts for each issuer, v2 uses one shared set of upgradeable (UUPS) contracts for all clients. Clients are kept apart by token-scoped roles: a role granted for one token gives no power over another token. The security tokens themselves are not upgradeable, and a new one is deployed for every tokenization.
The system is made up of the following components:
- Factory:
FactoryManageris the entry point for creating a tokenization. It checks a fee report signed by Brickken, charges the tokenization fee to the Brickken vault, and deploys the new token through a registered deployer contract. - Security Tokens:
ERC7943is an ERC-20 token with send and receive whitelists, frozen amounts, forced transfers, and an optional supply cap.STO7943andDTO7943extend it with balance checkpoints (used to compute payouts), gasless approvals and transfers, and an on-chain document registry. SimplerStableERC20andBasicERC20tokens can also be deployed. - Universal Escrow:
UniversalEscrowUpgradeableruns the primary sale. Issuers open issuances with a soft cap, a hard cap, a price, and a time window. Investors deposit payment tokens on-chain, and the Brickken backend can also book off-chain purchases (such as bank transfers). If the raise succeeds, the escrow mints all allocations to itself, pays the issuer after deducting the success fee, and lets each investor claim their tokens. If the raise fails or is cancelled, investors get their deposits back. - Payment Handler:
PaymentHandleris used after the sale. Issuers fund dividends (STO) and borrowers fund debt repayments (DTO), and each holder can claim a share based on their token balance at the time the payment was added. Anyone can trigger a claim on behalf of a holder, but the funds always go to the holder. For DTOs, the total debt is fixed by a one-time price that the Brickken backend signs and that the borrower submits. A holder's DTO balance is burned once the debt is fully repaid and claimed. - Fee Manager:
FeeManagerstores the success fee rate for each token and splits each fee between Brickken recipients and optional partner recipients. It does not hold funds, as it sends each share directly to the recipients.
The main lifecycle of a tokenization is as follows: the token is created through the factory, it is sold through the escrow, investors redeem their tokens (or are refunded), and the issuer later distributes dividends, or the borrower repays the debt, through the payment handler.
Security Model and Trust Assumptions
The contracts enforce role checks, signatures, and accounting. They do not verify off-chain facts such as bank payments, the legal eligibility of investors, or the value of the tokenized asset. Since the main contracts are shared by all clients, a single faulty upgrade or misconfiguration can affect every client at once. The tokens are not upgradeable, so an upgrade of a shared contract cannot change their code or their role assignments. However, it can still use the roles granted to the shared contracts on each token, such as minting by the escrow and burning DTO balances by the payment handler, until those roles are revoked.
During the audit, the following trust assumptions were identified:
- All payment tokens are allowlisted by Brickken and behave like standard ERC-20 tokens with stable decimals (such as USDC, USDT, or DAI). Tokens that take a fee on incoming transfers are supported, but rebasing tokens and tokens with transfer hooks are not.
- The tokens checked by the escrow and the payment handler are the intended factory-deployed tokens, since admission depends on role grants and not on the factory registry.
- Signers build the correct EIP-712 messages and track nonces, which are sequential for each signer and each type of message.
- The total supply of a DTO does not change once the first debt repayment has been made.
- Upgrades keep the existing storage layout, and proxies are initialized with the intended roles at deployment.
- Block timestamps are reliable enough to order checkpoints and to enforce issuance windows.
Privileged Roles
The following roles were identified in the codebase:
- Brickken Admin (
DEFAULT_ADMIN_ROLE): Holds the admin role on every shared contract and on every deployed security token. It can upgrade the shared contracts without a timelock, through a multisig account, change the fee vault and the registered deployers, pause and cancel issuances, withdraw any ERC-20 balance from the escrow (including live deposits), change the issuer of a token, and choose which address can burn DTO balances. This role is fully trusted. - Brickken Backend (
ESCROW_MANAGER_ROLE,PAYMENT_ADMIN_ROLE,FEE_MANAGER_ADMIN_ROLE,DEBT_PRICE_REPORTER_ROLE, andFACTORY_OFFCHAIN_REPORTER_ROLE): Allowlists payment tokens, books off-chain purchases in the escrow without any on-chain payment, signs issuances and payment authorizations, grants token-scoped roles on the shared contracts, sets the success fee rates and Brickken recipients (with immediate effect on live raises), signs the one-time DTO price, and signs tokenization fee reports. These roles are trusted to book only genuine off-chain payments, to set correct fees and prices, and to admit only suitable tokens. - Issuer or Borrower: Controls its own token (minting, burning, whitelisting, freezing, and forced transfers) and runs its own raises and payments through token-scoped roles in the escrow and the payment handler. The issuer is trusted to manage its own token within these powers, but it is not trusted with investor funds, allocations, or claims beyond them, and it must not be able to affect other clients' tokens.
- Partner: Sets the list of partner recipients that receive part of the success fee for a specific token. It is trusted only for its own token's fee split.
Investors, token holders, fee payers, and any external caller of the permissionless functions (such as buying, redeeming, claiming, or fee distribution) are untrusted.
Update: The fixes changed some of the roles described above. The admin of each new token is no longer the Brickken Admin. Instead, it is the admin address set in the tokenization config, which the Brickken backend approves as part of the signed tokenization report. This token admin can change the issuer or borrower of its token, choose which address can burn DTO balances, and grant itself the other roles of the token. In addition, the Brickken backend can now enable or disable the final burn of each DTO, and its signed DTO price report also fixes the token in which the debt must be repaid.
Medium Severity
Anyone Can Burn the Unredeemed DTO Allocations Held by the Escrow
When a DTO7943 issuance succeeds, _withdraw pre-mints the full allocation to the UniversalEscrow, and participants later pull their tokens through getTokens. The escrow is thus a whitelisted holder of every unredeemed allocation, and nothing requires all allocations to be redeemed before repayments start.
Since claim is permissionless, anyone can claim on behalf of the escrow. Once the debt is fully repaid, this reaches the final burn, which destroys the escrow's entire balance across every issuance of the token. getTokens then reverts for every remaining participant, and neither forcedTransfer nor re-minting can restore the allocations. The repayments paid to the escrow can only be returned through the unaccounted withdrawExcessToken and off-protocol distribution. Participants who no longer pass canReceive cannot redeem at all, so their allocations are always exposed.
Consider ensuring that DTO allocations held by the escrow on behalf of participants cannot be burned before they are redeemed.
Update: Resolved in pull request #105. The team stated:
“Fixed. The final burn in_claimDebtRepaynow runs only after the backend enables it per DTO withtoggleFinalBurn(dto, true)PAYMENT_ADMIN_ROLE). It is off by default. The backend enables it once every escrow allocation of the DTO has been delivered throughgetTokens. Until then, a claim on behalf of the escrow pays out and burns nothing, so unredeemed allocations stay intact. The payment handler has no reference to the escrow, and the toggle avoids a new cross-contract dependency.”
Issuer Can Unilaterally Change Issuance Terms After Deposits Are Accepted
In the UniversalEscrow, a raise that ends below softCap is rolled back and participants recover their deposits. However, the issuer can edit any ACTIVE issuance through patchIssuance, which only enforces internal consistency and blocks soft cap increases after a withdrawal.
The issuer can lower softCap to raisedAmount at any time, during or after the raise, and immediately call partialWithdraw, which only requires raisedAmount >= softCap. Once the funds are withdrawn, adminCancel only refunds pro-rata against the remaining balance. Participants promised a refund below the soft cap end up holding tokens of an undercapitalized issuance instead. Similarly, the issuer can extend endDate indefinitely to withhold refunds on a failed raise, although the admin can remedy this. The issuer can also lower hardCap to the current raisedAmount at any time, as _validateIssuance allows. This immediately satisfies the early finalization condition of finalizeIssuance. Thus, the issuer decides when a raise ends as well as whether it succeeds.
Consider restricting which issuance parameters can be modified once deposits have been accepted or the issuance has ended. This would prevent the issuer from unilaterally changing the terms participants relied upon.
Update: Partially resolved in pull request #80 at commit 2cd2a64. The patchIssuance function now reverts with the IssuanceEnded error once the issuance has ended, and with the new IssuanceTermsLocked error when the startDate or softCap field is changed after any amount has been raised. As a result, the issuer can no longer turn a failed raise into a successful one or reopen an ended raise, and lowering the hardCap field can only trigger early finalization once the soft cap has been met, since the _validateIssuance function keeps the softCap field at or below it. However, the endDate field can still be extended while the issuance is live, so refunds on a failing raise can be postponed indefinitely. The Brickken team accepted this risk, stating that the admin can stop such an issuance through the adminCancel function. The team stated:
“patchIssuancenow reverts afterendDate, andstartDateandsoftCapare locked once the issuance has deposits. So the issuer can no longer lowersoftCapto withdraw from a raise that should roll back, and cannot reopen a raise that has ended.”
“endDatestays patchable because issuers need to extend live raises. We accept the risk of delayed refunds on a failed raise, because the admin can stop it withadminCancel. MovingendDateearlier does not hurt depositors, becausesoftCapis locked.”
“LoweringhardCapalso stays allowed._validateIssuancekeepssoftCap <= hardCap, andsoftCapis locked. SohardCapcan only reachraisedAmountafter the raise has already succeeded, and the early finalize only stops new buyers.”
Zero Computed Debt Is Treated as Full Repayment, Allowing Anyone to Burn DTO Balances
Once _isDebtRepaid returns true and a holder has settled every repayment entry, _claimDebtRepay burns the holder's full DTO balance. However, _isDebtRepaid only checks that the computed remaining debt is zero. This is also the case when no debt has been established: while capitalPricePerToken is unset, or when supply * capitalPricePerToken rounds down to zero. If repayments are enabled in this state, the ledger is empty and the cursor check holds as 0 == 0. Any address can then call the permissionless claim to burn the balance of any whitelisted holder without payment. This includes the UniversalEscrow, which holds all unredeemed allocations after an issuance is finalized. Burning its DTO balance causes every subsequent getTokens call to revert.
toggleDebtRepayment does not require the price to be set, and the documented onboarding flow enables repayments right after setPaymentHandler, only requiring the price before the first repayment.
Consider having _isDebtRepaid return true only once a non-zero capital debt has been established, and requiring the capital price to be set before toggleDebtRepayment can enable repayments.
Update: Resolved in pull request #73. The team stated:
“The root cause is fixed in_isDebtRepaid: it now returns true only after a repayment was bookedtotalDebtRepaid != 0). Without a price set, or when the principal rounds down to zero, any repayment reverts, so the debt can never count as repaid. With that check in place, enabling repayments before the price is set is harmless: claims run on an empty ledger and nothing is burned. We did not add the price check totoggleDebtRepayment, to keep the diff small.”
DTO Debt Can Be Repaid in a Lower-Valued Payment Token
The debt of a DTO7943 is tracked by the PaymentHandler as an abstract 18-decimal value. _getRemainingDebt derives the principal from pinnedCapitalSupply and the signed capitalPricePerToken, which the documentation describes as "the same unit as the escrow's prices". Since each escrow issuance is priced in its own payment token, the debt is implicitly denominated in the currency the DTO was raised in. That currency is not recorded anywhere.
However, the plain addDebtRepayment overload accepts any token on the handler's global allowlist, as checked by _validatePaymentToken, and books the amount received against the debt after only a decimal conversion. One unit of any allowlisted token therefore settles one unit of debt, regardless of its value. A borrower that raised in EURC can thus repay the principal and interest in USDC, at a discount equal to the EUR/USD exchange rate. Once the computed debt reaches zero, repayments are disabled and the final claim, which any address can trigger through claim, burns each holder's entire DTO balance. Holders receive less than the value they are owed, and the position recording the shortfall is destroyed. Since signed distributions and repayments add their payment token to the same global allowlist, any token approved for one client can later be used to settle the debt of every DTO on the handler.
Consider binding each DTO to a single repayment token and rejecting repayments in any other token. The token could be included in the signed DebtPriceReport or recorded at the first repayment. Alternatively, consider maintaining per-asset payment-token allowlists restricted to a single unit of account.
Update: Resolved in pull request #107. The team stated:
“Fixed. The signedDebtPriceReportnow includespaymentToken, andsetInitialCapitalPricestores it as the DTO's repayment token.addDebtRepaymentreverts withRepaymentTokenMismatchfor any other token, so the borrower cannot repay in a lower-valued token.DebtCapitalPriceSetnow also emits the payment token.”
Anyone Can Burn the Tokens Sold in a Raise on a Fully Repaid DTO
The DTO debt is computed on the pinnedCapitalSupply fixed at the first repayment, so once it is fully repaid, the remaining debt stays at zero regardless of later mints. Claims remain open, and when a holder's cursor reaches the last entry, _claimDebtRepay burns their whole balance, assuming it was all covered by the repaid principal.
However, the DTO remains mintable after repayment. _newIssuance does not check the DTO's debt state, and the borrower keeps MINTER_ROLE. As a result, the borrower can open a new raise. Once it finalizes, the borrower receives the proceeds and the escrow pre-mints the allocations. Since none of these tokens are covered by the pinned principal, anyone can then call claim(dto, 0, investor) to burn a redeemed investor's balance for nothing. This also burns any tokens a previous holder bought in the new raise. Alternatively, anyone can call claim(dto, 0, escrow) to burn the unredeemed allocations, which makes getTokens revert. Moreover, the repayment toggle closed automatically at the final repayment, and even if it is reopened, _pinCapitalSupply rejects any repayment while the supply differs from the pin. Thus, these investors cannot be repaid on-chain and lose both their tokens and their payment.
Consider treating full repayment as a terminal state for the DTO by preventing new issuances and mints once its debt is repaid. Alternatively, consider limiting the final burn to the balance the holder had at the last repayment entry.
Update: Resolved in pull request #75. The team stated:
“Fixed with the second recommendation. The final burn is capped at min(balanceOf(holder), getPastBalance(holder, lastEntry.timestamp)), the same snapshot the payouts use. An address with no balance at the last entry never loses tokens, and the total burned can never exceed the pinned principal, so nobody can burn a position that the repayments did not cover. Two limits remain, and we accept them: - The cap is per address, because the token is fungible. An address that transfers its covered tokens out after the last entry and then receives new tokens can have up to its snapshot balance burned. Holders who claim before they transfer are not affected. - Tokens minted after the principal pin have no on-chain repayment path. Each DTO supports one repayment cycle (N-04). The backend does not open an escrow issuance for a DTO with a pinned principal, and a new raise uses a new DTO. We did not make full repayment a terminal state in the token, because that adds a dependency from the DTO to the payment handler on every mint.”Low Severity
OffchainReport Does Not Bind the Deployed TokenizationConfig
FactoryManager.newTokenization requires an OffchainReport signed by a FACTORY_OFFCHAIN_REPORTER_ROLE holder, but the signed payload only covers fee fields. The token is deployed from a separate, unsigned TokenizationConfig, so the issuer or spender can submit any configuration, despite the caller restriction comment claiming to prevent a "swapped config".
For example, a borrower can deploy a DTO7943 with a lower debtInterestRate (or 0), which the PaymentHandler reads from the token when computing the remaining debt. This is mitigated by the rate being visible on-chain and by Brickken having to grant per-token escrow and handler roles.
Consider including the reviewed token parameters in the signed report, or verifying them before granting roles, and correcting the comment.
Update: Resolved in pull request #77. The team stated:
“Fixed.OffchainReportnow carriesconfigHash = keccak256(abi.encode(config)), and it is part of the EIP-712 typehash.newTokenizationreverts withTokenizationConfigMismatchunless the submitted config hashes to the signed value. The issuer can no longer deploy a config the backend did not approve, for example a DTO withdebtInterestRate = 0. The misleading comment about a "swapped config" is fixed: the caller restriction only stops a third party from using someone else's report and fee.”
Inconsistent Receive Whitelist Enforcement on Payment Claims
The PaymentHandler exposes two claim paths. claim can be called by anyone on behalf of a holder and requires the holder to pass canReceive on the asset. In contrast, claimDebtRepayment lets a DTO holder claim for itself without that check. As a result, a DTO holder removed from the receive whitelist can still collect its debt repayments, so the check does not restrict DTO payouts. For STO tokens, claim is the only path. If a holder is removed from the receive whitelist, its dividend share remains reserved in the handler. It cannot be claimed or released until the issuer whitelists the holder again. This lets the issuer withhold already funded dividends from specific holders indefinitely. This is inconsistent with the escrow's stated principle that the whitelist gates the issued token and not the investor's money.
Consider applying a single policy to both claim paths, either by enforcing canReceive in both or by removing it from payouts altogether, and documenting the chosen behavior.
Update: Resolved in pull request #78. The team stated:
“Fixed by removing thecanReceivecheck fromclaim, so both payout paths follow one policy. The asset whitelist decides who may hold the security token. It does not gate payouts the holder already earned from past balances. A de-whitelisted holder can now claim funded dividends and debt repayments without the issuer whitelisting them again. This supersedes the earlier gate added for C-2026-01998. Docs are updated.”
Blacklisted Spenders Can Still Move Tokens Through Existing Allowances in StableERC20
The StableERC20 contract is documented as a "USDC-style" ERC-20 with a blacklist. However, the blacklist is only enforced in _update on the from and to addresses, while transferFrom and approve are inherited unchanged and never check the spender. As a result, a blacklisted address can keep spending any allowance it holds and can be granted new ones. It can use these allowances to move tokens from other holders to any non-blacklisted recipient. This defeats the purpose of blacklisting a sanctioned or compromised spender, such as an operator holding unlimited approvals. This behavior diverges from USDC, where blacklisted addresses can neither spend nor receive allowances.
Consider extending the blacklist checks to the spender of allowance-based transfers and to the parties of an approval.
Update: Resolved in pull request #79. The team stated:
“Fixed.StableERC20now overrides_approveto reject a blacklisted ownerERC20InvalidApprover) or spenderERC20InvalidSpender), and_spendAllowanceto reject a blacklisted spender. The second override is needed because OpenZeppelin skips_approvewhen spending an infinite allowance. A blacklisted address can no longer grant, receive or use an allowance, which matches USDC.”
A Payment Token That Rejects a Holder Blocks All of the Holder's Later Payments
The PaymentLedger records STO dividends and DTO repayments for a tokenized asset as a single list of entries, each of which can use a different payment token. It tracks each holder's progress with a single claim cursor. _settleClaims always starts at that cursor and transfers every non-zero share in order, so the whole claim reverts if any transfer fails.
If a payment token blocks transfers to a holder, such as through a USDC-style or StableERC20 blacklist, all their later payments for that asset become unclaimable. This includes payments in other tokens and lasts until the holder is unblocked or the handler is upgraded. For DTOs, this also blocks their final burn, and a token-wide pause affects every holder.
Consider ensuring that a payment that cannot be delivered does not prevent the settlement of unrelated entries.
Update: Resolved in pull request #118. The team stated:
“Fixed._settleClaims()now sends each share withtrySafeTransfer()instead ofsafeTransfer(). If the payment token refuses the transfer, the share goes to a newunpaid[holder][paymentToken]mapping in theLedger,UnpaidPaymentUpdatedis emitted, and the claim continues with the next entry. The cursor still advances, so the holder's later entries, in any token, are paid normally, and the DTO final burn still runs. At the start of each claim,_settleClaims()retries every non-zerounpaidamount overpaymentTokenList, so the holder gets it once the token unblocks them.”
Partial Withdrawals Charge the Fee on Off-Chain Contributions to On-Chain Investors
The fee is computed on the full raisedAmount, including off-chain contributions, but can only be collected from on-chain deposits. Each partialWithdraw thus charges amount * remainingFee / onchainAvailable, so in a mostly off-chain raise the effective rate can far exceed the nominal fee. The withdrawn amount is then booked gross in partialWithdrawn, and on an adminCancel, _refundToken refunds pro-rata on collected - partialWithdrawn without returning the fee.
Consider holding fees in the escrow until a successful finalization, or charging each withdrawal only the fee on its own amount.
Update: Acknowledged, not resolved. The team stated:
“Acknowledged inuniversal-escrow.md,protocol.mdandaudit-handoff.md. The fee is calculated on the whole raise, on-chain and off-chain, and it is collected from the on-chain funds on purpose, so that a raise reported mostly off-chain still pays its full fee on-chain. Before this design, issuers could raise off-chain and close the issuance without paying any fee. adminCancel after a partial withdrawal is only used in extreme cases. In that case, the fee already taken is settled off-protocol.”
Factory Admin Rotation Does Not Apply to Newly Deployed Tokens
Every token deployed by FactoryManager assigns the DEFAULT_ADMIN_ROLE to factoryAdmin. Only this account can rotate the issuer, authorize the DTO payment handler, and recover blocked escrow allocations. However, this address is stored once during the first initialization and cannot be updated afterwards. If Brickken moves the factory's DEFAULT_ADMIN_ROLE to a new address, every token deployed afterwards is still governed by the old one. If the old address is retired, these tokens permanently lose their governance because tokens are not upgradeable. If the old address was compromised, its holder retains full control of these tokens.
Consider making the token administrator updatable by the factory's current admin, and documenting that existing tokens must be rotated individually.
Update: Resolved in pull request #102. The team stated:
“Fixed. The factory no longer gives its own admin DEFAULT_ADMIN_ROLE on new tokens. newTokenization now takes the token admin from a new TokenizationConfig.admin field and reverts on address(0). Each token is owned by the admin chosen for that tokenization, not by the protocol, so a rotation of the factory admin has nothing to propagate. factoryAdmin is now only used as the first-initialization flag in initialize. It has no setter, and if it ever needs to change, a factory upgrade can do it.”
Sequential Per-Signer Nonces Are Shared Across Clients
The SignatureAuth contract keeps one sequential nonce per signer and purpose, and _verify only accepts the current one. The signer is a shared backend key, not the client. For instance, a factory report is signed by a FACTORY_OFFCHAIN_REPORTER_ROLE holder but submitted by the issuer or spender whenever they choose. Escrow, handler, and debt price authorizations follow the same pattern.
As a result, a signature that one client never submits, or submits late, blocks all later signatures from that signer for every other client until the backend re-signs them.
Consider using unordered nonces (such as a Permit2-style bitmap or EIP-3009-style random bytes32 nonces), or keying the sequence by signer and subject so that clients cannot block each other.
Update: Acknowledged, not resolved. The team stated:
“Acknowledged in protocol.md. Sequential per-signer nonces are intended: they give a strict order and simple replay protection without extra on-chain state. The backend handles the queue. It rotates several funded signer addresses per network, and each has its own nonce sequence for each purpose. A backend service uses an indexer to check each signer's balance and pending nonce, and assigns new payloads to a free signer based on the network load. So a signature that a client never submits blocks only that signer's sequence, not the others. The backend then re-signs the queued payloads for that signer. No funds are at risk, because an unused signature only delays the payloads behind it.”Push-Based Fee Distribution Allows a Non-Receivable Recipient to Block Raise Withdrawals
When raised funds leave the escrow, _partialWithdraw calls distribute on the FeeManager, which transfers each fee share to every Brickken and partner recipient in the same transaction. Both partialWithdraw and finalizeIssuance use this path whenever a fee is due.
If any recipient cannot receive the payment token, for example because it is on the blacklist of a USDC-style token, the entire withdrawal reverts. Until the recipient list is updated, the issuer cannot withdraw or finalize the issuance, and investors can neither redeem their tokens nor obtain a refund. Recovery requires either the partner to update its recipients through setPartnerConfig or the Brickken admins to change the fee configuration.
Consider decoupling fee payment from the withdrawal flow, for example by crediting each share to a balance that recipients claim separately. Alternatively, catch failed transfers and credit the share as claimable.
Update: Acknowledged, not resolved. The team stated:
“Acknowledgedfee-manager.md. The revert is intended: a recipient that cannot receive the payment token should not be paid, and skipping it would break the fee split between recipients. The revert also catches other misconfigurations, such as a missing allowance. To unblock, the partner updates its recipients withsetPartnerConfig(), or the fee admin usessetBrickkenConfig()orsetBrickkenFee(token, 10_000).”
Issuer Rotation Revokes the Escrow's MINTER_ROLE and Blocks Live Issuances
The changeIssuer and changeBorrower functions of the STO7943 and DTO7943 contracts revoke every member of each rotated role, including MINTER_ROLE. The escrow needs this role to pass the _requireDeliverable check of newIssuance, partialWithdraw, and finalizeIssuance.
As a result, rotating the issuer of a token with a live issuance makes these calls revert with TokenNotDeliverable. They revert until the new issuer re-grants the role to the escrow. This step is neither signaled on-chain nor documented. By contrast, BURN_FROM_ROLE is deliberately excluded from the purge to preserve the payment handler's authority.
Consider preserving the escrow's MINTER_ROLE across issuer rotations.
Update: Resolved in pull request #81 at commit 6f7d684. The team stated:
“MINTER_ROLEis no longer purged on rotation._rotateIssuermoves it from the outgoing holder to the incoming one only, so the escrow keeps it and live issuances settle without a new grant.MINTER_ADMIN_ROLEstill rotates, so the new issuer controls the minter set and can revoke any minter appointed by the previous issuer. All other operational roles are still purged.”
De-Whitelisted Participants Lose Both Their Deposit and Their Tokens
On a successful issuance, the _withdraw function of the EscrowSettlement contract releases every on-chain deposit to the issuer. Participants can then only redeem their tokens to their recorded address, which must pass canReceive.
If the issuer de-whitelists a paid participant, for example after a failed KYC check, the deposit is still released but the tokens cannot be delivered. The WITHDRAWN state has no refund branch, and the DEFAULT_ADMIN_ROLE bypass fails on the token's own canReceive check. The allocation can only be moved out-of-band, through withdrawExcessToken or forcedTransfer, to another whitelisted address. This contradicts the documented intent that "no role can block one investor's refund". The issuer's whitelist role leaves the investor with no on-chain way to recover their funds.
Consider providing a refund path for participants who can no longer receive the issued token.
Update: Acknowledged, not resolved. The team stated:
“Acknowledged inaudit-handoff.md,protocol.md,universal-escrow.mdand this is intended. A participant is de-whitelisted after a successful raise only for a compliance or legal reason, such as a failed KYC check or a dispute. The escrow must not deliver a security token to an investor who is not allowed to hold it. The allocation stays recorded, and the investor redeems it throughgetTokensonce they are whitelisted again, for example after legal clearance. A refund is not possible onWITHDRAWN, because the deposit has already gone to the issuer. "No role can block a refund" applies toROLLBACKandCANCELLED, where refunds never check the whitelist.”
Off-Chain Reports Have No Partial Fill or Reserved Capacity
The offchainReporting function of the EscrowSettlement contract books tickets that investors have already paid off-chain. Each entry must fit within maxTicket and entirely in the remaining hard cap, and a single failing entry reverts the whole batch. In contrast, the buyToken function caps the accepted amount to the remaining max ticket and the remaining hard cap. The escrow documentation states that off-chain reports apply the "same ticket, cap and allocatedTokens supply checks" as buyToken, which does not match this behavior.
Since no capacity is reserved for confirmed off-chain payments, an on-chain purchase executed before the manager's report can consume the remaining capacity. The report then reverts with the OffchainAmountExceedsAvailable error. If the cap is fully filled, it instead reverts with the HardCapReached error. Every other entry of the batch is rejected along with it. The manager has to resubmit the batch with a reduced amount for the affected investor and settle the unallocated part off-chain. Raising the hard cap through patchIssuance is possible, but it is a manual step that races with on-chain buyers in the same way.
Consider processing entries independently, so that an entry exceeding the remaining capacity or maxTicket is skipped and reported through an event instead of reverting the batch. Alternatively, consider allowing the manager to reserve capacity for confirmed off-chain payments. In any case, consider aligning the documentation with the chosen behavior.
Update: Acknowledged, not resolved. More documentation was added in pull request #101 at commit d6bc3bd. The team stated:
“Acknowledged, no logic change. Off-chain reports come from the trusted escrow manager, who controls the batch contents. All-or-nothing keeps bank-wire records exactly as reported, with no silent partial credit. The docs now state that a batch reverts as a wholeOffchainAmountExceedsAvailable,BelowMinTicket,ExceedsMaxTicket,UserNotWhitelisted) and does not trim likebuyToken. They also give the operator procedure: read the remaining capacity again, reduce or remove entries, and resubmit.”
Off-Book Settlements Leave Stale Claims That Are Re-Served From the Pooled Escrow Balance
On a successful raise, finalizeIssuance pre-mints the sum of all allocations to the escrow. _redeemToken later transfers each allocation out of the escrow's single issued-token balance, which is shared by every issuance of that token. getTokens is permissionless, has no deadline, and is the only path that sets the redeemed flag.
The documentation describes two operator procedures that move pre-minted allocations out of the escrow without updating the participant record. These are the withdrawExcessToken sweep of "never-claimed allocations" and the forcedTransfer recovery of an escrow blocked by the issuer. The participant still reads as unredeemed. Once the escrow holds a balance again, for example after a later issuance of the same token, anyone can call getTokens for them. The allocation is then paid a second time out of other participants' tokens. The same applies to a refund settled off-book, which is paid from the shared payment-token balance that backs other issuances, possibly of other issuers.
Consider recording every off-escrow delivery or refund in the participant's records. Alternatively, consider documenting a recovery that restores the escrow's deliverability, so that allocations are delivered through getTokens instead of being moved off-book.
Update: Acknowledged, not resolved. The team stated:
“Fixed in the docs. The operator docs no longer describe off-book recovery withforcedTransferor sweeping never-claimed allocations withwithdrawExcessToken. They now give a deliverability recovery procedure: restore the participant'scanReceive, or the escrow'scanSendor frozen state, and then deliver throughgetTokens. The participant record is markedredeemed, so the pooled balance cannot serve the claim twice.”
Notes & Additional Information
Backend Cannot Manage FeeManager Partner Roles Contrary to Documented Design
The initialize function of FeeManager documents that the backend wallet, which holds FEE_MANAGER_ADMIN_ROLE, can grant partner roles without a multisig transaction. However, the token-scoped partner role checked by onlyPartnerManager has no role admin and no token-scoped grant surface, so only DEFAULT_ADMIN_ROLE (the multisig) can grant or revoke it. As a result, every partner onboarding and offboarding requires a multisig transaction. This is inconsistent with UniversalEscrowUpgradeable and PaymentHandler, whose canManageTokenRole lets the backend manage token-scoped roles.
Consider aligning the implementation of partner role management with its documentation.
Update: Resolved in pull request #95. The team stated:
“Fixed. The partner role's admin isDEFAULT_ADMIN_ROLE, so only the multisig grants or revokes it. The backend holdsFEE_MANAGER_ADMIN_ROLEonly and cannot manage partners. This is intended, so no new role was added. TheinitializeNatSpec,fee-manager.mdand the audit handoff now state this.”
Issuance Ticket Bounds Are Not Validated Against the Hard Cap and Existing Allocations
The _validateIssuance function of the EscrowIssuance contract, used by both newIssuance and patchIssuance, only checks that minTicket does not exceed maxTicket. It does not compare the ticket bounds with the hard cap or with the amounts participants already hold, which leads to the following issues:
minTicketabovehardCap: a first purchase is trimmed to the room left under the hard cap before the minimum is checked, and off-chain reports are bounded by the same room. Consequently, no new investor can ever join. An issuance created this way can only roll back, and one patched this way during a sale is closed to new investors.maxTicketbelow an existing allocation:_validateBuyInputscomputesissuance.maxTicket - existing, which underflows. Every later on-chain purchase on behalf of that participant reverts withPanic(0x11)instead ofExceedsMaxTicket. In contrast,_recordOffchainEntrycomparesexisting + valueagainstmaxTicketand reverts with the descriptive error.
In addition, patchIssuance treats a zero value as "keep the current value" for every field, while a zero minTicket or maxTicket means "no limit". As a result, once a ticket bound has been set, it can never be removed. Relaxing it mid-sale requires workarounds such as setting maxTicket to the hard cap.
Consider requiring minTicket to be no greater than hardCap in _validateIssuance, and reverting with ExceedsMaxTicket in _validateBuyInputs when existing reaches a non-zero maxTicket. In addition, consider using a distinct sentinel for "keep the current value" in patchIssuance.
Update: Resolved in pull request #83. The team stated:
“Fixed._validateIssuancerequiresminTicket <= hardCap, andbuyTokenreverts withExceedsMaxTicketinstead ofPanic(0x11)whenmaxTicketis below the participant's existing amount.”
Finalizer Role Implicitly Grants Withdrawal Authority
The UniversalEscrow issuer can independently grant the finalizer (ESCROW_ISSUANCE_FINALIZER_ROLE) and withdraw (ESCROW_WITHDRAW_ROLE) roles to any account through grantTokenRole. However, on a successful issuance, finalizeIssuance sends the remaining proceeds to a caller-supplied withdrawTo address without requiring the withdraw role. As such, a finalizer-only account can redirect the remaining funds, which defeats the purpose of separating the two roles.
Consider aligning the finalizer role's permissions with its intended scope.
Update: Acknowledged, not resolved. The team stated:
“Acknowledged in universal-escrow.md. This is intended. ESCROW_ISSUANCE_FINALIZER_ROLE is broader than ESCROW_WITHDRAW_ROLE: a successful finalize changes the issuance state, opens redemption, and withdraws the remaining proceeds. Plus withdrawTo is only the recipient of the funds, so it does not need to hold ESCROW_WITHDRAW_ROLE. That role gates who can call partialWithdraw, not who receives funds. See pull request #85.”DTO Repayment Cycle Cannot Be Repeated Despite Documentation Implying Otherwise
The documentation states that DTO tranches should be minted "only between cycles", implying that several repayment cycles are supported. However, the principal is pinned permanently at the first repayment. Neither the repaid totals nor the one-time capital price is ever reset. As a result, each DTO supports exactly one repayment cycle. In addition, nothing prevents a new UniversalEscrow issuance of a DTO after the pin. Its allocation would either block further repayments with CapitalSupplyChanged or never be repayable on-chain.
Consider documenting that each DTO supports a single repayment cycle, and preventing new issuances of a DTO once its principal has been pinned.
Update: Acknowledged, not resolved. The team stated:
“Acknowledged. Each DTO supports a single repayment cycle by design: the principal is pinned at the first repayment and never resets. The documentation now describes the single-cycle model. New escrow issuances for a DTO with a pinned principal are blocked by the backend. A new raise uses a new DTO.”
Missing Docstrings
Many public contracts, functions, and constants have no NatSpec. Examples include:
- The view getters in
Factory,FeeManager, andPaymentHandler. - The
deployandgetTokenTypesfunctions of the three token deployers. - The
BasicERC20,StableERC20, andERC7943contracts. - Several
DTO7943andSTO7943members, including bothtokenizationTypefunctions. - Every constant in the
ERC7943Roleslibrary.
In addition, the docstring for EscrowStorage.AUTHORIZE_ISSUANCE_TYPEHASH is misplaced above ISSUANCE_AUTH_PURPOSE, and FactoryManager.setTokenDeployer is documented in IFactory but does not use @inheritdoc.
Consider documenting all elements of the public API following the NatSpec format, using @inheritdoc where an interface already provides accurate documentation.
Update: Resolved in pull request #96. The team stated:
“Fixed. All listed functions, contracts and constants now have NatSpec. Implementations use@inheritdocwhere an interface declares the function, and interfaces carry the full@notice/@param/@returndocs. TheAUTHORIZE_ISSUANCE_TYPEHASHdoc now sits on its constant, andFactoryManager.setTokenDeployeruses@inheritdoc IFactory.”
Unused Custom Errors
The UserIsNotCaller, PremintGreaterThanMaxSupply, InvalidFactory, InvalidFeeShares, and FeeOverLimits errors declared in Errors.sol are never used in the codebase.
Consider removing these errors to improve the clarity and maintainability of the codebase.
Update: Resolved in pull request #97. The team stated:
“Fixed. The five unused errors (UserIsNotCaller,PremintGreaterThanMaxSupply,InvalidFactory,InvalidFeeShares,FeeOverLimits) are removed fromErrors.sol.”
Nonexistent Issuances Are Reported as ACTIVE and Accepted by State-Changing Functions
Issuances are numbered from 1 and the first member of IssuanceStatus is ACTIVE. As a result, index 0 and every index above issuanceIndex[issuedToken] read as an active issuance with all other fields set to zero.
No function validates that the index exists. For such an index, isSuccess and isHardcapReached return true, while adminCancel and partialWithdraw succeed and emit events. If no fee manager is set, finalizeIssuance records a WITHDRAWN status for such an index. In addition, setIssuancePause accepts future indexes, and since _newIssuance does not reset issuancePaused, an issuance created at a pre-paused index starts paused.
Consider requiring the issuance index to be non-zero and not greater than issuanceIndex[issuedToken] in the view functions and in every function that takes an issuance index. Since UniversalEscrow is deployed behind a proxy, adding a NONE member as the first value of IssuanceStatus should be avoided, as it would reinterpret every stored status.
Update: Acknowledged, not resolved. The team stated:
“Acknowledged inuniversal-escrow.md. An issuance that was never created, either index 0 or any index abovegetIssuanceIndex(), reads as all zeros, and its status showsACTIVEonly becauseACTIVEis 0. It holds no funds, andbuyToken()andoffchainReporting()revert on it withIssuanceEnded, because itsendDateis 0. Creating the issuance writes the whole struct, so any status set on the empty slot is reset. Integrators read the valid range fromgetIssuanceIndex(), and our backend tracks issuances through indexing.”
Incomplete Docstrings
Several public functions have only partial or inaccurate NatSpec:
Factory.getFees(andIFactory.getFees) describes bothamountToPayandsignerunder a single@returntag.Factory.noncesdoes not document itsuserparameter.PaymentHandler.addDebtRepaymentandEscrowSettlement.offchainReportinghave a one-line@devbut no@paramtags. The latter is fully documented inIUniversalEscrowbut does not use@inheritdoc.UniversalEscrowUpgradeable.versionlacks a@returntag and carries a stale@devline about an EIP-712 domain separator.- The NatSpec of
EscrowSettlement.withdrawExcessTokenstill lists "pre-mint dust" among the balances it rescues, although_withdrawnow pre-mints exactly the sum of the allocations.
Consider completing and correcting these docstrings, and using @inheritdoc wherever the interface already documents the function.
Update: Resolved in pull request #98. The team stated:
“Fixed.getFeeshas one@returnper value,noncesdocuments its parameter and return,addDebtRepaymentandoffchainReportinghave full@paramtags,versionhas a@returnand the stale@devis removed. ThewithdrawExcessTokendocs no longer mention pre-mint dust or unclaimed allocations: the function withdraws only the balance above what the escrow owes.”
Use calldata Instead of memory
When dealing with the parameters of external functions, it is more gas-efficient to read their arguments directly from calldata instead of copying them to memory. In FactoryManager.sol, the _tokenDeployers parameter of the external initialize function is declared as memory even though it is only read.
Consider using calldata as the data location for read-only parameters of external functions to optimize gas usage.
Update: Resolved in pull request #99.
Hard Cap and Off-Chain Amounts Are Not Validated Against Payment Token Decimals
The _validateIssuance function of the EscrowIssuance contract does not require hardCap to be a whole number of payment-token units. The _recordOffchainEntry function of the EscrowSettlement contract books the reported 18-decimal value as is. On low-decimal payment tokens, either input leaves a remaining capacity below one payment-token unit once the next purchase is capped. From then on, every purchase reverts with the CapBelowPaymentTokenUnit error, the hard cap cannot be reached on-chain, and amountAvailable reports capacity that cannot be bought.
Consider requiring hardCap and off-chain amounts to be multiples of the payment token's unit.
Update: Resolved in pull request #94. The team stated:
“Fixed. The NatSpec ofhardCapand of theoffchainReporting()amounts now states that they are 18-dec values and must be multiples of one payment-token unit. Our backend enters these values in the payment token's own decimals and scales them to 18 decimals, so they never carry dust.”
Purchase Trimming Uses Zero as an Implicit Sentinel
The _validateBuyInputs function of the EscrowSettlement contract returns the purchase amount trimmed to fit the maximum ticket and the hard cap. A returned zero means "no trim", and the _executeBuy function falls back to the full requested amount. As a result, a trim that genuinely computes to zero must be rejected explicitly, as done in the maximum-ticket branch and in the conversion to native units. The hard-cap branch, however, skips the trim when no capacity remains instead of reverting. Purchases above the hard cap are therefore only prevented by the _requireOpen check performed by the caller, which makes the purchase path harder to follow and verify.
Consider returning the accepted amount explicitly instead of relying on zero as a sentinel, and enforcing the hard cap within the validation itself.
Update: Acknowledged, not resolved. The team stated:
“Acknowledged._requireOpenalready blocks any purchase onceraisedAmountreaches the hard cap, so a trimmed amount of zero never reaches_executeBuy.”
Protocol Documentation Contradicts the Implementation
Several parts of the documentation describe behavior that differs from the code:
- The fee model claims it "never over-collects" after a rate cut, but fees already taken at the previous rate are kept.
getTokensis described as minting allocations, but it transfers tokens that were pre-minted at finalization.- Refunds are described as returned to the depositing address, but deposits are credited to
onBehalfOfand refunded to it, so a third party that funds a purchase cannot recover the funds, and a beneficiary contract that cannot move the payment token strands them. - The token section states that there is "no supply cap" and that
supplyCapis unenforced, whileERC7943enforcesmaxSupply. - The DTO formulas in
protocol.mdandpayment-handler.mdcompute interest on the remaining capital, while the code charges it on the full principal and uses the live supply until the principal is pinned. upTois described as a count of entries, but it is an absolute end index.lastClaimedPaymentIndexis described as the last claimed index, but it is the next unclaimed one.FeeManagerupgrades are attributed toFEE_MANAGER_ADMIN_ROLE, but_authorizeUpgraderequiresDEFAULT_ADMIN_ROLE.- The docs (1, 2) state that a tokenization type with no deployer records
address(0)and is still charged the fee, but the factory reverts withNoDeployerConfigured. PaymentHandler.initializeis documented with one argument, but it takesadminandmanager.CheckpointBalanceChangedis described as emitted on mint and burn, but it is only emitted on transfers.
Consider updating the documentation to match the implementation.
Update: Resolved in pull request #100. The team stated:
“Fixed. All listed statements indocs/now match the code: the fee after a rate cut,getTokenstransfers, refunds go toonBehalfOf, themaxSupplycap, the interest formula on the full principal,upToas an absolute end index,lastClaimedPaymentIndexas the next unclaimed index, the FeeManager upgrade role,NoDeployerConfigured, thePaymentHandler.initializearguments andCheckpointBalanceChangedon transfers only.”
Conclusion
Brickken Protocol v2 is a real-world asset tokenization system that lets issuers create compliance-controlled security tokens, sell them through a shared escrow, and pay holders back through dividends or debt repayments. OpenZeppelin audited the factory, the security tokens, the universal escrow, the payment handler, the fee manager, and the shared utilities that support them.
The codebase is compact and the shared contracts follow common patterns, such as namespaced storage, role-based access control, and signed authorizations. However, the decision to serve all clients from one set of shared contracts means that a single issue can affect every client. The issues identified mainly relate to how issuers, investors, and third parties interact with tokens held by the escrow, to the handling of debt token repayments and burns, and to the ways that shared signature nonces, fee recipients, and payment-token allowlists allow one party to block or affect others.
The Brickken team is appreciated for being responsive throughout the engagement and for sharing documentation that described the intended behavior of the protocol.
Appendix
Issue Classification
OpenZeppelin classifies smart contract vulnerabilities on a 5-level scale:
- Critical
- High
- Medium
- Low
- Note/Information
Critical Severity
This classification is applied when the issue’s impact is catastrophic, threatening extensive damage to the client's reputation and/or causing severe financial loss to the client or users. The likelihood of exploitation can be high, warranting a swift response. Critical issues typically involve significant risks such as the permanent loss or locking of a large volume of users' sensitive assets or the failure of core system functionalities without viable mitigations. These issues demand immediate attention due to their potential to compromise system integrity or user trust significantly.
High Severity
These issues are characterized by the potential to substantially impact the client’s reputation and/or result in considerable financial losses. The likelihood of exploitation is significant, warranting a swift response. Such issues might include temporary loss or locking of a significant number of users' sensitive assets or disruptions to critical system functionalities, albeit with potential, yet limited, mitigations available. The emphasis is on the significant but not always catastrophic effects on system operation or asset security, necessitating prompt and effective remediation.
Medium Severity
Issues classified as being of medium severity can lead to a noticeable negative impact on the client's reputation and/or moderate financial losses. Such issues, if left unattended, have a moderate likelihood of being exploited or may cause unwanted side effects in the system. These issues are typically confined to a smaller subset of users' sensitive assets or might involve deviations from the specified system design that, while not directly financial in nature, compromise system integrity or user experience. The focus here is on issues that pose a real but contained risk, warranting timely attention to prevent escalation.
Low Severity
Low-severity issues are those that have a low impact on the client's operations and/or reputation. These issues may represent minor risks or inefficiencies to the client's specific business model. They are identified as areas for improvement that, while not urgent, could enhance the security and quality of the codebase if addressed.
Notes & Additional Information Severity
This category is reserved for issues that, despite having a minimal impact, are still important to resolve. Addressing these issues contributes to the overall security posture and code quality improvement but does not require immediate action. It reflects a commitment to maintaining high standards and continuous improvement, even in areas that do not pose immediate risks.