Back to Blog

#5:鸭嘴兽金融:幸运之神的眷顾,三次攻击后幸存

February 15, 2024

摘要

Platypus Finance 是一个基于 Avalanche 区块链的 AMM 协议。它曾遭受三次攻击,具体如下:

  • 2023年2月17日,由于错误的偿付能力检查,协议遭遇黑客攻击,总损失约905万美元。其中,在BlockSec的协助下,挽回了240万美元。大约38万枚代币被困在Aave合约中,随后被归还。
  • 2023年7月12日,由于忽视了稳定币之间的价格差异,协议被黑客攻击,损失约5万美元。
  • 2023年10月12日,协议遭受价格操纵攻击,损失约220万美元。在与攻击者协商后,90%的被盗资金被归还。

项目能够从所有这些攻击中幸存下来,实属幸运。我们对这三次漏洞利用的分析表明,如果进行仔细的审计或采取更积极的安全措施,就可以避免这些逻辑缺陷。

攻击一

要理解此次安全事件,必须了解几个智能合约的工作流程。大致流程如下:

  • 用户可以将代币存入池中成为 LP,并获得 LP 代币。
  • LP 代币可以质押在 MasterPlatypus 中以获得奖励。在此过程中,LP 代币将被转移到 MasterPlatypus 合约。
  • LP 代币可以用作抵押品来借入其他资产,以提高资产效率。

下图展示了交互过程。

漏洞分析

漏洞存在于 MasterPlatypus 合约中的 emergencyWithdraw 函数。在紧急情况下,此函数应用于从 MasterPlatypus 合约中提取质押的 LP 代币。在该函数中,合约会检查用户是否“有偿付能力”(Solvent)以允许提款。该逻辑检查用户是否欠有不良债务(即抵押品是否足以偿还债务)。如果不存在不良债务,用户就可以提取质押的 LP 代币。

然而,该逻辑存在缺陷。用户“有偿付能力”仅意味着用户的抵押品可以支付其债务。但这会检查用户在紧急提取质押代币后是否仍然“有偿付能力”。攻击者可以利用此缺陷借入资产,然后紧急提取质押的 LP 代币(而不偿还债务)。请参阅 Immunefi 博客上的详细分析

攻击分析

我们以一次攻击交易为例,展示整个攻击过程。

步骤1:从AAVE借款4400万USDC闪电贷

步骤2:将4400万USDC存入池中以获得LP-USDC

步骤3:将LP-USDC存入MasterPlatypus

步骤4:使用LP-USDC作为抵押品借入USP

步骤5:执行emergencyWithdraw函数发动攻击

攻击者在未偿还USP债务的情况下获得了LP-USDC。

步骤6:从池中提取LP-USDC以获得USDC

步骤7:出售USP获利

然而,利润留在了攻击合约中。事实上,攻击者可以设置一个新的接收地址来完成兑换并获取利润。

BlockSec的救援

我们发现攻击者将利润留在了攻击合约中。此外,攻击合约中没有提取资产的逻辑。然而,我们在攻击合约中发现了一个漏洞,可以利用该漏洞进行反向攻击以提取合约内的一部分资产。

具体来说,闪电贷回调函数存在访问控制,这意味着任何人都可以调用此回调函数。这也是许多 MEV 机器人遭受攻击的根本原因。

此外,在回调函数中,攻击者合约将USDC代币授权给了Platypus Finance池合约。而该池合约是可升级的!

结合以上两点,我们可以通过以下方式从攻击合约中救援USDC:

  • 升级Platypus Finance池合约,加入从合约内提取USDC的逻辑。
  • 调用攻击合约的回调函数,将USDC授权给池合约。
  • 池合约可以替换任何(将被攻击合约执行的)函数,将USDC从攻击合约转移出来(因为攻击合约已将USDC授权给池合约)。

以下是救援240万美元USDC的交易

其他两次攻击

有关另外两次攻击的更多详情,请参阅以下链接:

  • 攻击二:2023年7月11日,协议假设USDC和USDT之间的比率为1:1,这偏离了市场波动,导致提款逻辑存在缺陷。一次攻击交易链接。还有一些其他的攻击交易。
  • 攻击三:2023年10月12日,由于操纵的cash(现金)和liability(负债)影响了兑换价格。第一次攻击交易 | 第二次攻击交易

总结

这三次攻击利用了协议中不同的漏洞。尽管一些其他供应商已审计了该协议,但攻击者仍然发现了漏洞并成功地利用了它。幸运的是,一些资产得到了挽回,但我们不能指望每次都这么幸运。应该采取更多的安全措施,包括攻击监控和自动响应,以保护协议和用户资产。

阅读本系列中的其他文章:

Sign up for the latest updates
Tracing $1.6B in TRON USDT: Inside the VerilyHK Ponzi Infrastructure
Case Studies

Tracing $1.6B in TRON USDT: Inside the VerilyHK Ponzi Infrastructure

An on-chain investigation into VerilyHK, a fraudulent platform that moved $1.6B in TRON USDT through a multi-layered fund-routing infrastructure of rotating wallets, paired payout channels, and exchange exit funnels, with traced connections to the FinCEN-sanctioned Huione Group.

Weekly Web3 Security Incident Roundup | Mar 30 – Apr 5, 2026
Security Insights

Weekly Web3 Security Incident Roundup | Mar 30 – Apr 5, 2026

This BlockSec weekly security report covers nine DeFi attack incidents detected between March 30 and April 5, 2026, across Solana, BNB Chain, Arbitrum, and Polygon, with total estimated losses of approximately $287M. The week was dominated by the $285.3M Drift Protocol exploit on Solana, where attackers combined multisig signer social engineering with Solana's durable nonce mechanism to bypass a zero-timelock 2-of-5 Security Council, alongside notable incidents including a $950K flash loan TWAP manipulation against the LML staking protocol, a $359K Silo Finance vault inflation via an external `wstUSR` market donation exploiting a depegged-asset oracle and `totalAssets()` accounting flaw, and an EIP-7702 delegated-code access control failure. The report provides detailed vulnerability analysis and attack transaction breakdowns for each incident, covering flawed business logic, access control, price manipulation, phishing, and misconfiguration attack types.

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.