<?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>7135</bug_id>
          
          <creation_ts>2006-02-07 09:59:23 -0800</creation_ts>
          <short_desc>window.history object persists data across pages</short_desc>
          <delta_ts>2011-08-06 18:32:14 -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>History</component>
          <version>417.x</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Trivial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gaz Hay">gazhay</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>barraclough</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>ian</cc>
    
    <cc>krishnamurty.podipireddy</cc>
    
    <cc>S60webkit</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>31734</commentid>
    <comment_count>0</comment_count>
    <who name="Gaz Hay">gazhay</who>
    <bug_when>2006-02-07 09:59:23 -0800</bug_when>
    <thetext>This used to trouble me with IE and Mozilla.
The window.history object is protected from reading for obvious reasons, however, try this :-

1. On a page call any of the following (or all)
window.history[58769]=&quot;This is a history hijack attempt&quot;;
window.history[window.history.length]=&quot;this is another hijack&quot;;
window.history[0]=&quot;This is history 1&quot;;

2. On another page attempt to read window.history[58769], [0], or [length-1]

The result - data transfered across pages. (This also used to be considered a security problem, so much so that MS went to great lengths to stop you doing such things without cookies)

A trivial &apos;problem&apos; - but one that a malicious page writer could exploit to gain information. (I won&apos;t elaborate on the details)

Just interested in your thoughts on whether or not this is a bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31735</commentid>
    <comment_count>1</comment_count>
      <attachid>6331</attachid>
    <who name="Gaz Hay">gazhay</who>
    <bug_when>2006-02-07 10:01:01 -0800</bug_when>
    <thetext>Created attachment 6331
quick page to setup history object exploit

A quick example of window.history persisting across pages</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31752</commentid>
    <comment_count>2</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2006-02-07 13:06:00 -0800</bug_when>
    <thetext>I can verify that Safari does persist the data, whereas FF doesn&apos;t. It&apos;s not immediately clear to me why this is a vulnerability. A malicious site can only read the data if another site has explicitly made it available.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31774</commentid>
    <comment_count>3</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-02-07 14:16:47 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; I can verify that Safari does persist the data, whereas FF doesn&apos;t. It&apos;s not
&gt; immediately clear to me why this is a vulnerability. A malicious site can only
&gt; read the data if another site has explicitly made it available.

NOTE: I have NOT tested any of these theories (since I&apos;m not in front of my PowerBook G4 at the moment).

1. Can some sort of denial of service attack may be launched to consume memory?

&lt;script&gt;
for (i = window.history.length; 1 == 1; i++) {
    window.history[i] = &quot;...a really, really long string...&quot;;
}
&lt;/script&gt;

2. Can the index for window.history[] be overflowed if it&apos;s willing to accept any index value?

&lt;script&gt;
window.history[2147483647] = &quot;INT_MAX&quot;;
window.history[2147483647+1] = &quot;INT_MAX+1&quot;;
&lt;/script&gt;

3. Can a &quot;future&quot; history item be added to window.history[] and then window.history.forward() or javascript:goForward() be used to run it?

&lt;script&gt;
window.history[window.history.length] = &quot;javascript:alert(&apos;Hello world!&apos;);&quot;;
window.history.forward();
&lt;/script&gt;

4. The window.history[] array provides a cross-site scripting (XSS) attacker a large storage space for keeping cookie values or usernames/passwords.  If the attacker can plant XSS code to store sensitive data (such as session cookies) in the history array, they can store a lot of information that could be sent if they are able to trick the user into visiting a &quot;harvesting&quot; site later.

http://www.cert.org/advisories/CA-2000-02.html

I do remember the original brouhaha about the window.history issue in MSIE and that many people felt it was overblown, but Microsoft definitely got dinged for it at the time.  I can&apos;t find any good web pages that talk about it, though.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>31803</commentid>
    <comment_count>4</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-02-07 20:17:09 -0800</bug_when>
    <thetext>Summary:  In Firefox 1.5.0.1, an exception is thrown any time the user attempts to access the window.history[] array (either for reading or writing).  Implementing this behavior will solve all of the four issues below (although not all of them are exploitable).  I have not tested MSIE 6 behavior.

(In reply to comment #3)
&gt; 1. Can some sort of denial of service attack may be launched to consume memory?

Yes, this is very easy to do, although I imagine there are other ways perform this kind of DoS attack simply by using a JavaScript array defined in the browser instead of the windows.history[] array.

&gt; 2. Can the index for window.history[] be overflowed if it&apos;s willing to accept
&gt; any index value?

This has no effect.  I didn&apos;t check the source code, but it&apos;s probably hashing the numeric value rather than using it literally.

&gt; 3. Can a &quot;future&quot; history item be added to window.history[] and then
&gt; window.history.forward() or javascript:goForward() be used to run it?

A &quot;future&quot; history item can be added, but browser navigation completely ignores it--in both directions.

&gt; 4. The window.history[] array provides a cross-site scripting (XSS) attacker a
&gt; large storage space for keeping cookie values or usernames/passwords.  If the
&gt; attacker can plant XSS code to store sensitive data (such as session cookies)
&gt; in the history array, they can store a lot of information that could be sent if
&gt; they are able to trick the user into visiting a &quot;harvesting&quot; site later.

The original poster has already demonstrated this.  Again, throwing an exception when accessing the window.history[] array would prevent this.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>447660</commentid>
    <comment_count>5</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2011-08-06 14:06:27 -0700</bug_when>
    <thetext>I cannot reproduce this bug, I&apos;ll assuming this is an old vulnerability, since fixed?
If you can still reproduce this, please reopen.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>6331</attachid>
            <date>2006-02-07 10:01:01 -0800</date>
            <delta_ts>2006-02-07 10:01:01 -0800</delta_ts>
            <desc>quick page to setup history object exploit</desc>
            <filename>input.html</filename>
            <type>text/html</type>
            <size>261</size>
            <attacher name="Gaz Hay">gazhay</attacher>
            
              <data encoding="base64">PEhUTUw+CjxIRUFEPgo8U0NSSVBUPgp3aW5kb3cuaGlzdG9yeVs1ODc2OV09IlRoaXMgaXMgYSBo
aXN0b3J5IGhpamFjayBhdHRlbXB0IjsKd2luZG93Lmhpc3Rvcnlbd2luZG93Lmhpc3RvcnkubGVu
Z3RoXT0idGhpcyBpcyBhbm90aGVyIGhpamFjayI7CndpbmRvdy5oaXN0b3J5WzBdPSJUaGlzIGlz
IGhpc3RvcnkgMSI7CjwvU0NSSVBUPgo8L0hFQUQ+Cgo8Qk9EWT4KPGEgaHJlZj0ib3V0cHV0Lmh0
bWwiPk91dHB1dCBpdDwvYT4KPC9CT0RZPgo8L0hUTUw+
</data>

          </attachment>
      

    </bug>

</bugzilla>