<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>99318</bug_id>
          
          <creation_ts>2012-10-15 06:13:21 -0700</creation_ts>
          <short_desc>CSP and &lt;base&gt; Tag Injection</short_desc>
          <delta_ts>2013-03-26 06:58:59 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>113307</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Ashar Javed">justashar</reporter>
          <assigned_to name="Mike West">mkwst</assigned_to>
          <cc>abarth</cc>
    
    <cc>justashar</cc>
    
    <cc>mkwst</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>741994</commentid>
    <comment_count>0</comment_count>
    <who name="Ashar Javed">justashar</who>
    <bug_when>2012-10-15 06:13:21 -0700</bug_when>
    <thetext>Hi,

Even if site is using &apos;self&apos; CSP policy for all types of resources, attacker can still inject &lt;base&gt; tag and CSP can not stop it. e.g.,

On testing environment: http://www.mobilefuxx.de/csp/xsstest/test_unsafe.php , you may set the following CSP header as an example:

default-src &apos;self&apos;;

and in the allowed injection area, inject:

&lt;BASE HREF=&quot;http://www.google.com/logos/&quot;&gt;
&lt;img src=&quot;classicplus.png&quot;&gt;

Now click &quot;Submit Attack&quot; button ... nothing happens but behind the scene chrome has changed the base URL. You can see the new URL by clicking the &quot;Submit Attack&quot; button again and the URL now you have is:

http://www.google.com/csp/xsstest/test_unsafe.php

I think or I would like to suggest that CSP 1.1 would have also base-src &apos;self&apos; directive in order to stop base tag injection. At the same time I would also like to point out few posts related to base tag and how attacker can use this to ex-filtrate information. Thanks!

http://lcamtuf.coredump.cx/postxss/
http://www.thespanner.co.uk/2011/12/21/html-scriptless-attacks/
http://avuko.net/

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>742106</commentid>
    <comment_count>1</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-10-15 09:23:15 -0700</bug_when>
    <thetext>That&apos;s a good idea.  Would you be willing to email this information to the public-webappsec mailing list?  That&apos;s the appropriate forum for proposing features for CSP 1.1.

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>742107</commentid>
    <comment_count>2</comment_count>
    <who name="Ashar Javed">justashar</who>
    <bug_when>2012-10-15 09:24:48 -0700</bug_when>
    <thetext>Hi Adam,

Thanks for information.

I will do that. Thanks!

Best,

(In reply to comment #1)
&gt; That&apos;s a good idea.  Would you be willing to email this information to the public-webappsec mailing list?  That&apos;s the appropriate forum for proposing features for CSP 1.1.
&gt; 
&gt; Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>748996</commentid>
    <comment_count>3</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2012-10-23 14:35:48 -0700</bug_when>
    <thetext>&gt; (In reply to comment #1)
&gt; &gt; That&apos;s a good idea.  Would you be willing to email this information to the public-webappsec mailing list?  That&apos;s the appropriate forum for proposing features for CSP 1.1.
&gt; &gt; 
&gt; &gt; Thanks!

I&apos;ve just put together a test at https://mkw.st/p/mixed/base.html and can&apos;t reproduce your result, Ashar. Could you put up a sample that exhibits the problem (or did I screw up my test?)?

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>749440</commentid>
    <comment_count>4</comment_count>
    <who name="Ashar Javed">justashar</who>
    <bug_when>2012-10-24 00:51:37 -0700</bug_when>
    <thetext>Hi Mike,

I have just tested this again and it works in Chrome Stable version but in Canary it does not work.

In Chrome Stable the URL http://www.mobilefuxx.de/csp/xsstest/test_unsafe.php becomes http://www.google.com/csp/xsstest/test_unsafe.php

Steps to Reproduce
-----------------

1) In Chrome Stable open: http://www.mobilefuxx.de/csp/xsstest/test_unsafe.php

Set header &apos;self&apos; and in the text area inject:

&lt;BASE HREF=&quot;http://www.google.com/logos/&quot;&gt;
&lt;img src=&quot;classicplus.png&quot;&gt;

Click &quot;Submit Attack&quot; button.

Behind the scene in Chrome Stable the base URL which is mobilefuxx has been changed to google. You can see this by clicking on the button(Submit Attack) again.

I hope it helps. Thanks!




(In reply to comment #3)
&gt; &gt; (In reply to comment #1)
&gt; &gt; &gt; That&apos;s a good idea.  Would you be willing to email this information to the public-webappsec mailing list?  That&apos;s the appropriate forum for proposing features for CSP 1.1.
&gt; &gt; &gt; 
&gt; &gt; &gt; Thanks!
&gt; 
&gt; I&apos;ve just put together a test at https://mkw.st/p/mixed/base.html and can&apos;t reproduce your result, Ashar. Could you put up a sample that exhibits the problem (or did I screw up my test?)?
&gt; 
&gt; Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>761522</commentid>
    <comment_count>5</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2012-11-08 02:43:39 -0800</bug_when>
    <thetext>Great. Looks like this is fixed in trunk, then.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>