Headline
CVE-2023-30543: fix: use up-to-date chainId/accounts when querying EIP1193-derived wallets by zzmp · Pull Request #749 · Uniswap/web3-react
@web3-react is a framework for building Ethereum Apps . In affected versions the chainId
may be outdated if the user changes chains as part of the connection flow. This means that the value of chainId
returned by useWeb3React()
may be incorrect. In an application, this means that any data derived from chainId
could be incorrect. For example, if a swapping application derives a wrapped token contract address from the chainId
and a user has changed chains as part of their connection flow the application could cause the user to send funds to the incorrect address when wrapping. This issue has been addressed in PR #749 and is available in updated npm artifacts. There are no known workarounds for this issue. Users are advised to upgrade.
Conversation
// Wallets may resolve eth_chainId and hang on eth_accounts pending user interaction, which may include changing
// chains; they should be requested serially, with accounts first, so that the chainId can settle.
const accounts = await this.provider.request<string[]>({ method: ‘eth_requestAccounts’ })
const chainId = await this.provider.request<string>({ method: ‘eth_chainId’ })
try {
// Wallets may resolve eth_chainId and hang on eth_accounts pending user interaction, which may include changing
// chains; they should be requested serially, with accounts first, so that the chainId can settle.
const accounts = await (eager ? this.provider.request({ method: ‘eth_accounts’ }) : this.provider
.then(() => this.activate(desiredChainId))
// Wallets may resolve eth_chainId and hang on eth_accounts pending user interaction, which may include changing
// chains; they should be requested serially, with accounts first, so that the chainId can settle.
const accounts = await this.provider.request({ method: ‘eth_requestAccounts’ }) as string[]
this.actions.update({ chainId, accounts })
this.actions.update({ chainId: parseChainId(chainId), accounts })
zzmp deleted the fix-initial-chain branch
February 1, 2023 23:12
This was referenced
Feb 2, 2023
Related news
### Impact `chainId` may be outdated if the user changes chains as part of the connection flow. This means that the value of `chainId` returned by `useWeb3React()` may be incorrect. In an application, this means that any data derived from `chainId` could be incorrect. For example, if a swapping application derives a wrapped token contract address from the `chainId` *and* a user has changed chains as part of their connection flow the application could cause the user to send funds to the incorrect address when wrapping. This is a common approach when using other foundational libraries like [`ethers`](https://github.com/ethers-io/ethers.js), and most users of v8 will want to upgrade past the affected versions. ### Patches Patched in https://github.com/Uniswap/web3-react/pull/749. Users of [email protected] should upgrade to at least: - @web3-react/coinbase-wallet@^8.0.35-beta.0 - @web3-react/eip1193@^8.0.27-beta.0 - @web3-react/metamask@^8.0.30-beta.0 - @web3-react/walletconne...