Skip to content
Smart contracts Audit finding Intermediate

Pool: approveAndCall sets unnecessary approval

The Pool.approveAndCall function grants the recipient contract an unlimited token allowance instead of only the specified amount. An attacker controlling the recipient contract could spend more tokens than intended.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

The Pool.approveAndCall function approves the recipient contract with the max value instead of only the required amount.

For safety, the approval should not be set to the max value, especially if the amount that the contract may use is already known in this call, like this is the case for approveAndCall.

Recommend only approving amount.

The original report as published on Code4rena, by cmichel. 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

The function approves the maximum token value rather than the specific amount passed to the call.

Impact

A malicious or compromised recipient contract could spend more tokens than the caller intended, potentially draining the caller's balance.

What the attacker needed

Attacker controls the recipient contract

The fix

The approval should be limited to the exact amount required for the call.

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 smart contract lets another contract spend its tokens, it sets an allowance. This report says the allowance was set to the maximum possible number instead of just the amount needed for that one call. That means the other contract could take far more tokens than it should.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by cmichel

View all

196 more disclosed reports, best first.

More from Spartan Protocol Contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.