Skip to content
Misconfiguration Audit finding Intermediate

Hardcoded divider address in RollerUtils is incorrect and will brick autoroller

RollerUtils stored the Divider contract address as a hardcoded constant, and that address was the Goerli testnet one rather than the correct mainnet address. Because the wrong address makes the series lookup revert, the AutoRoller cooldown cycle could never complete, and for combineRestricted adapters liquidity providers could be left unable to withdraw their funds.

0x52 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-sense-judging/issues/19

Found by

0x52

Summary

RollerUtils uses a hard-coded constant for the Divider. This address is incorrect and will cause a revert when trying to call AutoRoller#cooldown. If the adapter is combineRestricted then LPs could potentially be unable to withdraw or eject.

Vulnerability Detail

address internal constant DIVIDER = 0x09B10E45A912BcD4E80a8A3119f0cfCcad1e1f12;

RollerUtils uses a hardcoded constant DIVIDER to store the Divider address. There are two issues with this. The most pertinent issue is that the current address used is not the correct mainnet address. The second is that if the divider is upgraded, changing the address of the RollerUtils may be forgotten.

    (, uint48 prevIssuance, , , , , uint256 iscale, uint256 mscale, ) = DividerLike(DIVIDER).series(adapter, prevMaturity);

With an incorrect address the divider#series call will revert causing RollerUtils#getNewTargetedRate to revert, which is called in AutoRoller#cooldown. The result is that the AutoRoller cycle can never be completed. LP will be forced to either withdraw or eject to remove their liquidity. Withdraw only works to a certain point because the AutoRoller tries to keep the target ratio. After which the eject would be the only way for LPs to withdraw. During eject the AutoRoller attempts to combine the PT and YT. If the adapter is also combineRestricted then there is no longer any way for the LPs to withdraw, causing loss of their funds.

Impact

Incorrect hard-coded divider address will brick autorollers for all adapters and will cause loss of funds for combineRestricted adapters

Code Snippet

AutoRoller.sol#L853-L914

Tool used

Manual Review

Recommendation

RollerUtils DIVIDER should be set by constructor. Additionally RollerUtils should be deployed by the factory constructor to make sure they always have the same immutable divider reference.

Discussion

jparklev

RollerUtils uses a hardcoded constant DIVIDER to store the Divider address. There are two issues with this. The most pertinent issue is that the current address used is not the correct mainnet address. The second is that if the divider is upgraded, changing the address of the RollerUtils may be forgotten.

We consider upgrading the divider a very disruptive and unlikely change that we'd need to redeploy most of our system for anyway, so we're not concerned with hardcoding as is. In addition, the address is for the goerli divider, so it was valid in the context we were testing it in.

That said, as we thought about it again, the divider address should actually be an immutable passed in via constructor, so we're validating this one and appreciate having a reason to rethink our assumptions

jparklev

Fix: https://github.com/sense-finance/auto-roller/pull/17

aktech297

Changes looks fine. As a suggestion, input address can be validated.

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

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 Divider address was hardcoded as a constant and the value used was the Goerli testnet address rather than the mainnet one.

Impact

Incorrect hard-coded divider address will brick autorollers for all adapters and will cause loss of funds for combineRestricted adapters

What the attacker needed

Deployed AutoRoller using RollerUtils; adapter is combineRestricted for fund loss

The fix

The divider address should be an immutable value passed in via the constructor, and the project fixed it in a pull request.

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.

A smart contract here kept another contract's address written directly into its code instead of being told the address when it was created. That written-in address pointed at a test network, so calls to it failed and a routine step in the auto-rolling process always broke. For some setups this meant users could not get their money back out.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by 0x52

View all

211 more disclosed reports, best first.

More from Sense Update #1

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.