TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: What's the point of this kind of API?

14 pointsby kujaomegaabout 5 years ago
I have seen some api requests on the web with a https GET response body starting with the following characters:<p>)]}&#x27;<p>Then this characters are followed by arrays of elements without keys(as a JSON). What&#x27;s the point of having this structure of response requests?

5 comments

duskwuffabout 5 years ago
It prevents the response from being evaluated as Javascript.<p>In some older web browsers (like Firefox 2.0), this was required to prevent an attack where the Array constructor is overridden to capture arrays within a response. This no longer works on any modern browser, but a lot of web services still attempt to defend against it.<p><a href="https:&#x2F;&#x2F;haacked.com&#x2F;archive&#x2F;2008&#x2F;11&#x2F;20&#x2F;anatomy-of-a-subtle-json-vulnerability.aspx&#x2F;" rel="nofollow">https:&#x2F;&#x2F;haacked.com&#x2F;archive&#x2F;2008&#x2F;11&#x2F;20&#x2F;anatomy-of-a-subtle-j...</a>
kenabout 5 years ago
<a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;26955167&#x2F;json-data-that-starts-with-closing-brackets" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;26955167&#x2F;json-data-that-...</a>
verdvermabout 5 years ago
It disables the JS from running in an IFrame I believe.<p>Companies like Google and Facebook use this to prevent others from embedding their pages in others.
notlukeskyabout 5 years ago
You will need it only depending on the type of API you are building. If redirects etc are not an issue then your won’t need it. APIs are an attack vector for hackers.
zenincognitoabout 5 years ago
To prevent xss and other type of attacks lose cookie stealing or redirects.