-
Notifications
You must be signed in to change notification settings - Fork 2k
Security issue: Don't read the host of the application from the HTTP header #847
Comments
@Koblaid the code https://github.com/meanjs/mean/blob/master/modules/users/server/controllers/users/users.password.server.controller.js#L62 is simply creating the password reset URL, at that point it's not sent to anyone and it is created per the user who views that link. Can you explain how would an attacker exploit that then? |
@Koblaid nevermind I think I understand what you were referring to.
WDYT? |
I would prefer 1 and refuse to start if the config option does not exist. Falling back to req.headers.host would mean to accept the security risk if the user forgets the option or is too lazy and does not understand the security implications. I think enforcing security is a good thing, especially if its done with a simple config variable. The requests originating IP would be the IP-address of the requesting host, right? This doesn't help anything, does it? Or do you mean the IP-address under which the server is running? I'm not sure if/where it could be accessed in a non-spoofable-manner. In addition, the IP of the actual server could differ from the IP under which the site is accessable from the outside (for example on Heroku). Also the IP would look suspicious in the email and using HTTPS would result in a browser warning. So I think enforcing the configuration option is the only secure way to handle this. |
Well "refuse" is a bit harsh. Can you offer another option without restricting the domain config? |
The only way of a fallback is using the HTTP header like it is done at the moment. I think in the end it's a question of convenience vs security. If you prefer convenience for the users falling back to HTTP header is the best option. My opinion is that software facing the web should prefer to add too much security in the case of doubt. I think users (me including :-) ) except frameworks such as mean.js to be secure by default. Also there is already a configuration system and most users probably have to configure something, so another option shouldn't really hurt. Concerning internal application: I think that especially in big companies there is a change in the way they secure internal applications. Because more and more networks get intruded without being detected the internal network can no longer be treaded as secure. So internal applications have to be secure too. |
Well instead of refusing to start maybe a red warning would be sufficient if the config is not set:
|
👍 |
maybe put the following in default.js: and in production.js: then, add to options when creating the server: WDYT? |
I think a default for production is dangerous, since there'll be no warning if the user forgets to change it. How about this: default.js: developtment.js: express.js:
EDIT: and somewhere the red warning if the hostname is not set in production mode |
good call, the default for productions would be dangerous. I like the idea of a warning. maybe we also put a comment in the production.js to remind people to set it? |
Sounds good to me |
👍 I like the conclusion that you three came up with... along with @jloveland last comment. treating this like any other config seems like a fine idea. |
I agree with the setting being required to start, but it would be helpful if defaults were pre-configured to handle localhost for the dev environment |
@lirantal @Koblaid can we finalize this so we can merge it in for 0.4.2? |
AFAICS the only thing missing are tests. Unfortunately I don't have time to write tests at the moment. Maybe it's accectable to merge it without tests. |
@Koblaid we can't merge without tests, we need to make sure everything we add works. |
Generic DOMAI configuration environment variable, useful for setting links to an app in reset email templates, and other cases. Fixes meanjs#871 and meanjs#847
Fixed with #1469 |
mean.js reads the host of the application from the HTTP header and stores it in req.locals (see https://github.com/meanjs/mean/blob/master/config/lib/express.js#L43). This value is then used for example to generate the password reset link: https://github.com/meanjs/mean/blob/master/modules/users/server/controllers/users/users.password.server.controller.js#L62
The HTTP host header field can be spoofed by an attacker. This could be used for example to let the server generate a password reset email with an url which contains the token but points to a completely different domain. More details: http://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html
We solved this problem by explicitly specifying the domain of the app in the config and use this value whenever we want to generate urls.
The text was updated successfully, but these errors were encountered: