Closed Bug 942307 Opened 12 years ago Closed 11 years ago

modal_dialog.js HTML/JS injection via innerHTML

Categories

(Firefox OS Graveyard :: Gaia::Browser, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
1.4 S5 (11apr)

People

(Reporter: rfletcher, Assigned: daleharvey)

Details

(Keywords: sec-high, Whiteboard: [systemsfe])

Attachments

(1 file)

apps/browser/js/modal_dialog.js is vulnerable to potential HTML/JS injection. The following line takes the output of prompt.message and uses it with innerHTML without an sanitization [1]: 129 elements.customPromptMessage.innerHTML = prompt.message; The file sanitizes this is exact field in other case statements [2], indicating this should be escaped as well. [1] http://mxr.mozilla.org/gaia/source/apps/browser/js/modal_dialog.js#129 [2] http://mxr.mozilla.org/gaia/source/apps/browser/js/modal_dialog.js#108
This seems bad. Who generates these prompts? The JS executes in a privileged context, yes? Rating sec-high at the moment.
Keywords: sec-high
This is a certified app, so the JS executes as part of a certified application. Still determining if we can control 'prompt.message' but thought I'd update with some notes so far: The handleBrowserEvent inside browser/js/browser.js, if the evt.type is 'mozbrowsershowmodalprompt', calls ModalDialog.handleEvent(evt, tab.id). inside modal_dialog.js, handleEvent then calls this.show(origin) where origin == tab.id So we are esssentially calling md_show(tab.id). md_shop() grabs the event from this.currentEvents[tab.id][0] and assigns it to 'evt'. If evt.detail.promptType is 'custom-prompt', then evt.detail.message is assigned to innerHTML.
Group: b2g-core-security
Is this something you could look at Dale? Thanks.
Flags: needinfo?(dale)
The content for the prompt can come from any web page, since it's basically what you set in alert("hello world!");
I can take a look, its not the same data as in alert(), thats escaped and formatted seperately
Assignee: nobody → dale
Flags: needinfo?(dale)
Whiteboard: [systemsfe]
I have been trying to find an exploit for this bug havent been able, its possible that a future browser dev could unknowingly use this api on unsafe user code, but for now most of the content comes from http://mxr.mozilla.org/mozilla-central/source/b2g/locales/en-US/chrome/overrides/appstrings.properties The appstrings do use newlines, and to be on the safe side we should still escape and format that prompt however, PR on the way
Attachment #8396680 - Flags: review?(fabrice)
Comment on attachment 8396680 [details] [review] Escape and newline custom browser prompts Oh the irony to review on github security bugs... don't do that please.
Attachment #8396680 - Flags: review?(fabrice) → review+
Apologies, I figured since I couldnt find an exploit that it was ok, wont do in future Green @ https://travis-ci.org/daleharvey/gaia/builds/21629056 Landed @ https://github.com/mozilla-b2g/gaia/commit/f8627656b0164cf7cfd435bcf08a11300cae29fb
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Group: b2g-core-security
Target Milestone: --- → 1.4 S5 (11apr)
Group: core-security → core-security-release
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: