Back to Blog

重审CashioApp安全事件

Code Auditing
May 16, 2022
4 min read

于2022年3月23日16:20:08 UTC+8开始,CashioApp遭到利用,导致抵押品代币账户被耗尽,损失约5200万美元。此次攻击之所以能够成功,是因为对输入账户的检查不足,使得攻击者能够在没有任何存款的情况下铸造200亿枚$CASH代币。接下来,我们将展示技术细节。

摘要

此次事件是由于Brrr程序中的一个bug造成的,该程序旨在处理以Saber LP Arrows为抵押品的$CASH代币的铸造和销毁。具体来说,用户可以通过存入Arrow LP代币来打印$CASH,即铸造$CASH。请注意,Arrow LP代币接收Saber LP代币作为底层代币。print_cash指令(可用于铸造$CASH)接收一个账户列表,包括Bank账户和Collateral账户。这些账户用于记录和跟踪允许用于铸造$CASH的抵押品(即Arrow LP代币)。根据设计,这两个账户应仅由管理员初始化和授权。然而,该程序未能检查Bank账户的有效性。因此,攻击者可以构造一系列虚假账户(包括Bank账户)输入到print_cash指令中,几乎免费地打印$CASH(唯一成本是交易费用)。

详情

我们从下方print_cash指令使用的账户开始分析。

BrrrCommon结构中的common属性(第75行)是一个结构体。在BrrrCommon中,bank账户和collateral账户由管理员初始化和授权。crate_token$CASH代币的账户,存储关于$CASH的信息,例如crate_mint(第107行)的公钥、管理员角色的公钥等。crate_collateral_tokens是一个金库账户,持有用户转移的抵押品代币。由于抵押品应该是Arrow LP代币,而Arrow LP代币接收Saber的LP代币,因此用户需要输入相关的saber_swap账户。BrrrCommon结构中的最后两个属性是指令中使用的目标程序的程序ID。请注意,PrintCash结构中的最后四个属性是用户的系统账户(也是交易的签名者)、用户的抵押品账户、接收铸造的$CASH的用户$CASH代币账户,以及有权铸造$CASH的账户的公钥。

攻击交易

在理解了上述账户的功能后,我们开始分析攻击交易:0x4fgL…z2K5。此攻击由攻击者地址(位于0x6D7f)发起,PrintCash指令中的输入账户列表如下所示。

上文中的Account #10x5aha)对应于Bank账户。我们注意到它与CashioApp官方网站上提供的地址(0xEm1P)不同,这意味着Bank账户的验证不足!

验证

让我们仔细查看代码中BrrrCommon结构的验证,以弄清楚绕过是如何工作的。

对输入Bank账户的唯一检查是确保输入的Collateral账户与Bank账户相关联(第12行)。然而,通过提供一个虚假的Collateral账户也可以轻松绕过此检查。此外,为了避免支付真实的抵押品资产,攻击者还提供了虚假的saber_swap账户。请注意,攻击者的目标是存入无价值的抵押品资产以打印有价值的$CASH代币,因此攻击者提供的crate_tokencrate_mint应该是真实地址。换句话说,Bank账户的检查不足使得攻击者能够构造一系列虚假账户,以无价值的抵押品打印$CASH

修复

修复方法是添加assert_keys_eq!(self.bank.crate_mint, self.crate_mint)语句。该语句确保Bank账户的crate_mint$CASH的正确crate_mint。但是,它如何确保Bank账户有效呢?让我们查看(bankman程序中的)NewBank结构和(crate_token程序中的)NewCrate结构来找到答案。

实际上,Bank账户是一个PDA,其种子包含crate_token的地址。同时,crate_token也是一个PDA,其种子包含crate_mint的地址。这确保了如果输入的crate_mint有效,Bank账户就是有效的。如果没有正确的crate_mint,攻击者就无法铸造$CASH,也无法发起攻击。

关于BlockSec

BlockSec是一家开创性的区块链安全公司,由一群全球知名的安全专家于2021年创立。公司致力于增强新兴Web3世界的安全性和可用性,以促进其大规模采用。为此,BlockSec提供智能合约和EVM链安全审计服务,用于安全开发和主动威胁拦截的Phalcon平台,用于资金追踪和调查的MetaSleuth平台,以及供Web3构建者在加密世界中高效冲浪的MetaSuites扩展。

迄今为止,公司已为MetaMask、Uniswap Foundation、Compound、Forta和PancakeSwap等300多家尊贵客户提供服务,并获得了来自Matrix Partners、Vitalbridge Capital和Fenbushi Capital等知名投资者的两轮融资,总计数千万美元。

官方网站:https://blocksec.com/

官方Twitter账号:https://twitter.com/BlockSecTeam

Sign up for the latest updates
The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis
Security Insights

The Decentralization Dilemma: Cascading Risk and Emergency Power in the KelpDAO Crisis

This BlockSec deep-dive analyzes the KelpDAO $290M rsETH cross-chain bridge exploit (April 18, 2026), attributed to the Lazarus Group, tracing a causal chain across three layers: how a single-point DVN dependency enabled the attack, how DeFi composability cascaded the damage through Aave V3 lending markets to freeze WETH liquidity exceeding $6.7B across Ethereum, Arbitrum, Base, Mantle, and Linea, and how the crisis forced decentralized governance to exercise centralized emergency powers. The article examines three parameters that shaped the cascade's severity (LTV, pool depth, and cross-chain deployment count) and provides an exclusive technical breakdown of Arbitrum Security Council's forced state transition, an atomic contract upgrade that moved 30,766 ETH without the holder's signature.

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 13 – Apr 19, 2026

This BlockSec weekly security report covers four attack incidents detected between April 13 and April 19, 2026, across multiple chains such as Ethereum, Unichain, Arbitrum, and NEAR, with total estimated losses of approximately $310M. The highlighted incident is the $290M KelpDAO rsETH bridge exploit, where an attacker poisoned the RPC infrastructure of the sole LayerZero DVN to fabricate a cross-chain message, triggering a cascading WETH freeze across five chains and an Arbitrum Security Council forced state transition that raises questions about the actual trust boundaries of decentralized systems. Other incidents include a $242K MMR proof forgery on Hyperbridge, a $1.5M signed integer abuse on Dango, and an $18.4M circular swap path exploit on Rhea Finance's Burrowland protocol.

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Apr 6 – Apr 12, 2026

This BlockSec weekly security report covers four DeFi attack incidents detected between April 6 and April 12, 2026, across Linea, BNB Chain, Arbitrum, Optimism, Avalanche, and Base, with total estimated losses of approximately $928.6K. Notable incidents include a $517K approval-related exploit where a user mistakenly approved a permissionless SquidMulticall contract enabling arbitrary external calls, a $193K business logic flaw in the HB token's reward-settlement logic that allowed direct AMM reserve manipulation, a $165.6K exploit in Denaria's perpetual DEX caused by a rounding asymmetry compounded with an unsafe cast, and a $53K access control issue in XBITVault caused by an initialization-dependent check that failed open. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Best Security Auditor for Web3

Validate design, code, and business logic before launch. Aligned with the highest industry security standards.

BlockSec Audit