Your IP: Unknown · Your Status: ProtectedUnprotectedUnknown

Skip to main content

JSONP injection

JSONP injection

Also JSON with Padding, JSONP injection attack

JSONP injection definition

JSONP injection is a security vulnerability that can occur when a website uses JSONP to bypass the same-origin policy in web browsers.

JSONP allows a server to respond with data wrapped in a function call, which the client can then execute. The client includes a script tag on their web page, which points to the server’s response URL. This URL includes a query parameter that defines the name of the function that the JSON data should be wrapped in.

In a JSONP injection attack, an attacker inserts a malicious script into the web page via the script tag, which the server then wraps in a function and sends back. The browser executes this function, allowing the attacker to run arbitrary JavaScript code in the user’s browser.

History of JSONP injection

JSONP was developed to bypass the same-origin policy in web browsers. In the mid-2000s, web developers started widely using JSONP. However, they realized the potential for misuse: if an attacker could control the data passed to the JSONP endpoint, they could run arbitrary JavaScript code on the user’s browser.

During the late 2000s and beyond, awareness of JSONP Injection attacks increased. Security experts started recommending alternatives to JSONP, such as CORS (Cross-origin resource sharing), a technology that provides a safer way to handle requests to other domains.

Today, using JSONP is discouraged due to the associated security risks.

Ultimate digital security