Suppose if there is some code like
<a href="<%=request.getHeader("Host")%>/xxx/abc.do>SignIn</a>
Can an attacker fake request.getHeader("host") to point 'SignIn' anchor to attacker's URL e.g. attacker.com/xxx/abc.do? If yes, how? If no, why not?
|
Suppose if there is some code like
Can an attacker fake request.getHeader("host") to point 'SignIn' anchor to attacker's URL e.g. attacker.com/xxx/abc.do? If yes, how? If no, why not? |
|||
|
|
|
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 test.company.com to www.company.com. 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 sensitive.company.com page checked that request.getHeader("referer") equaled internal.company.com 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 attacker.com, the request would have gone to attacker.com in the first place. |
||||
|
|