Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also be sure not to allow loopback connections (ie your own site or localhost) or you can cause a deadlock if the user requests the same URL to download from your site recursively. Choose an appropriate timeout too to prevent users tying up backend processes with a HTTP server that is slow to respond, and don't follow Location headers to avoid bypassing of your initial filters. A Range header should also be used to prevent users from telling your server to download multi-GB files and causing bandwidth waste / denial of service.


> Also be sure not to allow loopback connections (ie your own site or localhost) or you can cause a deadlock if the user requests the same URL to download from your site recursively.

Keep in mind that any arbitrary domain can point DNS to a loopback or LAN address. So the code that fetches a URL needs to include this filtering.

> don't follow Location headers to avoid bypassing of your initial filters

Often, you'll want to follow redirects, but re-apply your filters when doing so.

> A Range header should also be used to prevent users from telling your server to download multi-GB files and causing bandwidth waste / denial of service.

You can't count on support for Range, and the server might also just behave unexpectedly. Your fetching code needs to limit how much data it accepts from a server, and drop the connection after some upper bound.


> Your fetching code needs to limit how much data it accepts from a server, and drop the connection after some upper bound.

And if you accept compressed responses, remember that they can be a lot bigger when decompressed: e.g. gzip allows for factor 1000.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: