Base Tag Hijacking

Severity: Medium

Invicti detected that it's possible to control the href attribute of base tag in the HTML. base tag allows an attacker to control the base path for all of the resources, this can allow an attacker to load external scripts and resources to execute JavaScript on the context of the page hence the impact would be same with a cross-site scripting attack. Cross-site scripting allows an attacker to execute a dynamic script (JavaScript, VBScript) in the context of the application.

This allows several different attack opportunities, mostly hijacking the current session of the user or changing the look of the page by changing the HTML on the fly to steal the user's credentials. This happens because the input entered by a user has been interpreted as HTML/JavaScript/VBScript by the browser. Cross-site scripting targets the users of the application instead of the server. Although this is a limitation, since it allows attackers to hijack other users' sessions, an attacker might attack an administrator to gain full control over the application.

Depending on the content of the page this vulnerability might not be directly exploitable. When it's exploitable there are many different attacks that can be leveraged through the use of cross-site scripting, including:
  • Hijacking user's active session.
  • Mounting phishing attacks.
  • Intercepting data and performing man-in-the-middle attacks.
Do not allow user input to control the base tag. Whitelist it if the dynamic usage is necessary. Content-Security-Policy (CSP) base-uri directive can also help you prevent to change the <base> tag element. The base-uri directive defines the URIs that a user agent may use as the document base URL.
Content-Security-Policy: base-uri 'self'

Build your resistance to threats. And save hundreds of hours each month.

Get a demo See how it works