New issue
Advanced search Search tips

Issue 724000 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: May 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac , Fuchsia
Pri: ----
Type: Bug-Security



Sign in to add a comment

Security: Unfiltered JSONP callback can be abused to persist malicious JS over an origin via Service Workers

Reported by anti0...@gmail.com, May 18 2017

Issue description

VULNERABILITY DETAILS
Please provide a brief explanation of the security issue.

VERSION
Chrome Version: 58.0.3029.110
Operating System: OSX (same behavior on other OSses)

REPRODUCTION CASE
1. Clone BeEF since the exploit module is already in BeEF from a while:
git clone https://github.com/beefproject/beef.git 

The to start BeEF from a sane Ruby environment:
gem install bundler
bundle install
ruby beef -x 

2. Just run the attached Ruby app, it's a simple Sinatra one with an unfiltered JSONP endpoint and also a page vulnerable to Reflected XSS. For demo purposed, to hook the origin I'm using the /xssstored page rather than then /xss?secret=<> endpoint.

3. After hooking the localhost:4567 origin (the Ruby webapp) on BeEF (which origin is 127.0.0.1:3000), login into BeEF with default creds beef/beef, click on the hooked broser, go on command modules, search for "jsonp" and launch the module. You just want to enter "/vulnjsonp?callback=" in the command module input, since that is the same-origin JSONP unfiltered callback that will be used.

4. If everything worked, the origin is backdoored. 
onFetch is hooked and each response to that affected origin we control via XSS/hook has the body changed and the BeEF hook added to achieve persistence.  

This is probably expected behavior, however a JSONP callback that filters some characters might be helpful to mitigate the issue (until the whole callback can be rewritten via String.fromCharCode or similars :-)

Ruby code and screenshot attached.

 
jsonp_ruby_sw.rb
1.8 KB View Download
jsonp_PoC.png
3.5 MB View Download
Components: Blink>ServiceWorker
>This is probably expected behavior

Yes, as documented in the ServiceWorker security FAQ.

https://dev.chromium.org/Home/chromium-security/security-faq/service-worker-security-faq#TOC-If-a-site-has-an-XSS-vulnerability-can-the-attacker-permanently-compromise-that-origin-for-me-

A site that wishes to protect itself should take typical precautions against JSONP reflection and could simply reject requests containing the ServiceWorker request header: https://dev.chromium.org/Home/chromium-security/security-faq/service-worker-security-faq#TOC-Can-sites-opt-out-of-Service-Workers-

Comment 2 by palmer@chromium.org, May 18 2017

Cc: palmer@chromium.org kinuko@chromium.org mek@chromium.org slightlyoff@chromium.org
Labels: OS-Android OS-Chrome OS-Fuchsia OS-Linux OS-Mac OS-Windows
Status: Available (was: Unconfirmed)
In particular, sites should default to rejecting requests with the Service-Worker header, and only respond with an SW script on the specific endpoints/URLs for which they expect to receive SW requests. I'll leave it to an SW friend (CC'd) to decide whether to WontFix this bug and make it public, or if there is something more they'd like to do.

If we can make the best practices and recommendations for safe deployment more clear in the FAQ, please let us know. That document is just a start, and I don't expect it's perfect yet. :)

Comment 3 by wfh@chromium.org, May 19 2017

Labels: Needs-Feedback
Will WF tomorrow, if not heard back from SW peeps or reporter.

Comment 4 by kenrb@chromium.org, May 26 2017

Status: WontFix (was: Available)

Comment 5 by palmer@chromium.org, May 31 2017

Cc: falken@chromium.org
Project Member

Comment 6 by sheriffbot@chromium.org, Sep 2 2017

Labels: -Restrict-View-SecurityTeam allpublic
This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment