The Soulmate::writeMessageInSharedSpace
function currently lacks checks for both empty messages and prolonged messages. While empty messages are acceptable to ensure some form of communication, it's imperative to implement a check for message length. Longer messages incur a higher GAS
and could potentially lead to significant resource consumption. Therefore, implementing a length check is essential to mitigate this risk.
Place the following test code snippet into the test/unit/soulmateTest.t.sol file. Put it at the very bottom but before the last closing semicolon }
.
Open Your Bash Terminal
and execute the following command...
The output should clearly demonstrate that GAS costs increase with message length. This escalation in costs raises concerns about the potential for a Denial of Service (DoS) attack. In such a scenario, a soulmate could exhaust all their ETH reserves simply to cover the GAS costs associated with sending messages.
As GAS Cost grow with a message length, Sending a message could lead to heavy GAS Consumption and could cause a Denial of Service DoS
in the End.
Foundry Framework (Solidity, Rust)
Mitigation is simple, add checks to limit messages length and we can also add a check to avoid empty messages.
Update the src/Soulmate.sol
file with the following code modifications...
After modifying and updating the Soulmate.sol
file, try to re-execute the test discussed in the Proof of Concept (PoC). It should get reverted with the error Soulmate__CannotAddEmptyOrMoreThan50CharsLongMessage
at some point hopefully.
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.