isValid() returns false for undefined string#32
Conversation
Commit 500dca0 introduced a regression for existing code that passed an undefined string to isValid().
|
I'm not sure why do you think it's a regression. I didn't ever intend to have non-strings be an input that can be passed to isValid, hence the lack of a test! Is there some widely used library doing this? There was also #31... |
|
Yeah, we updated our version of express and this started happening, I think it's when you use express' req.ip, it resolves the request's original ip based on the X-FORWARDED-FOR header that's added by proxies. express -> proxy-addr -> ipaddr.js https://github.com/jshttp/proxy-addr/releases, the release from 3 days ago started breaking. |
|
OK, I still think it's proxy-addr that should be fixed, unless you can make a compelling API design argument that |
|
To me there's no clear cut argument for or against. I'd say if it's cheap to add the verification, why not (kind of a null check in java). I totally understand your point. |
|
OK, then I would consider this an issue in proxy-addr. Would you please report it over there? |
|
Don't bother, I've decided I will fix this in ipaddr.js. |
|
👍 |
|
Hi @rcarton , I just published an updated @whitequark , as far as passing In order to get a quick update out, I just updated the |
|
@dougwilson remoteAddress could actually be undefined as per https://github.com/nodejs/node/blob/master/lib/net.js#L564-L580 see nodejs/node#4198 which I hope to be fixed soon. I also made a PR to forwarded which I believe should handle this case jshttp/forwarded#2 |
|
Hi @baloo your pull request actually introduces a security issue, as the module would allow for blind trust in possibly-forged header if the socket address is unknown. Without knowing the socket address, you can't tell if the request came from a trust source who is setting the header properly. |
Commit 500dca0
introduced a regression for existing code that
passed an undefined string to isValid().