<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>XMLHttpRequest on Nathaniel Inman</title><link>https://nathanielinman.com/tags/xmlhttprequest/</link><description>Recent content in XMLHttpRequest on Nathaniel Inman</description><generator>Hugo -- 0.147.7</generator><language>en-us</language><copyright>Nathaniel Inman</copyright><lastBuildDate>Tue, 02 Jun 2020 00:00:00 +0000</lastBuildDate><atom:link href="https://nathanielinman.com/tags/xmlhttprequest/index.xml" rel="self" type="application/rss+xml"/><item><title>XMLHttpRequest Security</title><link>https://nathanielinman.com/xmlhttprequest-security/</link><pubDate>Tue, 02 Jun 2020 00:00:00 +0000</pubDate><guid>https://nathanielinman.com/xmlhttprequest-security/</guid><description>&lt;p>It&amp;rsquo;s possible to intercept, adjust and otherwise tamper with a XHR request with javascript in the browser. The most common way of doing this is simply making a pointer reference to the original &lt;code>XMLHttpRequest.prototype.send&lt;/code> function, overwriting that function with a new one that does the tampering and then calls the original send function once finished. Here&amp;rsquo;s an example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">const&lt;/span> XHR &lt;span style="color:#f92672">=&lt;/span> XMLHttpRequest,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> XHRopen &lt;span style="color:#f92672">=&lt;/span> XHR&lt;span style="color:#f92672">.&lt;/span>prototype&lt;span style="color:#f92672">.&lt;/span>open;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> XHR&lt;span style="color:#f92672">.&lt;/span>prototype&lt;span style="color:#f92672">.&lt;/span>open &lt;span style="color:#f92672">=&lt;/span> function() {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> onFinish();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> XHRopen&lt;span style="color:#f92672">.&lt;/span>apply(this, arguments);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> };
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="identifying-tampering">Identifying Tampering&lt;/h2>
&lt;p>It&amp;rsquo;s very straight forward to identify tampering of the function. Simply ensure that the &lt;code>XMLHttpRequest.prototype.open.toString() === 'function send() { [native code] }';&lt;/code> evaluates to true. The function should always be native code if it wasn&amp;rsquo;t corrupted or tampered with.&lt;/p></description></item></channel></rss>