Skip to content
Crypto Audit finding Intermediate

GolomTrader : validateOrder function does not check if ecrecover return value is 0

The validateOrder function in GolomTrader calls ecrecover directly and does not check if the returned address is zero. An attacker could submit an order with an invalid signature that recovers to address zero, making the order appear valid and enabling a griefing attack.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz, also found by 0x1f8b, 0xHarry, AuditsAreUS, djxploit, jayjonah8, joestakey, and teddav

The validateOrder function of GolomTrader calls the Solidity ecrecover function directly to verify the given signatures. The return value of ecrecover may be 0, which means the signature is invalid, but the check can be bypassed when signer is 0.

Proof of Concept

https://github.com/code-423n4/2022-07-golom/blob/e5efa8f9d6dda92a90b8b2c4902320acf0c26816/contracts/core/GolomTrader.sol#L176-L177

Recommended Mitigation Steps

Use the recover function from OpenZeppelin’s ECDSA library for signature verification.

kenzo (warden) commented:

Seems invalid or QA at best. No impact on protocol as far as I see, invalid orders from “address 0” will revert. In fillAsk if the o.signer is address 0, the function will try to pull tokens from address 0 and will fail. In fillBid/criteria, function will try to transfer msg.sender’s tokens to address 0 and pull weth from address 0. So will fail.

0xsaruman (Golom) disputed

LSDan (judge) commented:

This is valid as a medium risk. It opens a griefing attack where a bad actor spams any system that relies on this function. The fact that the fill will fail while the order appears valid is specifically what makes this griefing attack possible.


The original report as published on Code4rena, by cccz. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contract failed to verify that the address returned by ecrecover was not the zero address.

Impact

This could enable a griefing attack where a bad actor spams the system with orders that appear valid but fail when filled.

What the attacker needed

Ability to submit orders to the contract

The fix

The contract should use OpenZeppelin's ECDSA library for signature verification, which checks for invalid signatures.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a contract checks a digital signature, it uses a function called ecrecover to find out who signed. If the signature is bad, ecrecover can return the special address zero instead of failing. The contract here did not check for that, so a bad signature could look valid and cause problems.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by cccz

View all

104 more disclosed reports, best first.

More from Golom contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.