새소식

인기 검색어

Web3/BlockChain

[BlockChain] DeFiHackLabs - BRA

  • -
반응형

2023년 1월 10일 해커는 BRA Token을 exploit 하여 약 225,000달러에 해당하는 819 WBNB를 훔쳤다.

미쳤다.. 미쳤어...

다같이 Audit을 해보자!!

일단 취약한 address랑 CA를 확인해 보자.

Attacker address: 0x67a909f2953fb1138bea4b60894b51291d2d0795

Attack CA - 1: 0x1fae46b350c4a5f5c397dbf25ad042d3b9a5cb07

Attack CA - 2: 0x6066435edce9c2772f3f1184b33fc5f7826d03e7

Attack Tx - 1: 0x6759db55a4edec4f6bedb5691fc42cf024be3a1a534ddcc7edd471ef205d4047

Attack Tx - 2: 0x4e5b2efa90c62f2b62925ebd7c10c953dc73c710ef06695eac3f36fe0f6b9348

Vulnerable CA: 0x449fea37d339a11efe1b181e5d5462464bba3752

박스 쳐져있는 부분이 취약한 함수이다.

Root Cause는 이체 후 sync() 함수를 실행하지 않고 pancake pair에게 세금 수수료를 이중으로 보상하는 결함 때문이다.

첫 번째 공격의 flow는 총 7번으로 진행된다.

  1. Borrowing 1.4k WBNB with flash loan
  2. Swapping 1k WBNB for 10.5k BRA
  3. Transferring 10.5K $BRA to pancake pair (0x8f4ba1832611f0c364de7114bbff92ba676adf0e)
  4. Invoking the skim() function, which further invokes the transfer() function of BRA contract to double collect the tax fee. The fee rate is 3%
  5. Repeating step 4 for about 100 times. Before step 4, the BRA balance of the pair contract is 8.6K; while after step 4, the number reached 217.2k. Note that the 208.6k BRA was considered as the attacker's input for swapping
  6. Swapping back 1.675 WBNB
  7. Repaying 1.4K WBNB to the flash loan, and transferring the remaining 675 WBNB to attacker(0x67a909f2953fb1138bea4b60894b51291d2d0795)
  8. The attacker then carried out a second attack transaction from which he stole funds worth 144 $WBNB tokens.
  9. The exploiter finally transferred 819 $WBNB in total earnings to Attacker EOA address.

하나씩 같이 살펴보자.

일단 구분하기 쉽게 중요한 address를 색으로 나타내겠다

Attacker, ACA1, ACA2, Token

Step1

flashloan을 통해 1,4K WBNB을 빌렸다.

Step2

1k WBNB를 10.5k BRA로 바꿈

Step3

PancakeSwap pool에 BRA Token을 저장했다.

Step4

skim() 함수를 호출하여 BRA Contract의 transfer() 함수를 추가로 호출하여 세금을 이중으로 징수한다.

수수료는 3%이다.

Step5

한 번 skim()을 두 번 실행하면 8.6k이지만 약 100번 반복하면 217.2k로 증가한다. 그래서 208.6k BRA를 획득했다.

Step6

다시 1.674 WBNB으로 바꾼다.

Step7

flashloan으로 1.4k WBNB를 상환하고 Attacker 지갑에 675 WBNB를 송금했다.

Step8

그럼 다음 공격자는  두 번째 공격으로 144 WBNB 토큰을 훔쳤다.

Step9

최종적으로 공격자는 819 WBNB를 공격자 지갑 주소로 송금했다.

 

그래서 project BRA 가격이 96%나 하락하는 손실이 발생하였다.

 

반응형

'Web3 > BlockChain' 카테고리의 다른 글

[BlockChain] DeFiHackLabs - FDP  (0) 2023.02.14
[BlockChain] DeFi Protocol - Uniswap  (0) 2023.02.13
[BlockChain] DeFi Protocol - Tornado Cash  (0) 2023.02.10
[BlockChain] DeFiVulnLabs - Bypass iscontract  (0) 2023.02.10
[BlockChain] NFT  (0) 2023.02.10
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.