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