Hacker News new | past | comments | ask | show | jobs | submit login
Is it safe to use JavaScript to eval JSON-like data from your own servers?
3 points by benhoyt on June 15, 2007 | hide | past | favorite | 4 comments



Scenario: I've got a page which does an Ajax request and eval()s the response. I trust the response, because it's from our own servers (and simply contains a dictionary). But are there any possible issues I'm forgetting?


If it's static, then you have no more worry than you would with any other javascript file. If it's dynamically generated, just be sure to escape any string delimiters in user-supplied data.


proxies. Is what the client receiving actually from your server and not from something between them and you.


But a malicious proxy doesn't need to insert Javascript to get your browser to do naughty things, since it can just manipulate the upstream anyway. Not to mention inject Javascript into HTML pages as they come down.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: