TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: DNS rebinding protection for Express.js

30 pointsby braxxoxover 6 years ago

3 comments

partycoderover 6 years ago
In this line: <a href="https:&#x2F;&#x2F;github.com&#x2F;brannondorsey&#x2F;host-validation&#x2F;blob&#x2F;2ba4672b82e2d956dd8614c87e2d846505be18d6&#x2F;index.js#L91" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;brannondorsey&#x2F;host-validation&#x2F;blob&#x2F;2ba467...</a> use Array.some rather than iterating through all elements with Array.filter.<p>Then this: <a href="https:&#x2F;&#x2F;github.com&#x2F;brannondorsey&#x2F;host-validation&#x2F;blob&#x2F;2ba4672b82e2d956dd8614c87e2d846505be18d6&#x2F;index.js#L28" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;brannondorsey&#x2F;host-validation&#x2F;blob&#x2F;2ba467...</a> is not something I would recommend. Don&#x27;t try to fix bad input.
评论 #18108605 未加载
arkadiytover 6 years ago
Neat, thanks for raising awareness of this issue. I don&#x27;t think it makes a lot of sense for the web server case (as you said, using TLS would fix it and that seems like the bigger concern), but if someone is building something like an electron app with a local server component then they ought to use this.<p>FWIW I think you can check just the Host header, it&#x27;s always going to be present and can&#x27;t be set by an attacker - referrer doesn&#x27;t add anything extra and attackers can force requests with blank referrers.<p>Also all your example regexes are correctly anchored but I can see a developer shooting themselves in the foot with that - I&#x27;d maybe add some warnings around it or even programmatically enforce anchored regexes.<p>Anyhow thanks for the Show HN!
nacsover 6 years ago
I understand validating the `Host` header but my understanding that the referer field is optional and theres quite a few users who either block referer headers for privacy&#x2F;anti-tracking purposes. Would this stop those users from accessing the site also?