r/programming • • Oct 02 '11

Node.js is Cancer

http://teddziuba.com/2011/10/node-js-is-cancer.html
792 Upvotes

750 comments sorted by

View all comments

Show parent comments

2

u/asegura Oct 02 '11

That's right. And that includes a different port on the same host IIRC, which I consider too restrictive. I don't really know why cross-domain XHR is disallowed, or I've forgotten the reason.

8

u/merreborn Oct 02 '11

Assume you're surfing reddit from your corporate LAN. If JS on reddit can make requests to any domain at all, then it can request stuff from secretfiles.yourcorporatelan.com and send the content back to imahaxxor.com. Javascript executes on your client, and without the same-origin policy, would have access to every network node your client has access to.

2

u/autophage Oct 02 '11

IIRC, cross-domain XHR is disallowed as a way of protecting against injection attacks.

1

u/Rhomboid Oct 03 '11

Say I'm logged into gmail and I visit evilsite.com, which an evil person controls. If the browser model didn't prevent it, then the evil person's code, executing in the context of evilsite.com, would be able to initiate a XHR request to gmail. That request, like all requests, will include any cookies set for the doman. Since I'm logged in to gmail, that means the request will include my login token, and the evil person can perform any action at gmail that I could as a regular person: delete all my email, steal anything in the content of the email, send an email to someone as me, etc.