Protocol is will not work on most of the supported blockchains due to hardcoded WETH contract address
The Swap library hardcodes a single WETH contract address, so on chains other than Ethereum mainnet the wrapped native token address is wrong. The protocol's swap-related functionality would therefore fail on most of the blockchains it intends to support.
Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/308
Found by
HonorLt, gogo
Summary
The WETH address is hardcoded in the Swap library.
Vulnerability Detail
As stated in the README.md, the protocol will be deployed on the following EVM blockchains - Ethereum Mainnet, Arbitrum, Optimism, Polygon, Binance Smart Chain. While the project has integration tests with an ethereum mainnet RPC, they don't catch that on different chains like for example Polygon saveral functionallities will not actually work because of the hardcoded WETH address in the Swap.sol library:
address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
Impact
Protocol will not work on most of the supported blockchains.
Code Snippet
address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
Tool used
Manual Review
Recommendation
The WETH variable should be immutable in the Vault contract instead of a constant in the Swap library and the Wrapped Native Token contract address should be passed in the Vault constructor on each separate deployment.
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 wrapped native token address was written as a fixed constant in a shared library rather than being supplied per deployment.
What the attacker needed
Deployment on a non-mainnet chain
The fix
The address should be set as an immutable value in the Vault contract and passed in through the constructor on each deployment.
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 is code that lives on a blockchain. This project planned to run on several blockchains, but each chain has its own address for the token that wraps its native coin. The code baked in one chain's address, so on the other chains it would point at nothing useful and the swaps would break.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.