Tell me more ×
IT Security Stack Exchange is a question and answer site for IT security professionals. It's 100% free, no registration required.

I'm doing a "share box" where users can enter a link before posting and the app automatically scraps the URL to get a thumbnail and some other info. My question is: What would be a safe number of HTTP redirects to follow until giving up? The library I'm using has a default limit of 10, but I just realized some sites are doing more than 10 redirects. Take for example this curl command:

This doesn't reach the final content:

curl -L --max-redirs 10 http://www.nytimes.com/2012/03/10/world/americas/bernardo-pazs-inhotim-is-vast-garden-of-art.html?_r=0

Increasing the --max-redirs to 11 works:

curl -L --max-redirs 11 http://www.nytimes.com/2012/03/10/world/americas/bernardo-pazs-inhotim-is-vast-garden-of-art.html?_r=0

Can I just set a limit of 15 or 20 without affecting in a negative way the securty (and performance) of my app?

share|improve this question
Other than going into a recursive or loop that is too deep I don't see how this is a security issue. – makerofthings7 Feb 2 at 3:54
This question really isn't related to security. – Jeff Ferland Feb 2 at 6:48

closed as off topic by Jeff Ferland Feb 2 at 6:49

Questions on IT Security Stack Exchange are expected to relate to IT security within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

Yes, you can set a limit of 20 or 25 without causing any harm.

The only risk is that a redirect loop could cause you to keep fetching content, which might allow a malicious user to mount a Denial-of-Service attack against your server. But if you limit it to 25 redirects, then each user request can trigger at most 25 HTTP requests (not counting any embedded content), which is reasonable and shouldn't pose any significant risk.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.