Remove unparsable cruft from JSON responses #11186
Replies: 4 comments 4 replies
-
Further reading for those interested https://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx/ |
Beta Was this translation helpful? Give feedback.
-
Nice history lesson @p-m-j I vaguely knew the gruff was for security purposes but wasn't entirely sure why, and didn't know it had been fixed, so nice background 👍 My thought though is whether it's really worth doing right now given the back office rework stuff going on that most likely not going to have this anyway? Is there an immediate improvement to be had by doing this? Also, I vaguely remember in some package at some point that I had to work around this for a specific use case so I do wonder if removing this might break some things. |
Beta Was this translation helpful? Give feedback.
-
Related #11663 |
Beta Was this translation helpful? Give feedback.
-
We will make this change in v10, afaik it's a one liner to resolve. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
JSON responses from the Umbraco back office are returned with the following characters prefixing payloads
)]}',
The tl;dr for why is because it is recommended in the angular.js documentation https://docs.angularjs.org/api/ng/service/$http#json-vulnerability-protection
The long version requires some history.
Before CORS was commonplace it was still desirable to load JSON from different origins but the same-origin policy would prevent cross domain requests except when loading external script files.
A technique was invented where one would pass the name of a callback method in a querystring whilst loading a JSON resource with a script element, the server would respond with javascript which would invoke the callback passing a payload.
OK great but what does this have to do with the issue at hand?
A vulnerability was found where one could trick a user into loading a page which would redefine built-in objects
for example Array and then load a JSON resource which wasn't intended for use with JSONP, the browser would load the resource passing along any authentication cookies and potentially leak private data when passing it to the constructor of the redefined array object.
As a quick fix it was suggested that developers should use the previously mentioned unparsable cruft to make ensure browsers refused to evaluate the response whilst adding to Ajax handling code to strip the characters for legitimate uses.
The ECMAScript specification has been updated to prevent redefining important built-ins and all modern browsers are safe from this historical attack vector ergo there is no longer a need to include the unparsable cruft.
Beta Was this translation helpful? Give feedback.
All reactions