New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 808407 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 27
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac , Fuchsia
Pri: 2
Type: Bug-Security



Sign in to add a comment

CSP bypass and XSS introduction via JavaScript URI in view source

Reported by s.h.h.n....@gmail.com, Feb 2 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36

Steps to reproduce the problem:
1. Go to https://vuln.shhnjk.com/xssable.php?xss=%3Cmeta%20http-equiv=%22content-security-policy%22%20content=%22default-src%20%27none%27%22%3E%0a%3C!--%20%20XSS%20Start%20--%3E%0a%3Ch2%3EPress%20Ctrl%20+%20U%3C/h2%3E%0a%0a%0a%3Ca%20href=%22javascript:alert(document.domain)//Click%20ME!!!!!%22%3E%3C/a%3E%3C!--
2. Press Ctrl + U
3. Click on javascript URL in View Source

What is the expected behavior?
Script execution is blocked by CSP

What went wrong?
view source does not inherit CSP from original website. This allows XSS which wasn't possible otherwise.

Did this work before? N/A 

Chrome version: 64.0.3282.119  Channel: n/a
OS Version: 10.0
Flash Version:
 
Components: Blink>ViewSource Blink>SecurityFeature>ContentSecurityPolicy
Labels: Security_Impact-Stable OS-Android OS-Chrome OS-Fuchsia OS-iOS OS-Linux OS-Mac
Status: Untriaged (was: Unconfirmed)
Summary: CSP bypass via JavaScript URI in view source (was: CSP bypass via XSS in view source)
This is essentially the same as  Issue 705206 , but introduces the observation that Content-Security-Policy is bypassed in this scenario.

Given the user-interaction requirement, this should probably be Severity_Low.
Oops, this is worse than I thought.

This bug "introduces" XSS to a site which wasn't possible otherwise.

PoC
https://vuln.shhnjk.com/xssable.php?xss=%3Cimg%20src=javascript:alert(1)%3E%3C!--

Please change the summary accordingly :)
Cc: jochen@chromium.org mkwst@chromium.org
Labels: -OS-iOS -Arch-x86_64 M-66 Security_Severity-Low
Owner: andypaicu@chromium.org
Status: Assigned (was: Untriaged)
Summary: CSP bypass and XSS introduction via JavaScript URI in view source (was: CSP bypass via JavaScript URI in view source)
Does this really affect iOS? We don't have Blink/our own CSP there. Please correct me if I'm wrong.

andypaicu, can you please take a look? Thanks.
Good point, view-source: isn't available on iOS.

Surgical CL:
https://chromium-review.googlesource.com/c/chromium/src/+/900099

Comment 5 Deleted

Project Member

Comment 6 by bugdroid1@chromium.org, Feb 6 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4f811848ab21dbbe39f64f82f61aa0e41c14a227

commit 4f811848ab21dbbe39f64f82f61aa0e41c14a227
Author: Eric Lawrence <elawrence@chromium.org>
Date: Tue Feb 06 17:37:23 2018

Sanitize JavaScript links in HTMLViewSourceDocument

To limit mischief, replace the target of JavaScript-scheme links in
HTMLViewSourceDocument with about:blank.

Bug:  705206 ,  808407 
Change-Id: I185006d0cb29caabcd08dd9d5b9324357c79efaa
Reviewed-on: https://chromium-review.googlesource.com/900099
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Eric Lawrence <elawrence@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534705}
[modify] https://crrev.com/4f811848ab21dbbe39f64f82f61aa0e41c14a227/third_party/WebKit/Source/core/html/HTMLViewSourceDocument.cpp

From the code review: 

"Let's keep the patch small and merge it back to 65. That said, I think it's worth putting together a followup to harden `view-source:` a bit more. Perhaps we could poke at `Document::SetIsViewSource` to move the document into an opaque origin, and `Document::CanExecuteScripts` to block script execution for `Document`s where `IsViewSource()` is true? WDYT? I'd be fine with adding a CSP as well. Might as well add all the layers. :)

Adding a block to CanExecuteScripts seems trivial. Adding CSP is also easy:

  HTMLMetaElement* csp = HTMLMetaElement::Create(*this);
  csp->setAttribute(http_equivAttr, "Content-Security-Policy");
  csp->setAttribute(contentAttr, "default-src 'none'");
  head->ParserAppendChild(csp);

Switching to a unique origin isn't something I've done before but probably isn't too hard. 
Project Member

Comment 8 by bugdroid1@chromium.org, Feb 7 2018

Labels: merge-merged-3325
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bdad902d8163ca5a723d930d1f22bea61669dd72

commit bdad902d8163ca5a723d930d1f22bea61669dd72
Author: Eric Lawrence <elawrence@chromium.org>
Date: Wed Feb 07 19:06:40 2018

Sanitize JavaScript links in HTMLViewSourceDocument (M65 merge)

To limit mischief, replace the target of JavaScript-scheme links in
HTMLViewSourceDocument with about:blank.

Bug:  705206 ,  808407 
Change-Id: I185006d0cb29caabcd08dd9d5b9324357c79efaa
Reviewed-on: https://chromium-review.googlesource.com/900099
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Eric Lawrence <elawrence@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#534705}(cherry picked from commit 4f811848ab21dbbe39f64f82f61aa0e41c14a227)
Reviewed-on: https://chromium-review.googlesource.com/907408
Reviewed-by: Eric Lawrence <elawrence@chromium.org>
Cr-Commit-Position: refs/branch-heads/3325@{#366}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
[modify] https://crrev.com/bdad902d8163ca5a723d930d1f22bea61669dd72/third_party/WebKit/Source/core/html/HTMLViewSourceDocument.cpp

Project Member

Comment 9 by sheriffbot@chromium.org, Feb 8 2018

Status: Fixed (was: Assigned)
Please mark security bugs as fixed as soon as the fix lands, and before requesting merges. This update is based on the merge- labels applied to this issue. Please reopen if this update was incorrect.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: andypaicu@chromium.org
Owner: elawrence@chromium.org
Status: Assigned (was: Fixed)
Still more work to do, per #7.
I can see that this is fixed in Chrome 65. Can I talk about this bug publicly? Or should I wait till defense-in-depth mitigations are pushed?
The broader Defense-in-Depth fix breaks a *ton* of tests, so it will need considerably more work to land:

https://chromium-review.googlesource.com/c/chromium/src/+/917121

failures:
ViewSourceTest.CrossSiteSubframe
ViewSourceTest.JavaScriptURISanitized
ViewSourceTest.ViewSourceCrossProcessAndBack
ViewExtensionSourceTest.ViewSourceTabRestore
ExtensionSettingsUIBrowserTest.ViewSource
ViewSourceTest.HttpPostInMainframe
ViewSourceTest.HttpPostInSubframe
ViewSourceTest.NavigationOmitsReferrer
RenderFrameHostManagerTest.RendererDebugURLsDontSwap

 Issue 833916  has been merged into this issue.
 Issue 833916  simply noted that View-Source was no longer in its own origin. Comment #2 in that issue helps explain why we probably need to land *both* disabling script execution AND opaque-origin in the same CL.
Project Member

Comment 15 by sheriffbot@chromium.org, May 30 2018

Labels: -M-66 M-67
I guess elawrence@ already left Google. This bug needs new owner.
Cc: elawrence@chromium.org
Owner: ----
Status: Available (was: Assigned)
Unfortunately, I won't be able to work on this further in the foreseeable future. I think we can call the original bug "Fixed", but we may want further hardening. 
Could anyone mark this bug as fixed and create another bug for DiD hardening if required?
Project Member

Comment 19 by sheriffbot@chromium.org, Jul 25

Labels: -M-67 Target-68 M-68
Owner: elawrence@chromium.org
Status: Fixed (was: Available)
Filed hardening bug at bug 868488, closing this one as fixed.
(also added Eric back as owner of this now fixed bug since he did all the hard work here)
Project Member

Comment 22 by sheriffbot@chromium.org, Jul 28

Labels: -Restrict-View-SecurityTeam Restrict-View-SecurityNotify
Labels: reward-topanel
Labels: -reward-topanel reward-0
Hello! Thanks for the report, but the VRP declined to reward, given the level of user interaction required.
Project Member

Comment 25 by sheriffbot@chromium.org, Nov 3

Labels: -Restrict-View-SecurityNotify 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