Skip to content

Drop setAllowUniversalAccessFromFileURLs in ControlPanelFragment#10

Open
jim-daf wants to merge 1 commit into
timnew:masterfrom
jim-daf:fix-webview-universal-access
Open

Drop setAllowUniversalAccessFromFileURLs in ControlPanelFragment#10
jim-daf wants to merge 1 commit into
timnew:masterfrom
jim-daf:fix-webview-universal-access

Conversation

@jim-daf
Copy link
Copy Markdown

@jim-daf jim-daf commented May 13, 2026

Closes #9.

ControlPanelFragment.afterView enables both setAllowFileAccessFromFileURLs(true) and setAllowUniversalAccessFromFileURLs(true) on the panel WebView and attaches the ir JS bridge:

settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
panel.addJavascriptInterface(emitter, "ir");
panel.loadUrl(layoutUrl);

layoutUrl is file:///android_asset/panels/<name>/index.html. The panel JS (assets/js/Panel.coffee) does $.getJSON on a sibling .json descriptor in the same directory:

loadJson: (jsonFile, callback) ->
    url = @resolveUrl jsonFile
    $.getJSON url, (data) =>
        callback data

That XHR is file:// to file://, so setAllowFileAccessFromFileURLs(true) is needed for the existing panels to load their JSON descriptors.

setAllowUniversalAccessFromFileURLs(true) is the strictly broader flag: it lets a file:// page XHR any origin, not just other file:// resources. The panel JS only ever fetches a sibling .json from android_asset, so this flag is not load-bearing for any existing panel. With the ir bridge attached, leaving it on would let an attacker-controlled panel exfiltrate IR command data, app information, or anything else the bridge exposes to a remote host (CWE-200).

Change

Drop settings.setAllowUniversalAccessFromFileURLs(true). Keep setAllowFileAccessFromFileURLs(true) so the sibling-JSON loading continues to work.

Assisted-by: Claude (Anthropic)

ControlPanelFragment.afterView loads a panel from
file:///android_asset/panels/<name>/index.html and attaches the ir
JS bridge. It used to set both:

    settings.setAllowFileAccessFromFileURLs(true);
    settings.setAllowUniversalAccessFromFileURLs(true);

The panel scripts (assets/js/Panel.coffee) call $.getJSON on a sibling
file:// JSON descriptor (file:///android_asset/panels/<name>/*.json).
That XHR is file-to-file, so setAllowFileAccessFromFileURLs(true) is
needed for the existing panels to load their configuration.

setAllowUniversalAccessFromFileURLs(true) is the strictly broader
flag: it lets a file:// page XHR ANY origin, not just other file://
resources. The panel JS only ever fetches a sibling .json from
android_asset, so this flag is not load-bearing for any existing
panel. With the ir JS bridge attached, leaving it on would let an
attacker-controlled panel exfiltrate IR command data, app
information, or anything else the bridge exposes to a remote host
(CWE-200).

Drop the universal-access flag. The file-from-file flag stays in
place so the existing JSON loading keeps working.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ControlPanelFragment enables allowUniversalAccessFromFileURLs while the panel JS only loads sibling JSON files

1 participant