Hijacking Web3 Extensions: Unvalidated Storage & TOCTOU Patch Bypass in Coin98
The Coin98 browser extension trusted values in the web page's localStorage to decide how to inject its Web3 provider, so any website could poison those keys and replace window.ethereum with a rogue provider. A later validation patch could be bypassed with a race condition that changed the keys after the check but before use.
infosecwriteups.com
Published on infosecwriteups.com
Web3
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Coin98 is a browser wallet extension for Web3. Like other wallet extensions, it injects a provider object into the page so that dApps can talk to the wallet: the content script mounts window.ethereum and window.coin98 in the page's DOM context, and dApp calls such as signing requests are routed through that bridge.
The report covers two vulnerabilities in that injection path, tracked as coin98-161 and coin98-193:
| ID | Issue | Affected version |
|---|---|---|
coin98-161 |
Unvalidated LocalStorage context poisoning | < 10.5.1 |
coin98-193 |
TOCTOU patch bypass | 10.5.1 |
The stated impact is zero-interaction provider hijacking, transaction interception and account takeover. Both issues were patched in production, and Coin98 agreed to public disclosure.
Setup
The report does not describe a lab setup, test accounts or tooling. The precondition that matters is simply that a user has the Coin98 extension installed and visits a site controlled by the attacker. No user interaction beyond loading the page is required.
Finding it
The starting observation is architectural. The extension's content script decided how to load its Web3 injection scripts based on state parameters persisted in localStorage. Content scripts share the page's DOM and local storage context, so any script running on the origin can read and write those keys. The extension trusted them without cross-origin or cryptographic integrity verification, which turns the storage namespace into an input channel controlled by the attacker.
Exploitation
Step 1: Poison the storage keys
A user visits an arbitrary site hosting malicious JavaScript. Before the wallet extension finishes initialisation, the site writes engineered parameters into the origin's localStorage namespace.
The report's data-flow sketch shows the sequence:
[ Unprivileged Web Page ] │ ├─► Poison localStorage keys │[ Coin98 Content Script ] │ ├─► Reads unvalidated state from localStorage ├─► Evaluates dynamic script injection parameters │[ Window DOM Context ] └─► Overwrites window.ethereum / window.coin98 with Rogue Provider
The page needs no privileges: writing to its own origin's localStorage is ordinary web API use. The timing matters, because the values must be in place before the content script reads them during initialisation.
Step 2: The content script mounts a rogue provider
The Coin98 content script executes, parses the corrupted state values, and dynamically mounts the provider bridge using external or overridden logic. Because the injection parameters come from the poisoned state, the object placed on window.ethereum and window.coin98 is the attacker's provider rather than the legitimate one.
Step 3: Intercept dApp traffic
Any dApp interaction initiated in that browser context, with Uniswap and OpenSea given as examples, routes cryptographic signing requests directly to the attacker's bridge.
Step 4: Bypass the first patch with a race
Coin98 fixed coin98-161 in release 10.5.1 by adding a synchronous validation check on the key-value pairs stored in localStorage before injecting the provider proxy onto the window object. The check created an asynchronous execution window between verification and mounting, and origin scripts run concurrently with the extension's content script injection loops, so the attacker can keep mutating the keys during execution:
- Time-of-check: the content script reads
localStorageand verifies that the state keys pass the new validation checks. - Race window: before the script consumes the validated config to freeze and mount
window.ethereum, the attacker's script overwrites the storage keys with payload values. The report namesrequestAnimationFrameand Web Workers as ways to run at high execution frequency. - Time-of-use: the extension reads the storage reference again during the DOM injection phase, parses the mutated state, and executes the malicious provider bridge even though the initial check passed.
Root cause
Two distinct mistakes, one per report.
For coin98-161, the content script treated localStorage as trusted configuration. Content scripts share the page's storage and DOM, so those values are attacker-controlled on any origin the user visits. Without integrity verification, the injection logic could be steered by the page.
For coin98-193, the fix validated the state and then used it later, reading the storage reference again at injection time instead of working from a frozen copy. The check and the use were not atomic, so the value could change in between. The synchronous validation added in 10.5.1 did not stop this because the storage reference was read again during the DOM injection phase.
Impact
An unprivileged website visited by a user with the extension installed could force the content script to inject a malicious provider into window.ethereum and window.coin98. That enables transaction redirection and dApp request interception across all supported chains, without user interaction. The report frames the outcome as zero-interaction provider hijacking, transaction interception and account takeover.
The bypass in coin98-193 was demonstrated against version 10.5.1, the release that was meant to close the first issue.
Fix
Coin98 shipped the architectural validation and isolation models described in the reports in production releases from 10.5.1 onward. The report's own recommendations for extension developers:
- Do not use
localStoragefor extension state. Keep state and initialisation flags inchrome.[redacted]orchrome.storage.session, which are isolated from origin scripts and cannot be tampered with by the page. - Initialise context atomically. Avoid multi-step checks when reading untrusted DOM or storage state; copy configuration into immutable memory in the content script context at execution time.
- Verify provider integrity. Lock down
window.ethereumwithObject.defineProperty()usingwritable: falseandconfigurable: falseimmediately atdocument_start, so it cannot be modified after injection.
Disclosure and payout
Both issues were verified as functional attack vectors in production releases, but no bug bounty payout was awarded by Coin98 or Hackenproof. coin98-161 was initially triaged as High/Critical because of its cross-dApp injection scope, then retroactively downgraded and marked Informative; coin98-193 was closed without financial settlement. After mediation on the platform, Coin98 consented to public disclosure.
Timeline:
| Date | Event |
|---|---|
| 24 March 2026 | coin98-161 submitted, covering global provider hijacking via unvalidated storage parameters |
| 1 April 2026 | Coin98 releases 10.5.1 with initial validation checks |
| 19 April 2026 | coin98-193 submitted, demonstrating a TOCTOU race bypassing the 10.5.1 patch |
The reports are linked at hackenproof.com/reports/coin98-161 and a second hackenproof report link.
Variants to test
- Other storage-backed configuration. Look for any extension that reads injection parameters, feature flags or RPC endpoints from
localStorageorsessionStorage. A positive result is that changing a key from the page changes which script or provider the content script loads. - Check-then-use patterns in content scripts. Any validation followed by a later read of the same storage key is a candidate. A positive result is that a value mutated between the two reads is accepted, for example by hammering the key from
requestAnimationFramewhile the page loads. - Provider object mutability. After the extension injects
window.ethereum, try to redefine or overwrite it from page script. A positive result is that the property is writable or configurable, or that a proxy can be installed around it. - Initialisation timing. Load a page that writes storage keys as early as possible, before extension initialisation completes, and check whether the injected provider differs from a clean profile. A positive result is a provider whose requests go to an endpoint you control.
- Cross-context leakage. Check whether extension state stored in page-accessible storage is used for anything beyond injection, such as account selection or chain configuration, and whether poisoning it changes signing behaviour.
What happened, in plain words
Coin98 is a browser wallet extension. You install it in Chrome (or a similar browser), and it holds the keys to your cryptocurrency accounts, much like a password manager holds your passwords. When you visit a website that uses crypto, called a dApp (short for decentralised application), the extension needs a way to talk to that website so the site can ask you to sign a transaction.
The way this conversation happens is through a special object the extension places inside the web page itself. In JavaScript, the language web pages are written in, an object is a bundle of named values and functions. The extension puts an object called window.ethereum and another called window.coin98 into the page. Any script on the page can then call functions on those objects to ask the wallet to do things, such as sign a transaction. Think of it as a reception desk the extension sets up inside the website's lobby: the website walks up to the desk and asks for a signature.
The problem the researcher found is that the extension decided how to set up that desk by reading some settings from a storage area that the website itself can write to. That storage area is called localStorage. It is a small key-value store that every website has in your browser, private to that website's address (its origin). If the extension trusts what it finds there, then any website can put fake settings in place and make the extension set up a fake desk, one that belongs to the attacker. When you then use a dApp, your signing requests go to the attacker instead of to the real wallet.
There were two separate problems. The first, tracked as coin98-161, was this unvalidated storage issue. Coin98 fixed it in version 10.5.1 by checking the settings before using them. The second, coin98-193, showed that the fix could be beaten: the attacker could change the settings after the check but before the extension used them. This kind of gap is called a TOCTOU (time-of-check to time-of-use) race condition. The report says both issues were patched in production and that Coin98 agreed to public disclosure.
The two vulnerabilities at a glance
The report covers two issues in the same part of the extension, the code that injects the wallet object into web pages.
| ID | Issue | Affected version |
|---|---|---|
coin98-161 |
Unvalidated LocalStorage context poisoning | < 10.5.1 |
coin98-193 |
TOCTOU patch bypass | 10.5.1 |
The stated impact is zero-interaction provider hijacking, transaction interception and account takeover. In plain words: you visit a page, you click nothing, and your wallet's connection to dApps can be redirected to the attacker, which can intercept transactions and, in the report's framing, lead to account takeover.
What you need for this to work
The report does not describe a lab setup, test accounts or tooling. The only precondition that matters is simple: a user has the Coin98 extension installed and visits a site controlled by the attacker. Nothing else is required from the user beyond loading the page.
That is worth pausing on. Many attacks need you to click a link, approve a popup or type a password. Here, simply opening a page is enough, which is why the report calls it zero-interaction.
How the researcher found it
The starting point is not a clever trick but an observation about how the extension is built. The extension's content script decided how to load its Web3 injection scripts based on state parameters kept in localStorage.
A few terms need unpacking here.
- A content script is a piece of JavaScript that a browser extension runs inside a web page. It is the extension's representative on the page.
localStorageis a storage box that every website has in the browser, tied to that site's origin. The site's own scripts can read and write it freely.- The DOM (Document Object Model) is the browser's in-memory model of the page: every element, every script, everything the page is made of. Content scripts and page scripts both live in and around this same model.
Because content scripts share the page's DOM and local storage context, any script running on the site can read and write those keys. The extension trusted them without cross-origin or cryptographic integrity verification. In other words, it never asked "did this value really come from me, and has it been tampered with?" It just used whatever it found. That turns the storage box into an input channel the attacker controls.
A useful comparison: imagine a hotel where the front desk keeps a note in the lobby saying which room the guest should be given. If anyone in the lobby can rewrite that note, the hotel is trusting a piece of paper that any passer-by can edit. The extension was doing the same with localStorage.
Step by step: how the attack works
Step 1: Poison the storage keys
A user visits an arbitrary site hosting malicious JavaScript. Before the wallet extension finishes initialisation, the site writes engineered parameters into the origin's localStorage namespace.
The report's data-flow sketch shows the sequence:
[ Unprivileged Web Page ] │ ├─► Poison localStorage keys │[ Coin98 Content Script ] │ ├─► Reads unvalidated state from localStorage ├─► Evaluates dynamic script injection parameters │[ Window DOM Context ] └─► Overwrites window.ethereum / window.coin98 with Rogue Provider
Line by line, in plain words:
[ Unprivileged Web Page ]is the attacker's website. It has no special rights; it is just a normal page.├─► Poison localStorage keysmeans the page writes its own values into the storage box for its own address. This is ordinary web API use, something any website can do.[ Coin98 Content Script ]is the extension's code running on that page.├─► Reads unvalidated state from localStoragemeans the extension picks up those values without checking whether they are genuine.├─► Evaluates dynamic script injection parametersmeans it uses those values to decide how to set up the wallet connection.[ Window DOM Context ]is the page's live model, where the wallet object lives.└─► Overwrites window.ethereum / window.coin98 with Rogue Providermeans the result is a fake wallet object in place of the real one.
The page needs no privileges: writing to its own origin's localStorage is ordinary web API use. The timing matters, because the values must be in place before the content script reads them during initialisation. Think of slipping a forged note onto the desk before the receptionist arrives in the morning.
Step 2: The content script mounts a rogue provider
The Coin98 content script executes, parses the corrupted state values, and dynamically mounts the provider bridge using external or overridden logic. Because the injection parameters come from the poisoned state, the object placed on window.ethereum and window.coin98 is the attacker's provider rather than the legitimate one.
A provider here is the object that dApps talk to when they want the wallet to do something. If the provider is the attacker's, then every request the dApp makes goes to the attacker.
Step 3: Intercept dApp traffic
Any dApp interaction initiated in that browser context, with Uniswap and OpenSea given as examples, routes cryptographic signing requests directly to the attacker's bridge.
A signing request is a dApp asking the wallet to approve something with the user's private key, for example authorising a transaction. If that request goes to the attacker's bridge, the signing request is routed to the attacker rather than the real wallet. The report describes this as transaction redirection and dApp request interception across all supported chains, without user interaction.
Step 4: Bypass the first patch with a race
Coin98 fixed coin98-161 in release 10.5.1 by adding a synchronous validation check on the key-value pairs stored in localStorage before injecting the provider proxy onto the window object.
A synchronous check runs in one go, without pausing. The idea was: read the settings, check them, and only then set up the wallet object. That sounds solid, but the check created an asynchronous execution window between verification and mounting. Asynchronous means the work is split into steps that do not happen at exactly the same instant; other code can run in between. Origin scripts run concurrently with the extension's content script injection loops, so the attacker can keep mutating the keys during execution.
The report breaks the bypass into three moments:
- Time-of-check: the content script reads
localStorageand verifies that the state keys pass the new validation checks. - Race window: before the script consumes the validated config to freeze and mount
window.ethereum, the attacker's script overwrites the storage keys with payload values. The report namesrequestAnimationFrameand Web Workers as ways to run at high execution frequency.requestAnimationFrameis a browser function that runs code just before each screen repaint, so it fires many times per second; a Web Worker is a background script that runs in parallel with the page. Both let the attacker hammer the storage key over and over. - Time-of-use: the extension reads the storage reference again during the DOM injection phase, parses the mutated state, and executes the malicious provider bridge even though the initial check passed.
A comparison: a bouncer checks your ID at the door, then you swap badges with someone in the queue before the bouncer looks again at the bar. The check was real, but it happened at the wrong moment. The report's point is that the fix only guaranteed the value was valid at the moment of the check, not at the moment of use.
Why it worked: the root cause
There are two distinct mistakes, one per report.
For coin98-161, the content script treated localStorage as trusted configuration. Content scripts share the page's storage and DOM, so those values are attacker-controlled on any origin the user visits. Without integrity verification, the injection logic could be steered by the page.
For coin98-193, the fix validated the state and then used it later, reading the storage reference again at injection time instead of working from a frozen copy. The check and the use were not atomic. Atomic means all-or-nothing, done as a single indivisible step. Because the two steps were separate, the value could change in between. The existing defence, the synchronous validation added in 10.5.1, did not stop this because it only guaranteed that the value was valid at the moment of the check, not at the moment of use.
What the impact means for a user
An unprivileged website visited by a user with the extension installed could force the content script to inject a malicious provider into window.ethereum and window.coin98. That enables transaction redirection and dApp request interception across all supported chains, without user interaction. The report frames the outcome as zero-interaction provider hijacking, transaction interception and account takeover.
The bypass in coin98-193 was demonstrated against version 10.5.1, the release that was meant to close the first issue.
How it was fixed
Coin98 shipped the architectural validation and isolation models described in the reports in production releases from 10.5.1 onward. The report's own recommendations for extension developers are worth reading even if you never write an extension, because they explain the shape of a good fix:
- Do not use
localStoragefor extension state. Keep state and initialisation flags inchrome.[redacted]orchrome.storage.session, which are isolated from origin scripts and cannot be tampered with by the page. These are storage areas that belong to the extension, not to the website, so the website cannot reach them. - Initialise context atomically. Avoid multi-step checks when reading untrusted DOM or storage state; copy configuration into immutable memory in the content script context at execution time. Immutable means it cannot be changed after it is set, so there is no window for an attacker to slip in a different value.
- Verify provider integrity. Lock down
window.ethereumwithObject.defineProperty()usingwritable: falseandconfigurable: falseimmediately atdocument_start, so it cannot be modified after injection.document_startis the earliest moment the browser lets an extension run code on a page.writable: falsemeans the property cannot be reassigned, andconfigurable: falsemeans it cannot be redefined or deleted.
Disclosure and payout
Both issues were verified as functional attack vectors in production releases, but no bug bounty payout was awarded by Coin98 or Hackenproof. coin98-161 was initially triaged as High/Critical because of its cross-dApp injection scope, then retroactively downgraded and marked Informative; coin98-193 was closed without financial settlement. After mediation on the platform, Coin98 consented to public disclosure.
A bug bounty is a programme where companies pay researchers for reporting security problems. Triage is the first assessment of a report, where the programme decides how serious it is. Informative is a status meaning the report was noted but not treated as a payable vulnerability.
The timeline:
| Date | Event |
|---|---|
| 24 March 2026 | coin98-161 submitted, covering global provider hijacking via unvalidated storage parameters |
| 1 April 2026 | Coin98 releases 10.5.1 with initial validation checks |
| 19 April 2026 | coin98-193 submitted, demonstrating a TOCTOU race bypassing the 10.5.1 patch |
The reports are linked at hackenproof.com/reports/coin98-161 and a second hackenproof report link.
What to look for in other extensions
If you are learning security, these are the kinds of things to check in other wallet extensions.
- Other storage-backed configuration. Look for any extension that reads injection parameters, feature flags or RPC endpoints from
localStorageorsessionStorage. A positive result is that changing a key from the page changes which script or provider the content script loads. An RPC endpoint is the server address a wallet uses to talk to a blockchain. - Check-then-use patterns in content scripts. Any validation followed by a later read of the same storage key is a candidate. A positive result is that a value mutated between the two reads is accepted, for example by hammering the key from
requestAnimationFramewhile the page loads. - Provider object mutability. After the extension injects
window.ethereum, try to redefine or overwrite it from page script. A positive result is that the property is writable or configurable, or that a proxy can be installed around it. - Initialisation timing. Load a page that writes storage keys as early as possible, before extension initialisation completes, and check whether the injected provider differs from a clean profile. A positive result is a provider whose requests go to an endpoint you control.
- Cross-context leakage. Check whether extension state stored in page-accessible storage is used for anything beyond injection, such as account selection or chain configuration, and whether poisoning it changes signing behaviour.
Glossary
- API: a defined way for one piece of software to ask another to do something, like a menu of allowed requests.
- Atomic: done as a single indivisible step, all or nothing, with no moment in between where something else can change.
- Asynchronous: split into steps that do not happen at exactly the same instant, so other code can run in between.
- Bug bounty: a programme where a company pays researchers for finding and reporting security problems.
- Chain: short for blockchain, the shared ledger a cryptocurrency runs on.
- Content script: JavaScript that a browser extension runs inside a web page.
- dApp: a website or application that talks to a blockchain, often through a wallet extension.
- DOM: the browser's in-memory model of a page, made of every element and script on it.
document_start: the earliest moment the browser lets an extension run code on a page.- Hackenproof: the bug bounty platform where these reports were submitted.
- Immutable: cannot be changed after it is set.
- Informative: a report status meaning the issue was noted but not treated as a payable vulnerability.
localStorage: a small key-value storage box every website has in the browser, tied to that site's origin and writable by the site's own scripts.- Origin: the combination of scheme, host and port that identifies a website, for example
https://example.com. - Provider: the object a dApp talks to when it wants the wallet to do something, such as
window.ethereum. - Race condition: a bug where the result depends on the exact timing of two things happening at once.
requestAnimationFrame: a browser function that runs code just before each screen repaint, many times per second.- RPC endpoint: the server address a wallet uses to talk to a blockchain.
- Signing request: a dApp asking the wallet to approve something with the user's private key, such as a transaction.
- Synchronous: runs in one go, without pausing for other code.
- TOCTOU: time-of-check to time-of-use, a bug where a value is checked and then used later, and can change in between.
- Triage: the first assessment of a bug report, where the programme decides how serious it is.
- Web Worker: a background script that runs in parallel with the page.
- Zero-interaction: an attack that needs nothing from the user beyond loading a page.