The checkLog
function in the UsdTokenSwapKeeper
contract does not validate the event signature before processing log topics. This allows attackers to craft fake logs that can manipulate the contract’s behavior. The vulnerability enables unauthorized triggering of swap requests, which could lead to financial loss.
In Solidity, event logs are stored with indexed parameters in topics
. The first topic
(index 0
) contains the event signature (a keccak256
hash of the event name and parameters). The checkLog
function currently extracts and processes log.topics[1]
and log.topics[2]
without verifying that log.topics[0]
corresponds to the expected event.
The function assumes that log.topics[1]
and log.topics[2]
belong to the intended event without checking log.topics[0]
.
Attackers can create malicious logs with the same topics[1]
and topics[2]
, but with a different event signature in topics[0]
, tricking the function into processing an invalid log.
Attack scenario:
An attacker crafts a fake log with:
topics[0]
: A different event signature.
topics[1]
: The attacker's address.
topics[2]
: A manipulated request ID.
The contract reads topics[1]
and topics[2]
without verifying the event signature, allowing the attacker to trigger unintended actions.
An attacker submits a malicious transaction with the following log:
topics Index |
Value |
---|---|
0 (event sig) |
0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef |
1 (caller) |
0x1234567890123456789012345678901234567890 |
2 (requested) |
0x1 |
Test in Foundry:
This test confirms that the contract processes logs even if the event signature does not match.
Attackers can fake logs to execute swaps they do not own.
Attackers could change the requestId
to manipulate token swaps.
Users may experience losses if malicious transactions are executed.
Manual review.
To prevent this, validate the event signature before extracting topics:
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.