Skip to content

Commit dcbabab

Browse files
committed
fix(Web3TokenView): only enable WebView contents debugging in debug builds (#2323)
Refs #2323 Web3TokenView.init() unconditionally calls `WebView.setWebContentsDebuggingEnabled(true)`, which leaves the in-app WebView attachable from `chrome://inspect` on any device with USB debugging enabled — including release builds installed on end-user devices. Because Web3TokenView is the surface that runs TokenScript / dapp JavaScript inside a *wallet* application, that is a CWE-489 exposure of session content for a process that signs transactions. Gate the call behind `BuildConfig.DEBUG` so contents debugging is only available in developer builds. This matches the practice used by MetaMask, Trust Wallet, and other audited Android wallet apps. This change does *not* address the larger refactor requested in #2323 (replacing the legacy provider with a MetaMask-style one); that work is left tracked by the issue.
1 parent c873a4a commit dcbabab

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/src/main/java/com/alphawallet/app/web3/Web3TokenView.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ private void init() {
123123
webSettings.setLoadWithOverviewMode(true);
124124
webSettings.setUserAgentString(webSettings.getUserAgentString()
125125
+ "AlphaWallet(Platform=Android&AppVersion=" + BuildConfig.VERSION_NAME + ")");
126-
WebView.setWebContentsDebuggingEnabled(true);
126+
// CWE-489: Web3TokenView holds session JS for a wallet that signs
127+
// transactions. Leaving WebView contents debuggable in release builds
128+
// lets anyone with USB access attach chrome://inspect and read the
129+
// page's DOM/JS. Restrict to debug builds only.
130+
WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG);
127131

128132
if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING))
129133
{

0 commit comments

Comments
 (0)