Sign up ×
Information Security Stack Exchange is a question and answer site for information security professionals. It's 100% free, no registration required.

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

1 Answer 1

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.