title: Fix Host header attack Vulnerability in Codeigniter
body: <p>I was asked to solve a security issue in a codeigniter application hosted on a windows server <strong>IIS</strong> and here is the description of the issue. I believe it has come from reporting software called "Acunetix".</p>
  
  <blockquote>
    <p>Host header attack</p>
    
    <p>Vulnerability description</p>
    
    <p>An attacker can manipulate the Host header as seen by the web application and cause the application to behave in unexpected ways. Developers often resort to the exceedingly untrustworthy HTTP Host header         (_SERVER["HTTP_HOST"] in PHP). Even otherwise-secure applications trust this value enough to write it to the page without HTML-encoding it with code equivalent to: </p>
  
  <pre><code>   &lt;link href="http://_SERVER['HOST']"    (Joomla)
     ...and append secret keys and tokens to links containing it: 
     &lt;a href="http://_SERVER['HOST']?token=topsecret"&gt;  (Django, Gallery, others)
     ....and even directly import scripts from it: 
     &lt;script src="http://_SERVER['HOST']/misc/jquery.js?v=1.4.4"&gt;  (Various)
  </code></pre>
    
    <p>Affected items</p>
    
    <ul>
    <li>/techP/user/forget </li>
    <li>/techP/user/login </li>
    <li>/techP/user/loginexec </li>
    <li>/techP/user/register </li>
    </ul>
    
    <p>The impact of this vulnerability</p>
    
    <p>An attacker can manipulate the Host header as seen by the web application and cause the application to behave in unexpected ways.</p>
    
    <p>How to fix this vulnerability</p>
    
    <p>The web application should use the SERVER_NAME instead of the Host header. It should also create a dummy vhost that catches all requests with unrecognized Host headers. This can also be done under Nginx     by specifying a non-wildcard SERVER_NAME, and under Apache by using a non-wildcard serverName and turning the UseCanonicalName directive on. Consult references for detailed information.</p>
  </blockquote>
  
  <p>I did not understand what the actual problem is, so can some one explain briefly how to fix this?</p>