Skip to content
Business logic Audit finding Intermediate

xToken Approvals Allow Spenders To Spend More Tokens

The approve function in xToken contracts was not overridden, so allowances were denominated in shares rather than the equivalent rebalanced vault token amount. As rewards accrued, the approved spender could transfer more underlying tokens than the approver intended.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

The approve function has not been overridden and therefore uses xToken shares instead of the equivalent rebalanced amount, i.e. the underlying vault token amount.

Proof of Concept

The approved spender may spend more tokens than desired. In fact, the approved amount that can be transferred keeps growing as rewards continue to be distributed to the XTokenUpgradeable contract.

Many contracts also use the same amount for the approve call as for the amount they want to have transferred in a subsequent transferFrom call, and in this case, they approve an amount that is too large (as the approved shares amount yields a higher rebalanced amount).

Recommended Mitigation Steps

The _allowances field should track the rebalanced amounts (i.e. the equivalent vault token amount) such that the approval value does not grow.

The transferFrom needs to be overridden and approvals should then be subtracted by the transferred vault token amount, not shares.

0xKiwi (NFTX) acknowledged, but disagreed with high severity and commented:

Not sure if I agree with this severity. If I approve for xTokens, I’m using xTokens, not the underlying token.

LSDan (judge) decreased severity to medium and commented:

This is a medium risk, not high. External assumptions (malicious contracts) are requires for any attack regarding the approval being too high.


The original report as published on Code4rena, by leastwood. 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 approve function was not overridden to convert shares to the equivalent rebalanced vault token amount, so allowances were stored in shares and grew with rewards.

Impact

An approved spender could transfer more tokens than the approver intended, but the judge noted that a malicious contract is required for any attack, so severity was reduced to medium.

What the attacker needed

A malicious or buggy spender contract; user approves xToken spending

The fix

The `_allowances` field should track the rebalanced amounts (i.e. the equivalent vault token amount) such that the approval value does not grow.

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.

In many crypto tokens, you can approve someone else to spend a certain amount of your tokens. Here, the approval was recorded in a different unit (shares) than the unit actually spent (the underlying vault tokens). Because the value of shares grows over time as rewards are added, the spender could end up moving more tokens than the approver meant to allow.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by leastwood

View all

70 more disclosed reports, best first.

More from NFTX contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.