Back to Blog

并非所有代币都是好的:Paraluni 攻击快速分析

Code Auditing
March 13, 2022
3 min read

Paraluni项目于3月13日上午(UTC+8时间)遭到攻击。攻击者利用了两个漏洞攻击了该协议。第一个漏洞是未对传入的代币进行验证,第二个是传统的重入漏洞。攻击者发起了一系列攻击交易。接下来,我们将使用其中一笔交易 0xf2bba649019ce40a67f0fb74e5e800257d359d9094b6ba6faea14ffa4d3446b1 来说明整个攻击过程。

第一步:向paraRouter添加liquidity

攻击者调用了BTCB-WBNB池(索引=9)的addLiquidity,该池会将lp代币铸造给UBT(攻击者创建的代币)。在此操作之后,UBT代币持有该池的lp代币。请注意,BTCB和WBNB是从闪电贷借来的。

第二步:调用MasterChefdepositByAddLiquidity 攻击者调用了depositByAddLiquidity,将_pid设置为9,并将UGT和UBT代币作为参数。然而,该函数并未检查池子的储备代币是否与传入的代币(UGT和UBT)相等。

然后,该函数调用depositByAddLiquidityInternal,后者又调用了paraRouter的addLiquidity。该函数将调用UGT和UBT代币的transferFrom函数。然而,这两个代币由攻击者控制。在UBT的transferFrom函数中,攻击者调用了MasterChef合约的deposit函数,将第一步获得的LP代币存入MasterChef合约。

不幸的是,由于deposit函数中的余额变化,addLiquidity后的newBalance远大于oldBalance。通过这种方式,攻击者在MasterChef合约中获得了双倍的信用。

第三步:获利

攻击者最终调用了UBT.withdrawAssetMasterChef.withdraw来赎回lptoken以获取BTCB和WBNB。由于流动性的数量超出了攻击者应有的份额,因此攻击者将获得利润。

教训

除了重入问题之外,传入代币未经验证也是根本原因之一。我们已经在Visor案例Coin98案例中看到了类似问题的其他案例。

关于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
~$15.9M Lost: Trusted Volumes & More | BlockSec Weekly
Security Insights

~$15.9M Lost: Trusted Volumes & More | BlockSec Weekly

This BlockSec bi-weekly security report covers 11 notable attack incidents identified between April 27 and May 10, 2026, across Sui, Ethereum, BNB Chain, Base, Blast, and Berachain, with total estimated losses of approximately $15.9M. Three incidents are analyzed in detail: the highlighted $1.14M Aftermath Finance exploit on Sui, where a signed/unsigned semantic mismatch in the builder-fee validation allowed an attacker to inject a negative fee that was converted into positive collateral during settlement; the $5.87M Trusted Volumes RFQ authorization mismatch on Ethereum; and the $5.7M Wasabi Protocol infrastructure-to-contract-control compromise across multiple EVM chains.

Newsletter - April 2026
Security Insights

Newsletter - April 2026

In April 2026, the DeFi ecosystem experienced three major security incidents. KelpDAO lost ~$290M due to an insecure 1-of-1 DVN bridge configuration exploited via RPC infrastructure compromise, Drift Protocol suffered ~$285M from a multisig governance takeover leveraging Solana's durable nonce mechanism, and Rhea Finance incurred ~$18.4M following a business logic flaw in its margin-trading module that allowed circular swap path manipulatio

~$7.04M Lost: GiddyDefi, Volo Vault & More | BlockSec Weekly
Security Insights

~$7.04M Lost: GiddyDefi, Volo Vault & More | BlockSec Weekly

This BlockSec weekly security report covers eight attack incidents detected between April 20 and April 26, 2026, across Ethereum, Avalanche, Sui, Base, HyperLiquid, and MegaETH, with total estimated losses of approximately $7.04M. The highlighted incident is the $1.3M GiddyDefi exploit, where the attacker did not break any cryptography or use a flash loan but simply replayed an existing on-chain EIP-712 signature with the unsigned `aggregator` and `fromToken` fields swapped out for a malicious contract, demonstrating how partial signature coverage turns any historical signature into a generic permit. Other incidents include a $3.5M Volo Vault operator key compromise on Sui, a $1.5M Purrlend privileged-role takeover, a $413K SingularityFinance oracle misconfiguration, a $142.7K Scallop cross-pool index injection, a $72.35K Kipseli Router decimal mismatch, a $50.7K REVLoans (Juicebox) accounting pollution, and a $64K Custom Rebalancer arbitrary-call exploit.

Best Security Auditor for Web3

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

BlockSec Audit