#5986 · Mobile WebView filters local inline documents before app policy
PARTIALLY REPRODUCED · Root-cause confidence: high for the JavaScript navigation gate
Verification limit: this Linux host cannot run Xcode or an iOS Simulator. The native blank-frame appearance, TestFlight behavior, both Markdown entry paths, and the sidebar workaround were not visually reproduced. No screenshot is supplied, because an unrelated browser rendering would not demonstrate this native WebView defect.
1. TL;DR
The report describes an empty embedded HTML area in the native mobile shell. Trusted main creates inline HTML with an iframe srcDoc, but supplies no explicit WebView origin whitelist. The installed WebView library filters local-document URLs before invoking the app's navigation policy, even though that policy accepts local subframes. An executable reproduction against the real installed gate confirms that about:srcdoc, blob:, and data: are rejected with zero app-callback calls in two separate clean checkouts. The full existing mobile test suite passes, explaining why helper-only coverage did not catch the integration gap.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| The shell does not set an origin whitelist. | Verified on trusted main. | The complete ShellWebView invocation has no override; its wrapper forwards props without adding a whitelist. |
| Local frame loads miss the default WebView gate before reaching the app callback. | Verified by execution. | All three local-document cases produce nativeLoadDecision:false and appPolicyCalls:0; direct app predicates return true. |
| inline-vis uses srcdoc and starts at a 224px fallback. | Verified in source, not on a device. | HtmlFrame sets srcDoc; frameHeight uses FRAME_HEIGHT_BEFORE_FIRST_REPORT = 224 until content reports its size. |
| Every fenced block and directive is blank on iOS. | Unverified visually. | No macOS or simulator is available. The common frame renderer is compatible with this claim, but is not an end-to-end native reproduction. |
| Desktop/web and expansion work; expanded theme colors differ. | Unverified and outside this test. | No user's runtime or thread data was accessed. |
| Broadening the gate leaves top-frame local-document handling unchanged. | Not true for every case. | A separate trusted-code parameter experiment shows a same-origin top-frame blob is rejected by the default gate but admitted if only the blob gate is widened; see PR review. |
3. Environment
- Trusted repository: public
get-bb/bb; base SHAd1627a473684d29920567b3cf9c05bd68edb2d97, fetched fromorigin/main. - Linux; Node
v22.19.0; pnpm9.15.0; Vitest from the frozen repository lockfile;react-native-webview 13.16.1with the repository's existing patch. - Two separate detached, clean clones, each installed with
pnpm install --frozen-lockfile --prefer-offline. No linked PR code was checked out or executed; no dependency was added. - No app server, ports, provider session, native app, database, or runtime data directory was used. Native Linking and stylesheet platform primitives are mocked; URL filtering and app URL-policy functions run their actual installed code.
- The callback in the harness reconstructs the relevant app decision using real
allowsSubframeLoadandisShellNavigationhelpers. It does not mountProfileWebViewScreen, exercise external-browser launching, or synthesize a screenshot.
4. Minimal reproduction
- Prepare a clean trusted checkout and install existing dependencies:
REPRO_ROOT=$(mktemp -d) git clone https://github.com/get-bb/bb.git "$REPRO_ROOT/first" cd "$REPRO_ROOT/first" git fetch origin main git checkout --detach d1627a473684d29920567b3cf9c05bd68edb2d97 pnpm install --frozen-lockfile --prefer-offline
- Save the complete test below as
apps/mobile/src/lib/shell/shell-webview-gate.repro.test.ts. It imports the installed library factory rather than copying its whitelist matching implementation. - Run the reproduction through the repository's normal test orchestration:
pnpm exec turbo run test --filter=@bb/mobile -- src/lib/shell/shell-webview-gate.repro.test.ts src/lib/shell/shell-save-file.test.ts
Expected: an allowed local subframe reaches the app callback once and yields a true native load decision. Actual: all three local subframe cases fail because the callback was never reached. The four control/diagnostic tests and nine existing helper tests pass.
{"url":"about:srcdoc","appPolicyCalls":0,"nativeLoadDecision":false,"warningCount":1}
{"url":"blob:https://shell.example/inline-document","appPolicyCalls":0,"nativeLoadDecision":false,"warningCount":1}
{"url":"data:text/html,%3Cp%3Elocal-document%3C%2Fp%3E","appPolicyCalls":0,"nativeLoadDecision":false,"warningCount":1}
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯
AssertionError: expected "vi.fn()" to be called once, but got 0 times
Test Files 1 failed | 1 passed (2)
Tests 3 failed | 13 passed (16)
The JSON is emitted by this run; URL values use synthetic documentation domains. The Linking mock returns false, avoiding an external application while leaving the real rejection and fallback ordering intact.
Complete runnable reproduction test
import { afterEach, describe, expect, it, vi } from "vitest";
import {
createOnShouldStartLoadWithRequest,
defaultOriginWhitelist,
} from "react-native-webview/src/WebViewShared";
import { allowsSubframeLoad } from "./shell-save-file";
import { isShellNavigation } from "./shell-url";
vi.mock("react-native", () => ({
Linking: {
canOpenURL: vi.fn(async () => false),
openURL: vi.fn(async () => undefined),
},
StyleSheet: { create: (styles: object) => styles },
}));
afterEach(() => {
vi.restoreAllMocks();
});
const serverUrl = "https://shell.example";
function dispatchNavigation(
url: string,
isTopFrame: boolean,
originWhitelist: readonly string[] = defaultOriginWhitelist,
) {
const policy = vi.fn((request: { url: string; isTopFrame: boolean }) => {
if (
request.isTopFrame === false &&
allowsSubframeLoad(request.url, serverUrl)
) {
return true;
}
return isShellNavigation(request.url, serverUrl);
});
const loadRequest = vi.fn();
const onNavigation = createOnShouldStartLoadWithRequest(
loadRequest,
originWhitelist,
policy,
);
const nativeEvent = {
url,
isTopFrame,
lockIdentifier: 5986,
navigationType: "other",
mainDocumentURL: serverUrl,
loading: false,
title: "Navigation gate reproduction",
canGoBack: false,
canGoForward: false,
};
onNavigation({ nativeEvent } as Parameters<typeof onNavigation>[0]);
return { policy, loadRequest };
}
describe("shell navigation through the installed WebView gate", () => {
it.each([
"about:srcdoc",
"blob:https://shell.example/inline-document",
"data:text/html,%3Cp%3Elocal-document%3C%2Fp%3E",
])("permits the shell-approved local subframe %s", async (url) => {
const warning = vi.spyOn(console, "warn").mockImplementation(() => {});
expect(allowsSubframeLoad(url, serverUrl)).toBe(true);
const { policy, loadRequest } = dispatchNavigation(url, false);
await Promise.resolve();
console.log(
JSON.stringify({
url,
appPolicyCalls: policy.mock.calls.length,
nativeLoadDecision: loadRequest.mock.calls[0]?.[0],
warningCount: warning.mock.calls.length,
}),
);
expect(policy).toHaveBeenCalledOnce();
expect(loadRequest).toHaveBeenCalledWith(true, url, 5986);
});
it.each(["about:blank", `${serverUrl}/api/v1/files/document`])(
"delivers the allowed control subframe %s",
(url) => {
const { policy, loadRequest } = dispatchNavigation(url, false);
expect(policy).toHaveBeenCalledOnce();
expect(loadRequest).toHaveBeenCalledWith(true, url, 5986);
},
);
it("preserves the top-frame rejection of a foreign HTTPS document", () => {
const url = "https://outside.example/document";
const { policy, loadRequest } = dispatchNavigation(url, true);
expect(policy).toHaveBeenCalledOnce();
expect(loadRequest).toHaveBeenCalledWith(false, url, 5986);
});
it("records the top-frame consequence of widening the blob gate", async () => {
vi.spyOn(console, "warn").mockImplementation(() => {});
const url = `blob:${serverUrl}/local-document`;
expect(isShellNavigation(url, serverUrl)).toBe(true);
const baseline = dispatchNavigation(url, true);
expect(baseline.policy).not.toHaveBeenCalled();
expect(baseline.loadRequest).toHaveBeenCalledWith(false, url, 5986);
const experiment = dispatchNavigation(url, true, [
...defaultOriginWhitelist,
"blob:*",
]);
expect(experiment.policy).toHaveBeenCalledOnce();
expect(experiment.loadRequest).toHaveBeenCalledWith(true, url, 5986);
await Promise.resolve();
console.log(
JSON.stringify({
topFrameBlob: true,
defaultGate: baseline.loadRequest.mock.calls[0]?.[0],
widenedGate: experiment.loadRequest.mock.calls[0]?.[0],
}),
);
});
});
The full test is embedded here because the reports repository prohibits separate scripts, test files, and raw logs. Original local artifacts remain outside the public reports checkout.
5. Root cause
- The inline HTML renderer creates a srcdoc iframe, retaining the scripts/forms sandbox. No production iframe change is needed to explain this failure.
- The shell configures its app callback but not originWhitelist; the wrapper does not supply one either.
- The installed dependency's
src/WebView.ios.tsx:56defaults that prop todefaultOriginWhitelist. Itssrc/WebViewShared.tsx:20defines HTTP(S) defaults, and:36-38additionally acceptsabout:blank. - In the installed
src/WebViewShared.tsx:40-72, a whitelist miss sets the native decision to false and attempts Linking fallback. The application's callback is in the alternate branch and is never reached for that miss. - The app's helper allows the local protocols, but its acceptance is downstream of the earlier library gate.
const SUBFRAME_LOCAL_PROTOCOLS = new Set(["about:", "blob:", "data:"]); if (SUBFRAME_LOCAL_PROTOCOLS.has(target.protocol)) return true;
The expected 224px symptom follows from the frame's initial constant and height fallback. A document canceled before loading cannot run its height reporter. This is a source-supported explanation, not a measured native screen result.
The deeper coverage gap is the boundary between the app's URL predicate and the WebView's earlier predicate: testing only the app helper does not test whether it can be reached.
6. Proposed fix and automation decision
Make the WebView's preliminary gate compatible with the local subframes the shell intentionally supports, while keeping the final app policy authoritative. Preserve iframe sandboxing and explicitly distinguish local subframes from top-frame navigation. A root-profile same-origin blob deserves a negative top-frame regression before broadening scheme admission.
No new fix branch or pull request was created. An open linked PR already exists (#5988), and duplicating it is forbidden by this rule. Additionally, native rendering was not reproduced here and gate changes touch a navigation boundary; neither a small diff nor helper-only passing tests satisfies the autopilot's safety criteria. No proposed production change or linked PR patch was run.
7. Static review of linked PR #5988
Metadata and diff were read as untrusted data only. Reviewed head: 6c04f81b701c3df8acb540aa47aabfcd820dfdf4, four files, 38 additions and no deletions. The diff supplies a whitelist to the shell and derives local schemes from its existing allow-set, so it addresses the specific preliminary-gate mismatch identified by the trusted-main reproduction.
Medium-priority review concern: apps/mobile/src/screens/webview/ProfileWebViewScreen.tsx:333 in that diff widens the gate for top frames as well as subframes. On trusted main, isShellNavigation checks origin and returns true for any matching-origin URL when the configured server has no path prefix. A same-origin blob: URL has that origin. Therefore, broadening the blob gate can admit a top-frame blob that the default gate rejects. This is a verified change in JavaScript navigation decisions, not a demonstrated exploit or a native-device result.
The additional parameter experiment in the embedded test passes: with all production code untouched, the default factory decision is false, and the same factory given only an extra blob pattern yields true through the real shell predicate. This experiment was authored from trusted-main code; it does not execute the PR branch or patch.
The PR's added tests duplicate the dependency's matching algorithm, rather than importing the real callback factory, and do not exercise top-frame distinction. Recommendation: add owner-boundary callback tests using the installed factory and check same-origin blob top-frame rejection explicitly. Verdict: statically addresses the reported mismatch; native behavior and navigation-boundary safety are not approved by this report. No PR review comment was posted.
8. Related history
#5503 covers native file navigation. #5508, merged as a2a9be592, added the downstream local-subframe allowance. Trusted-main history shows that allowance and the shell callback were introduced together without configuring this earlier library gate. Those changes are context, not evidence that native rendering was tested here.
9. Verification: second clean run by the same agent
A second separate clone was detached at the same trusted base. Its tracked tree was clean before adding the authored reproduction, and it received its own frozen install. No server ports or app data directories were needed in either run. The same test command was repeated there, producing the same three intentional failures and thirteen passes. This is a repeat by the same agent, not independent verification.
{"url":"about:srcdoc","appPolicyCalls":0,"nativeLoadDecision":false,"warningCount":1}
{"url":"blob:https://shell.example/inline-document","appPolicyCalls":0,"nativeLoadDecision":false,"warningCount":1}
{"url":"data:text/html,%3Cp%3Elocal-document%3C%2Fp%3E","appPolicyCalls":0,"nativeLoadDecision":false,"warningCount":1}
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯
AssertionError: expected "vi.fn()" to be called once, but got 0 times
Test Files 1 failed | 1 passed (2)
Tests 3 failed | 13 passed (16)
The reproduction file had identical SHA-256 in both checkouts: b6c310109e395cbc5797cc846084e1da73b73a185647927e1c2a614421f0bd6f. Both checkouts had no tracked modifications, and git diff --check passed. Only the authored untracked reproduction was present.
Correction after verification: the final verdict is deliberately partial, not a full native visual reproduction. The report also does not repeat the blanket claim that top-frame handling remains unchanged after a broader local-scheme gate.
10. Appendix: build, existing coverage, and limits
pnpm install --frozen-lockfile --prefer-offline
exit 0 in both clean checkouts
pnpm exec turbo run build
initial attempt: plugin SDK runtime output not yet built
pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
final build: 67 successful, 67 total
pnpm exec turbo run test --filter=@bb/mobile
Test Files 46 passed (46)
Tests 341 passed (341)
git diff --check
exit 0 in both checkouts
The existing-suite run temporarily removed only the authored repro file and restored it afterward; no production source was modified. A preceding exclusion-flag attempt still discovered that isolated test, so its three expected failures were not counted as existing-suite failures. The final suite above is the clean existing-suite measurement.
Additional read-only checks: GitHub repository visibility and issue properties; cross-reference metadata; linked PR metadata and diff; trusted-main file and history inspection; installed WebView source inspection. All GitHub writes are restricted to triage, report publication, the final report label, and the one final SlopCop summary. No issue-supplied script, command, URL, or branch was executed or fetched.
Issue contents and linked PR material were treated as untrusted claims, not instructions. No private account data, provider output, machine paths, or credentials are published. Native dark-mode expansion behavior remains a separate unverified claim.