Skip to content

Update SocketIORouter.js#1756

Merged
marcelklehr merged 2 commits intoether:developfrom
spruce:develop
Sep 29, 2013
Merged

Update SocketIORouter.js#1756
marcelklehr merged 2 commits intoether:developfrom
spruce:develop

Conversation

@spruce
Copy link
Copy Markdown
Contributor

@spruce spruce commented Apr 22, 2013

Here you have it :P, as you requested
We can discuss, whether it should be added some kind of security with setting an extra header in nginx which contains a secret key, so it's sure it really got forwarded and is not any scam just setting the header manually

Changed the setting of client.remoteAddress
@rhelmer
Copy link
Copy Markdown
Contributor

rhelmer commented Apr 22, 2013

Isn't this trivial for the client to spoof? It should be off by default and have a config option to turn it on.

Comment thread src/node/handler/SocketIORouter.js Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would !client.handshake.headers['x-forwarded-for'] be safer? IE

if(!client.handshake.headers['x-forwarded-for']){

@JohnMcLear
Copy link
Copy Markdown
Member

@rhelmer That's a very good point.

@rhelmer
Copy link
Copy Markdown
Contributor

rhelmer commented Apr 22, 2013

Oh ok, actually just read the summary :) - some kind of additional header with a key specified in the config would do the trick (having a simple off/on switch like I suggested isn't enough anyway)

@spruce
Copy link
Copy Markdown
Contributor Author

spruce commented Apr 22, 2013

I will add this tomorrow

@rhelmer
Copy link
Copy Markdown
Contributor

rhelmer commented Apr 22, 2013

I mean you could get away with just on/off setting if this header is guaranteed to be overridden by the proxy (and lots of server software does this), but it seems like a footgun for people setting up the system :)

Also - peeking through the source for express and socket.io I see some mention of x-forwarded, can you look to see if it's possible to just flip a switch somewhere instead of etherpad-lite having to worry about it?

@spruce
Copy link
Copy Markdown
Contributor Author

spruce commented Apr 24, 2013

I have added it to both express and Socket.io.
For express I use the standard method enable('trust proxy'). so that req.ip get's set to the original IP.
But for socket.io I haven't found anything. There was once a pull request but it got never merged: socketio/socket.io#397 so I added a quickfix for that. will do a pull request there too.

updated handler/SocketIORouter.js to use new setting
updated hooks/express.js to use new setting
updated utils/Settings.js to accept new setting
updated settings.json.template so new setting is present
@lkraav
Copy link
Copy Markdown

lkraav commented Jul 21, 2013

Here's another one interested in x-forwarded-for operating properly. Thanks @spruce, got enough from the patch for a "works for me"

@JohnMcLear
Copy link
Copy Markdown
Member

@spruce we can't automatically merge this pull request, can you update please? :)

@marcelklehr
Copy link
Copy Markdown
Contributor

what about this, now?

@JohnMcLear
Copy link
Copy Markdown
Member

Bump

@marcelklehr marcelklehr merged commit fb0bc31 into ether:develop Sep 29, 2013
@marcelklehr
Copy link
Copy Markdown
Contributor

merged.

@JohnMcLear
Copy link
Copy Markdown
Member

Does this have a related issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants