<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Asktav - Latest Comments in Sanitising JSONP Callback Identifiers For Security</title><link>http://asktav.disqus.com/</link><description>Tav's Blog</description><atom:link href="https://asktav.disqus.com/sanitising_jsonp_callback_identifiers_for_security/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sun, 02 Nov 2014 09:16:57 -0000</lastBuildDate><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-1670906600</link><description>&lt;p&gt;Hi Tav&lt;/p&gt;&lt;p&gt;Very well written and still relevant!&lt;/p&gt;&lt;p&gt;Your post served as inspiration for a practical example of how JSONP and reflected file downloads can be used to harm unsuspecting users in my blog post:&lt;/p&gt;&lt;p&gt;&lt;a href="http://blog.davidvassallo.me/2014/11/02/practical-reflected-file-download-and-jsonp/" rel="nofollow noopener" target="_blank" title="http://blog.davidvassallo.me/2014/11/02/practical-reflected-file-download-and-jsonp/"&gt;http://blog.davidvassallo.m...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">David Vassallo</dc:creator><pubDate>Sun, 02 Nov 2014 09:16:57 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-1272854965</link><description>&lt;p&gt;Thanks guys! Maybe the post could link to both PHP and C# ports?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kees C. Bakker »µßlg</dc:creator><pubDate>Thu, 06 Mar 2014 09:48:08 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-590169761</link><description>&lt;p&gt; I know it is two years ago, but this is simply wrong (just to warn others).&lt;/p&gt;&lt;p&gt;In fact, the &amp;lt; symbol would not cause any problems in the callback, other than (probably) confusing JavaScript.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tom</dc:creator><pubDate>Tue, 17 Jul 2012 09:58:19 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-581553907</link><description>&lt;p&gt;Thanks for that! Here's a C# port of your PHP port: &lt;a href="https://gist.github.com/3074365" rel="nofollow noopener" target="_blank" title="https://gist.github.com/3074365"&gt;https://gist.github.com/307...&lt;/a&gt; :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel15</dc:creator><pubDate>Mon, 09 Jul 2012 01:27:31 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-312660117</link><description>&lt;p&gt;Thanks for the inspiration! I ported, simplified and refined this for PHP.&lt;/p&gt;&lt;p&gt;&lt;a href="https://gist.github.com/1217080" rel="nofollow noopener" target="_blank" title="https://gist.github.com/1217080"&gt;https://gist.github.com/121...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Erik Eng</dc:creator><pubDate>Fri, 16 Sep 2011 03:03:54 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-137669696</link><description>&lt;p&gt;Ignore me the test does appear to be passing. My lack of python expertise probably :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ag</dc:creator><pubDate>Mon, 31 Jan 2011 11:50:26 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-137570650</link><description>&lt;p&gt;Thanks for the useful code and article. I'm not a python expert but if you change the test&lt;/p&gt;&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; is_valid_javascript_identifier(u'Stra\u00dfe')&lt;/p&gt;&lt;p&gt;to&lt;/p&gt;&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; is_valid_javascript_identifier(r'Stra\u00dfe')&lt;/p&gt;&lt;p&gt;the test fails. Is this a bug or am I missing something? Shouldn't the validator deal with unicode escape sequences in ascii as well as the unicode letter itself?&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ag</dc:creator><pubDate>Mon, 31 Jan 2011 06:01:13 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-16287815</link><description>&lt;p&gt;This is all that's required:&lt;/p&gt;&lt;p&gt;def is_valid_jsonp_callback_value(value): value.find('&amp;lt;') &amp;lt; 0&lt;/p&gt;&lt;p&gt;I cannot tell if  your code does this or not.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Simple Xsrf</dc:creator><pubDate>Wed, 09 Sep 2009 23:28:09 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-16113327</link><description>&lt;p&gt;what you are describing is just the standard case of any XSS.&lt;/p&gt;&lt;p&gt;But there is no difference what so ever between&lt;/p&gt;&lt;p&gt;&amp;lt;script&amp;gt;alert(document.cookies)&amp;lt;/script&amp;gt;&lt;/p&gt;&lt;p&gt;and&lt;/p&gt;&lt;p&gt;&amp;lt;script src="&lt;a href="http://othersite.com/jsonp?callback=alert(document.cookies);foo" rel="nofollow noopener" target="_blank" title="http://othersite.com/jsonp?callback=alert(document.cookies);foo"&gt;http://othersite.com/jsonp?...&lt;/a&gt;"&amp;gt;&lt;/p&gt;&lt;p&gt;while I agree that XSS must be avoided at all cost, this is not the job of the remote site. It's the job of the local site.&lt;/p&gt;&lt;p&gt;PS: let's hope my sample code goes through :-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Philip Hofstetter</dc:creator><pubDate>Mon, 07 Sep 2009 17:20:12 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-16101704</link><description>&lt;p&gt;Thanks for the comment btw -- I've updated the article in response too. Cheers!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">tav</dc:creator><pubDate>Mon, 07 Sep 2009 13:42:54 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-16101232</link><description>&lt;p&gt;Hey Philip,&lt;/p&gt;&lt;p&gt;You are right, the code is executed in the context of the CALLERs page. But that is the problem...&lt;/p&gt;&lt;p&gt;Imagine the scenario, where a client-side web application allows arbitrary data sources to be added... it's not too implausible a future where instead of adding RSS feeds to an RSS Reader, one adds JSON feeds to such an application...&lt;/p&gt;&lt;p&gt;In this context, if the user is tricked into adding a maliciously crafted URL, then everything from their identity to their data is accessible... not to mention being able to abuse the account to spread a worm even...&lt;/p&gt;&lt;p&gt;I believe the possibilities of using JSONP haven't been explored much yet, and for it to go further in the context of interesting mashups/applications, it's important that it not be a security hole...&lt;/p&gt;&lt;p&gt;Hope that makes sense!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">tav</dc:creator><pubDate>Mon, 07 Sep 2009 13:34:26 -0000</pubDate></item><item><title>Re: Sanitising JSONP Callback Identifiers For Security</title><link>http://tav.espians.com/sanitising-jsonp-callback-identifiers-for-security.html#comment-16098663</link><description>&lt;p&gt;the problem here is the fact that whatever you pass to friendfeed is again executed in the context of your page.&lt;/p&gt;&lt;p&gt;This means that the alert() you so "cleverly" injected runs in the context of the CALLERs page, so the document.cookies that are alerted are the cookies on the source page (the page where the friendfeed-page is sourced on), not of the target page (friendfeed).&lt;/p&gt;&lt;p&gt;This also means that friendfeed doesn't have to do sanitization because whatever you are "injecting" there you could as well just put on your page to begin with.&lt;/p&gt;&lt;p&gt;The real problem behind JSONP is that the consumer has to trust the provider and there is no way to do ANY sanitization of that (the moment you add that "script src=" you are toast and you need to do that because requesting the script via XHR for example isn't possible due to the same origin policy).&lt;/p&gt;&lt;p&gt;So while this might look like a nice idea, it's completely unneeded and doesn't solve the real problem, which is, unfortunately, insolvable.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Philip Hofstetter</dc:creator><pubDate>Mon, 07 Sep 2009 12:25:13 -0000</pubDate></item></channel></rss>