Beosin Alert Profile picture
Oct 18, 2022 12 tweets 5 min read Read on X
#BeosinAlert #Flashloan
$PLTD suffers a price manipulation attack with a profit of 24,497 $BUSD for the hacker.
(Tx provided by @bbbb)

TX:0x8385625e9d8011f4ad5d023d64dc7985f0315b6a4be37424c7212fe4c10dafe0

Attacker’s address:0x6ded5927f2408a8d115da389b3fe538990e93c5b
The attacker mainly exploits the vulnerability in the PLTD contract to reduce the balance of PLTDs in Case-LP (0x4397c7) to 1 via flashloan, and then uses the $PLTD to swap all the $BUSD into the attack contract.
Step 1: The attacker initiates 2 flashloans through DODO and borrows $666,000 BUSD. Image
Step 2: The attacker swaps all the 666,000 $BUSD into 1.57M $PLTDs, at which point the attacker already holds a large amount of PLTD tokens, which will subsequently be used for the purpose of manipulating the balance of PLTD tokens in Cake-LP. Image
Step 3: The attacker queries the current bron value and the PLTD balance of the Commite-LP, which is a check before the attack. Note that these two values are critical and relate to the success of the attack. Image
Step 4: The attacker sends 116,000 $PLTD tokens directly to Commite-LP (0x4397c7), note that this amount is just twice the balance of $PLTDs in Commite-LP in the previous step minus 1

Why this number? We can find answers from the code. ImageImage
1) Call the transfer function.
2) The target address is uniswapV2Pair, we look at else if branch in line 344. The from address is the attack contract, takeFee is true, and the internal function _tokenTransferSell is called. ImageImage
3) The internal code of the _tokenTransferSell function is as follows. In lines 423-426, this part of the code sets the _bron to half the number of this transfer, i.e. the balance of the Cake-LP minus 1. Image
Step 5: Let's back to the attack. Here the attacker uses skim to take back the PLTD transferred in step 4. As in the _transfer function, if the from address is uniswapV2Pair, then it will call _tokenTransferBuy.
(The function will not affect the value of _bron) Image
Step 6: All the previous operations are for this step. The attacker transfers 1 $PLTD to the address 0x16b9a82891338f9ba80e2d6970fdda79d1eb0dae, and since this address is not the address of Take-LP, the internal function _tokenTransfer is called for this transfer. Image
Look at line 451 to 456. In step 4, _bron is set to the balance of Cake-LP minus 1, and the fifth step restores the balance of Cake-LP. This step directly reduces the balance of Cake-LP to 1, and then calls the sync function of Cake-LP to synchronize the balance to reserve. ImageImage
Step 7: The attacker swaps all the $PLTD tokens to $BUSD, almost draining the entire BUSD balance of Case-LP.
The attacker gains 690,000 $BUSD and repays the 666,000 BUSD flashloan. The remaining 24,497 $BUSD profit is sent to 0x083c057221e95D45655489Fb01b05C4806387C19 Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Beosin Alert

Beosin Alert Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @BeosinAlert

Jun 30, 2023
H1 2023 Web3 Security Statistics

🚨Total losses from hacks, phishing scams, and rug pulls in Web3 reached $655.61 million in the first half of 2023.

Among them,
108 attacks -> $471.43M
Phishing scams -> $108M
110 rug pulls -> $75.87M https://t.co/8Q9kmDETfQtwitter.com/i/web/status/1…
2/ The total loss from hacks in Web3 has significantly decreased compared to last year.

In H1 2022, the total loss from attacks was ~$1.91 billion, and in H2 2022, it was about $1.69 billion, while in H1 2023, this value dropped to $470 million.
3/ Distribution of loss amount in hacks:

Loss exceeding $100 million: 1 incident
$10 million to $100 million: 7 incidents
$1 million to $10 million: 23 incidents

Read 5 tweets
Jun 6, 2023
Last month, Beosin security researchers have discovered a high-risk vulnerability CVE-2023–33252 in the library of SnarkJS (version 0.6.11 and earlier).

The high-risk vulnerability that allowing double-spending has now been fixed by Circom. It has a severity score of 7.5 in the… twitter.com/i/web/status/1… ImageImage
2/ Circom is a zero-knowledge proof circuit compiler developed in Rust. The team behind Circom has also developed the SnarkJS library, which supports various functionalities, including trusted setups, generation and verification of zero-knowledge proofs. Image
3/ In versions of SnarkJS <= 0.6.11, the library fails to perform comprehensive validation checks on the parameters during proof verification. This allows attackers to forge multiple proofs that pass the verification process, enabling double-spending attacks.
Read 9 tweets
May 19, 2023
Swaprum on Arbitrum rugged for ~$3M.

The deployer of Swaprum used the add() backdoor function to steal LP tokens staked by users, then removed liquidity from the pool for profit.

One tx:
arbiscan.io/tx/0x36fef881f… ImageImage
2/ The project has upgraded the the normal liquidity collateral reward contract to a contract containing backdoor functions.

arbiscan.io/address/0x9980…

arbiscan.io/address/0xcb65…
3/ The backdoor function add() will transfer LP tokens from the contract to the _devadd address. By querying the _devadd address, it will return the ‘Swaprum:Deployer’ address. ImageImage
Read 4 tweets
Apr 16, 2023
On Apr 15th, @HundredFinance was exploited for over $7M on #Optimism.
Hundred Finance was also a victim of a reentrancy attack on Mar 2022.
Txs:
0x15096dc6a59cff26e0bd22eaf7e3a60125dcec687580383488b7b5dd2aceea93
0x6e9ebcdebbabda04fa9f2e3bc21ea8b2e4fb4bf4f4670cb8483e2f0b2604f451
2/ The root cause is that the attacker can manipulate the exchangeRate by donating a large amount of WBTC to the hWBTC contract.
In the getAccountSnapshot function, the value of exchangeRateMantissa relies on the amount of WBTC in the contract. ImageImageImage
3/ The attacker flashloaned 500 $WBTC, then called the redeem function to redeem the previously staked 0.3 WBTC.
Next, the attack contract 1 sent 500.3 WBTC to attack contract 2. Contract 2 used 4 BTC to mint 200 hWBTC. The redeem function was then called to redeem the 4 BTC. ImageImage
Read 5 tweets
Apr 9, 2023
Root cause: The reset of lastCalledPool is before the check. This results in an invalid check on Pool, allowing attackers to specify malicious Pool to transfer users’ funds that have approved when swap.

Example: 0xea3480f1f1d1f0b32283f8f282ce16403fe22ede35c0b71a732193e56c5c45e8
1) The attacker created the malicious pool contract 30 days ago.
2) The swap is performed by calling SushiSwap's router function processRoute, specifying the malicious contract as the pool contract.
3) After the swap, the malicious contract calls the uniswapV3SwapCallback, specifying the tokenIn as WETH and the from address as the victim's address (@0xSifu sifuvision.eth), thus using the victim's approval to router contract to transfer the funds.
Read 6 tweets
Apr 5, 2023
Sentiment protocol was under an attack with a loss of ~$1 million caused by a price error due to reentrancy.
arbiscan.io/tx/0xa9ff2b587… Image
2/ The attacker first calls the "joinPool" function of Balancer Vault to make a deposit. Then he calls "exitPool" to withdraw, during which Balancer Vault sends eth to the attacker to call the fallback function of the attack contract.
3/ In the fallback function, the attacker calls the 0x62c5 contract's borrow function, which does a price calculation based on the return data from Balancer Vault.getPoolTokens().
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(