Skip to content
Smart contracts Audit finding Advanced

Vulnerability related to ‘Optimizer Bug Regarding Memory Side Effects of Inline Assembly’

0xSmartContract Follow with 0xheynacho

Originally disclosed on Sherlock

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

Found by

0xSmartContract, 0xheynacho

Summary

Solidity versions 0.8.13 and 0.8.14 are vulnerable to a recently reported optimizer bug related to inline assembly. Solidity 0.8.15 has been released with a fix.

Vulnerability Detail

AutoRoller.sol inherits solidity contracts from solmate FixedPointMathLib and ERC4626 , and both these uses inline assembly, and optimization is enabled while compiling.

Impact

This bug only occurs under very specific conditions: the legacy optimizer must be enabled rather than the IR pipeline (true for the current project configuration), and the affected assembly blocks must not refer to any local Solidity variables.

Code Snippet

AutoRoller.sol#L5

AutoRoller.sol#L7

FixedPointMathLib.sol#L36-L51

Solidity
contracts/src/AutoRoller.sol:
 
  4: import { ERC20 } from "solmate/tokens/ERC20.sol";
  5: import { FixedPointMathLib } from "solmate/utils/FixedPointMathLib.sol";
  6: import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol";
  7: import { ERC4626 } from "solmate/mixins/ERC4626.sol";

contracts/foundry.toml:
  1: [profile.default]
  8: optimizer_runs = 10000

Tool used

Manual Review

Recommendation

Use recent Solidity version 0.8.15 which has the fix for these issues.

Discussion

jparklev

We will bump our solidity patch version

jparklev

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

aktech297

Verified the fix. The contracts are updated with 0.8.15 compiler version.

The original report as published on Sherlock, by 0xSmartContract. 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.

What is known

A medium-severity smart contracts bug in Sense Update #1. Sherlock made it public on 9 November 2022. Found in the 19 audit contest (finding M-1), also found by 1 other warden.

About Smart contracts

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

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

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 0xSmartContract

View all

6 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.

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.