Back to Blog

重温 CashioApp 安全事件

Code Auditing
May 16, 2022

BlockSec 正在回顾 Cashio 应用安全事件

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

摘要

此次事件是由 Brrr 程序中的一个错误引起的,该程序旨在处理使用 Saber LP Arrows 作为抵押品的 $CASH 代币的铸造和销毁。具体来说,用户可以通过存入 Arrow LP 代币来打印 $CASH,即铸造 CASH。请注意,ArrowLP代币以[SaberLPtoken](https://app.saber.so/swap)作为底层代币。printcash指令(可以铸造CASH。请注意,Arrow LP 代币以 [Saber LP token](https://app.saber.so/swap) 作为底层代币。`print_cash` 指令(可以铸造 `CASH)接收一个账户列表,包括 Bank账户和Collateral账户。它们用于记录和跟踪允许用于铸造CASH的抵押品(即ArrowLP代币)。根据设计,这两个账户只能由管理员初始化和授权。然而,该程序未能检查Bank账户的有效性。因此,攻击者可以构造一系列虚假账户(包括Bank账户)来喂给printcash指令,从而几乎免费地打印CASH` 的抵押品(即 `Arrow` LP 代币)。根据设计,这两个账户只能由管理员初始化和授权。然而,该程序未能检查 `Bank` 账户的有效性。因此,攻击者可以构造一系列虚假账户(包括 `Bank` 账户)来喂给 `print_cash` 指令,从而几乎免费地打印 `CASH`(唯一的成本是交易费用)。

细节

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

common 属性(第 75 行)是一个结构体,在程序中其类型为 BrrrCommon。在 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 #1(上面的 0x5aha)对应于 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 是正确的 $CASHcrate_mint。但是,它如何确保 Bank 账户有效呢?让我们查看(bankman 程序中的)NewBank 结构体和(crate_token 程序中的)NewCrate 结构体来找到答案。

事实上,Bank 账户是一个 PDA,其 seed 包含 crate_token 的地址。同时,crate_token 也是一个 PDA,其 seed 包含 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
Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation
Security Insights

Drift Protocol Incident: Multisig Governance Compromise via Durable Nonce Exploitation

On April 1, 2026 (UTC), Drift Protocol on Solana suffered a $285.3M loss after an attacker exploited Solana's durable nonce mechanism to delay the execution of phished multisig approvals, ultimately transferring administrative control of the protocol's 2-of-5 Squads governance with zero timelock. With full admin privileges, the attacker created a malicious collateral market (CVT), inflated its oracle price, relaxed withdrawal protections, and drained USDC, JLP, SOL, cbBTC, and other assets through 31 rapid withdrawals in approximately 12 minutes. This incident highlights how durable nonce-based delayed execution can decouple signer intent from on-chain execution, bypassing the temporal assumptions that multisig security implicitly relies on.

Weekly Web3 Security Incident Roundup | Mar 23 – Mar 29, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 23 – Mar 29, 2026

This BlockSec weekly security report covers eight DeFi attack incidents detected between March 23 and March 29, 2026, across Ethereum and BNB Chain, with total estimated losses of approximately $1.53M. Incidents include a $679K flawed burn mechanism exploit on the BCE token, a $512K spot-price manipulation attack on Cyrus Finance's PancakeSwap V3 liquidity withdrawal, a $133.5K flash-loan-driven referral reward manipulation on a TUR staking contract, and multiple integer overflow, reentrancy, and accounting error vulnerabilities in DeFi protocols. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident.

Newsletter -  March 2026
Security Insights

Newsletter - March 2026

In March 2026, the DeFi ecosystem experienced three major security incidents. Resolv Protocol lost ~$80M due to compromised privileged infrastructure keys, BitcoinReserveOffering suffered ~$2.7M from a double-minting logic flaw, and Venus Protocol incurred ~$2.15M following a donation attack combined with market manipulation.

Best Security Auditor for Web3

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

BlockSec Audit