少存多得:yCREDIT 攻击详情

少存多得:yCREDIT 攻击详情

2021年1月2日(北京时间上午07:25),我们的监控系统ThunderForecast报告了一系列针对yCREDIT智能合约的可疑交易。随后,我们使用我们研究团队开发的EthScope系统分析了这些交易,并确认所有报告的交易均为恶意交易。在本篇博文中,我们将详细说明攻击细节。

细节

此次攻击源于铸造的代币数量与预期数量不符。因此,攻击者可以以较低的价格获得更多的yCREDIT代币,然后将这些代币出售以获利。

易受攻击的函数位于StableYieldCredit 合约_deposit 函数中。

接下来,我们将使用一个攻击交易来演示整个过程。

攻击者首先向WBTC-yCREDIT 对池转入了1e-8 WBTC331.335 yCredit代币。然后,攻击者向StableYieldCredit合约存入了0.5 WBTC以发动攻击。

具体来说,_value 是基于价格预言机提供商ChainLink(第480行,_value1466786010075)根据token(0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 - WBTC)的amount(0.5)计算得出的。其目的是计算存入的WBTC以美元计的价值。然后,合约将(_value - fee)数量的yCREDIT代币转给存入WBTC的人(即攻击者)。这是因为yCREDIT的价值等于一美元(正如系统所设计的)。一切正常,除了攻击者会损失少量的fee

此外,合约会将存入的WBTC添加到WBTC-yCREDIT 对池中。这是因为如果存入的WBTC被锁定在合约中,它将失去流动性。因此,它首先计算将放入池中的代币对(WBTC到yCREDIT)的价值。这个价值是使用_addLiquidity函数计算的。基本上,它是根据池中现有的储备计算的。由于池中只有1e-8 WBTC331.335 yCREDIT代币,计算出的amountA44amountB1466786010075)。这意味着攻击者仅花费了44e-8 WBTC(第485行),并获得了14667.86010075 - fee = 14594.52080025个yCREDIT代币(第493行)。同时,池中剩余少量的WBTC(1e-8 + 44e-8)和(331.335 + 14667.86010075)yCREDIT代币。

为了获利,攻击者只需在交易所交易获得的14594.52080025个yCREDIT代币即可。有趣的是,在此交易中获取利润的过程比必要情况复杂得多。我们也观察到了其他交易中一种巧妙的攻击策略。

此次攻击涉及一系列交易,包括(但不限于)以下交易。

更新

2020/01/03:有一个新智能合约修复了该漏洞。

时间线

  • 2021/01/01 23:25 UTC,攻击被我们的系统捕获
  • 2021/01/02 16:20 UTC,本篇博文发布
Sign up for the latest updates
Weekly Web3 Security Incident Roundup | Feb 9 – Feb 15, 2026

Weekly Web3 Security Incident Roundup | Feb 9 – Feb 15, 2026

During the week of February 9 to February 15, 2026, three blockchain security incidents were reported with total losses of ~$657K. All incidents occurred on the BNB Smart Chain and involved flawed business logic in DeFi token contracts. The primary causes included an unchecked balance withdrawal from an intermediary contract that allowed donation-based inflation of a liquidity addition targeted by a sandwich attack, a post-swap deflationary clawback that returned sold tokens to the caller while draining pool reserves to create a repeatable price-manipulation primitive, and a token transfer override that burned tokens directly from a Uniswap V2 pair's balance and force-synced reserves within the same transaction to artificially inflate the token price.

Top 10 "Awesome" Security Incidents in 2025

Top 10 "Awesome" Security Incidents in 2025

To help the community learn from what happened, BlockSec selected ten incidents that stood out most this year. These cases were chosen not only for the scale of loss, but also for the distinct techniques involved, the unexpected twists in execution, and the new or underexplored attack surfaces they revealed.

#10 Panoptic Incident: XOR Linearity Breaks the Position Fingerprint Scheme

#10 Panoptic Incident: XOR Linearity Breaks the Position Fingerprint Scheme

On August 29, 2025, Panoptic disclosed a Cantina bounty finding and confirmed that, with support from Cantina and Seal911, it executed a rescue operation on August 25 to secure roughly $400K in funds. The issue stemmed from a flaw in Panoptic’s position fingerprint calculation algorithm, which could have enabled incorrect position identification and downstream fund risk.