title: Yahoo HTML5 Context Parser - Cross site scripting (XSS)
body: <p>I'm trying out Yahoo's HTML5 Context Parser <a href="https://github.com/yahoo/context-parser" rel="nofollow">Yahoo context-parser</a> which helps in identifying potential XSS vulnerabilities.</p>
  
  <p>As a try out,running the <strong>./bin/context-dump</strong>  utility against the text </p>
  
  <pre><code>&lt;form&gt;&lt;input name=q value="%(query)s"&gt; &lt;/form&gt; 
  </code></pre>
  
  <p>(taken from 
  <a href="http://ArticleXSSInAttributes" rel="nofollow">ArticleXSSInAttributes</a>)</p>
  
  <p>produces :</p>
  
  <pre><code>HTML-State { statesSize: 51 } +0ms
  HTML-State { ch: 0, state: 1, symbol: 0 } +2ms
  HTML-State { ch: f [0x66], state: 8, symbol: 11 } +1ms
  HTML-State { ch: o [0x6f], state: 10, symbol: 11 } +0ms
  HTML-State { ch: r [0x72], state: 10, symbol: 11 } +0ms
  HTML-State { ch: m [0x6d], state: 10, symbol: 11 } +0ms
  HTML-State { ch: &gt; [0x3e], state: 10, symbol: 9 } +0ms
  HTML-State { ch: [0x20], state: 1, symbol: 0 } +0ms
  HTML-State { ch: [0x20], state: 1, symbol: 0 } +0ms
  HTML-State { ch: [0x20], state: 1, symbol: 0 } +0ms
  HTML-State { ch: &lt; [0x3c], state: 1, symbol: 7 } +0ms
  HTML-State { ch: i [0x69], state: 8, symbol: 11 } +0ms
  HTML-State { ch: n [0x6e], state: 10, symbol: 11 } +0ms
  HTML-State { ch: p [0x70], state: 10, symbol: 11 } +1ms
  HTML-State { ch: u [0x75], state: 10, symbol: 11 } +0ms
  HTML-State { ch: t [0x74], state: 10, symbol: 11 } +0ms
  HTML-State { ch: [0x20], state: 10, symbol: 0 } +0ms
  HTML-State { ch: n [0x6e], state: 34, symbol: 11 } +0ms
  HTML-State { ch: a [0x61], state: 35, symbol: 11 } +0ms
  HTML-State { ch: m [0x6d], state: 35, symbol: 11 } +0ms
  HTML-State { ch: e [0x65], state: 35, symbol: 11 } +0ms
  HTML-State { ch: = [0x3d], state: 35, symbol: 8 } +0ms
  HTML-State { ch: q [0x71], state: 37, symbol: 11 } +0ms
  HTML-State { ch: [0x20], state: 40, symbol: 0 } +0ms
  HTML-State { ch: v [0x76], state: 34, symbol: 11 } +0ms
  HTML-State { ch: a [0x61], state: 35, symbol: 11 } +0ms
  HTML-State { ch: l [0x6c], state: 35, symbol: 11 } +0ms
  HTML-State { ch: u [0x75], state: 35, symbol: 11 } +0ms
  HTML-State { ch: e [0x65], state: 35, symbol: 11 } +0ms
  HTML-State { ch: = [0x3d], state: 35, symbol: 8 } +0ms
  HTML-State { ch: " [0x22], state: 37, symbol: 2 } +1ms
  HTML-State { ch: % [0x25], state: 38, symbol: 12 } +0ms
  HTML-State { ch: ( [0x28], state: 38, symbol: 12 } +1ms
  HTML-State { ch: q [0x71], state: 38, symbol: 11 } +0ms
  HTML-State { ch: u [0x75], state: 38, symbol: 11 } +0ms
  HTML-State { ch: e [0x65], state: 38, symbol: 11 } +0ms
  HTML-State { ch: r [0x72], state: 38, symbol: 11 } +0ms
  HTML-State { ch: y [0x79], state: 38, symbol: 11 } +0ms
  HTML-State { ch: ) [0x29], state: 38, symbol: 12 } +0ms
  HTML-State { ch: s [0x73], state: 38, symbol: 11 } +0ms
  HTML-State { ch: " [0x22], state: 38, symbol: 2 } +0ms
  HTML-State { ch: &gt; [0x3e], state: 42, symbol: 9 } +0ms
  HTML-State { ch: [0x20], state: 1, symbol: 0 } +0ms
  HTML-State { ch: &lt; [0x3c], state: 1, symbol: 7 } +0ms
  HTML-State { ch: / [0x2f], state: 8, symbol: 6 } +0ms
  HTML-State { ch: f [0x66], state: 9, symbol: 11 } +0ms
  HTML-State { ch: o [0x6f], state: 10, symbol: 11 } +0ms
  HTML-State { ch: r [0x72], state: 10, symbol: 11 } +0ms
  HTML-State { ch: m [0x6d], state: 10, symbol: 11 } +0ms
  HTML-State { ch: &gt; [0x3e], state: 10, symbol: 9 } +0ms
  HTML-State { ch: [0xa], state: 1, symbol: 0 } +0ms
  HTML-State { undefined - char in html without state } +0ms
  </code></pre>
  
  <p>How does the given output help me to identify potential XSS issues, or in other words how does the Context Parser helps?</p>