CSP bypass and XSS introduction via JavaScript URI in view source
Reported by
s.h.h.n....@gmail.com,
Feb 2 2018
|
|||||||||||||
Issue descriptionUserAgent: 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:
,
Feb 2 2018
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 :)
,
Feb 2 2018
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.
,
Feb 2 2018
Good point, view-source: isn't available on iOS. Surgical CL: https://chromium-review.googlesource.com/c/chromium/src/+/900099
,
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
,
Feb 6 2018
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.
,
Feb 7 2018
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
,
Feb 8 2018
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
,
Feb 8 2018
Still more work to do, per #7.
,
Mar 6 2018
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?
,
Apr 27 2018
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
,
Apr 27 2018
Issue 833916 has been merged into this issue.
,
Apr 27 2018
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.
,
May 30 2018
,
Jun 2 2018
I guess elawrence@ already left Google. This bug needs new owner.
,
Jun 12 2018
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.
,
Jul 4
Could anyone mark this bug as fixed and create another bug for DiD hardening if required?
,
Jul 25
,
Jul 27
Filed hardening bug at bug 868488, closing this one as fixed.
,
Jul 27
(also added Eric back as owner of this now fixed bug since he did all the hard work here)
,
Jul 28
,
Jul 30
,
Aug 6
Hello! Thanks for the report, but the VRP declined to reward, given the level of user interaction required.
,
Nov 3
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 |
|||||||||||||
Comment 1 by elawrence@chromium.org
, Feb 2 2018Labels: 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)