Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose if there is some code like

<a href="<%=request.getHeader("Host")%>/xxx/>SignIn</a>

Can an attacker fake request.getHeader("host") to point 'SignIn' anchor to attacker's URL e.g. If yes, how? If no, why not?

share|improve this question

Not really.

request.getHeader() is a function that runs on the server and pulls information (in this case host) from the client's request header and places the string in the html it is fashioning. The line of code you have provided is just a convenience (and good coding practice) that makes it so the developer does not have to change the server code if they move the app from say to

However, for pen testing, I would recommend you look out for calls to request.getHeader() that make an access control decision based on on the result. For example, if the page checked that request.getHeader("referer") equaled before allowing the client, this would be exploitable because the client can place whatever it wants in that field.

EDIT: I would add the points made about DNS resolution and vhosts that are made in the answer to your other question Is Request.getHeader("host") vulnerable?. If the 'host' was, the request would have gone to in the first place.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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