Skip to content
Account takeover Write-up Intermediate

CVE-2017–1398

The WebSphere Commerce application reflected the Host header into HTML and other areas, allowing an attacker to rewrite it. This could enable password reset email poisoning, tricking users into sending reset tokens to a malicious site.

medium.com

Published on medium.com

During my first couple of months as a Pentester, I was tasked with a simple web application assessment of a Websphere Commerce site.

John M, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

During my first couple of months as a pentester I was tasked with a simple web application assessment of a Websphere Commerce site. One of the things I try to do on every assessment is run through a basic web app checklist to make sure I have followed each bit of my methodology. One such test is to look at issues related to the host header, and on this engagement that test led to finding CVE-2017-1398.

The flaw effectively allowed a malicious actor to rewrite the host header, which was then pulled into HTML and other areas of the application. My client's reset email contained no link, so I theorised that password reset email poisoning was possible using this CVE.

My client was not vulnerable to password reset email poisoning, because their reset email did not include a reset link at all (a whole different issue). I theorised that the poisoning was possible using this CVE, and went looking for a real world WebSphere Commerce site to demonstrate it on.

A note on scope: this CVE has been resolved across most instances, and the site shown below was the only public website I could find that was prepared to give me permission to test the theory. It uses custom URL structures, so I have had to redact more than I would like in order to maintain their privacy. Also, because of those custom URL structures, it is not clear whether custom coding has affected the outcome of my test. If you find a real world example using the default IBM URL structures, the author asks to be messaged on twitter.

Setup

The testing was done against a live WebSphere Commerce site whose owner gave permission to test the theory. The precondition for the attack is knowledge of a customer's email address, plus any other information the site needs in order to generate a password reset request. No other tooling, account setup or version detail is given in the report.

Finding it

The starting point was the standard host header test from a basic web app checklist. CVE-2017-1398 covers the host header being pulled into HTML and other areas of the application. The interesting question was not the reflection itself but what the application did with that value in security-sensitive flows, and the password reset email is the obvious candidate: if the reset link is assembled from the request's host header, the link in the victim's inbox points wherever the attacker says.

Exploitation

The attack is fairly simple. Find a customer's email address (and any other information needed to generate a password reset request), then when creating a password reset request, capture it using Burp Suite and rewrite the host header to a domain you control.

Step 1: capture the password reset request

Submit a password reset for the target customer's email address and intercept the request in Burp Suite. The request is the normal reset submission; the only part that changes is the host header.

Step 2: rewrite the host header

In the intercepted request, replace the host header value with a domain under the attacker's control. The example request below shows the header swapped out for attackerswebsite.com.

An example request, the highlighted host header has been swapped out for attackerswebsite.com From the original on medium.com

An example request, the highlighted host header has been swapped out for attackerswebsite.com

Step 3: the reset email is generated with the poisoned host

Forward the modified request. The application builds the password reset email using the host value from the request, so the link the victim receives points at the attacker's domain rather than the legitimate site.

The redacted password reset email, important to note that email templates change according to the brand and may even obscure the domain behind a link From the original on medium.com

The redacted password reset email, important to note that email templates change according to the brand and may even obscure the domain behind a link

Two things are worth noting about the email. Templates change according to the brand, and a template may even obscure the domain behind a link, so the poisoned host is not always visible to the recipient at a glance.

Root cause

The application takes the host header from the incoming request and uses it when constructing content, including the links in the password reset email, instead of using a value it controls itself, such as a configured canonical hostname. Because the header is attacker-controlled, the generated link follows the attacker's domain. The report does not describe which server-side component performs this substitution or what validation, if any, was present; the behaviour is demonstrated end to end rather than traced through the code.

Impact

The end result is that an attacker would be able to use this vulnerability to trick users into passing their password reset tokens to a malicious website under the attacker's control. The end result is that an attacker would be able to trick users into passing their password reset tokens to a malicious website under the attacker's control.

The impact depends on the reset flow actually containing a link built from the host header. My original client was not affected for exactly this reason: their email did not include a reset link. On the site used for the demonstration, the custom URL structures mean it is not certain whether custom coding influenced the result.

Fix

IBM validated the issue and released a fix in July 2017, and the CVE has been resolved across most instances. The report does not describe the contents of the fix. The general remedy for this class of bug is to stop trusting the request's host header when building links and other absolute URLs, and to use a configured canonical hostname instead.

Timeline

  • March 2017: issue discovered and reported to IBM
  • July 2017: IBM validate issue and release a fix
  • February 2019: this blog post detailing the vulnerability published

Variants to test

  • Password reset on other WebSphere Commerce instances. Submit a reset with the host header set to a domain you control and check the email that arrives. A positive result is a reset link whose host is your domain.
  • Other emails that contain links. Other emails that contain links may also be built from the host header. A positive result is any of them carrying a link to your domain after the header is rewritten.
  • Reflected host in HTML. The CVE also covers the host header being pulled into HTML and other areas. A positive result is the attacker-supplied host appearing in a page response where a canonical hostname is expected.
  • Default IBM URL structures. The demonstration used custom URL structures, so the outcome may be influenced by custom coding. Testing a site on the default IBM URL structures would show whether the behaviour is present without customisation.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

What happened, in plain words

A security tester was checking a website built with IBM WebSphere Commerce, a program that companies use to run online shops. While going through a standard checklist of things to test, they looked at how the site handled something called the host header. That header is a small piece of information your browser sends with every request to a website, telling the server which website name you are trying to reach. The tester found that the site took whatever value was in that header and used it to build parts of its web pages and other content. This was a known bug, tracked as CVE-2017-1398.

The most serious use of this bug is in the password reset feature. When you forget your password, you ask the site to send you an email with a link to reset it. That link normally points to the real site. But if the site builds the link using the host header from your request, an attacker can change that header to their own domain before the email is sent. Then the email you receive contains a link to the attacker's website instead of the real one. If you click it, the secret token in the link goes to the attacker's website instead of the real one.

The tester's original client was not vulnerable to this specific attack because their password reset email did not contain a link at all. So the tester set out to find a real website prepared to give permission to test the theory, and found one. They used a tool called Burp Suite to capture and modify the request. The site used custom URL structures, so the tester had to redact many details to protect the site's privacy, and it is not clear whether custom coding affected the result. The bug was reported to IBM in March 2017, fixed in July 2017, and this write-up was published in February 2019.

Background: what is a host header?

When your browser asks a web server for a page, it sends a request that includes several headers. One of them is the host header, which contains the domain name you typed (like www.example.com). This is necessary because one server can host many websites; the server uses the host header to know which site you want. If a website takes that value and uses it to build links or other content without checking it, an attacker can supply a different domain and trick the site into generating links to the attacker's domain. This is called host header poisoning.

The vulnerability: CVE-2017-1398

CVE-2017-1398 is a specific bug in IBM WebSphere Commerce that allowed an attacker to rewrite the host header, which was then used in HTML and other areas of the application. The report focuses on the password reset flow because that is where the impact is highest: if the reset link is built from the host header, the attacker can direct the victim's reset token to their own server.

The test: step by step

The attack is simple. First, find a customer's email address (and any other information needed to generate a password reset request). Then, when creating a password reset request, capture it using Burp Suite and rewrite the host header to a domain you control.

Step 1: capture the password reset request

Go to the site's password reset page and enter the victim's email address. Before you submit, start Burp Suite so it can intercept the request. Burp Suite is a tool that sits between your browser and the server, letting you see and change requests. When you submit the form, Burp Suite pauses the request so you can edit it.

Step 2: rewrite the host header

In the intercepted request, find the host header and change its value to a domain you control, for example attackerswebsite.com. The image below shows an example request where the host header has been swapped out.

An example request, the highlighted host header has been swapped out for attackerswebsite.com From the original on medium.com

An example request, the highlighted host header has been swapped out for attackerswebsite.com

The request above is a normal password reset submission, except that the host header now points to attackerswebsite.com.

Step 3: the reset email is generated with the poisoned host

Forward the modified request. The application builds the password reset email using the host value from the request, so the link the victim receives points at the attacker's domain rather than the legitimate site. The image below shows the redacted password reset email that arrives.

The redacted password reset email, important to note that email templates change according to the brand and may even obscure the domain behind a link From the original on medium.com

The redacted password reset email, important to note that email templates change according to the brand and may even obscure the domain behind a link

Two things are worth noting about the email. Templates change according to the brand, and a template may even obscure the domain behind a link, so the poisoned host is not always visible to the recipient at a glance.

Why it works: root cause

The application takes the host header from the incoming request and uses it when constructing content, including the links in the password reset email, instead of using a value it controls itself, such as a configured canonical hostname. Because the header is attacker-controlled, the generated link follows the attacker's domain. The report does not describe which server-side component performs this substitution or what validation, if any, was present; the behaviour is demonstrated end to end rather than traced through the code.

Impact

The end result is that an attacker would be able to use this vulnerability to trick users into passing their password reset tokens to a malicious website under the attacker's control. The end result is that an attacker would be able to trick users into passing their password reset tokens to a malicious website under the attacker's control.

The impact depends on the reset flow actually containing a link built from the host header. The tester's original client was not affected for exactly this reason: their email did not include a reset link. On the site used for the demonstration, the custom URL structures mean it is not certain whether custom coding influenced the result.

Fix

IBM validated the issue and released a fix in July 2017, and the CVE has been resolved across most instances. The report does not describe the contents of the fix. The general remedy for this class of bug is to stop trusting the request's host header when building links and other absolute URLs, and to use a configured canonical hostname instead.

Timeline

  • March 2017: issue discovered and reported to IBM
  • July 2017: IBM validate issue and release a fix
  • February 2019: this blog post detailing the vulnerability published

Variants to test

  • Password reset on other WebSphere Commerce instances. Submit a reset with the host header set to a domain you control and check the email that arrives. A positive result is a reset link whose host is your domain.
  • Other emails that contain links. Other emails that contain links may also be built from the host header. A positive result is any of them carrying a link to your domain after the header is rewritten.
  • Reflected host in HTML. The CVE also covers the host header being pulled into HTML and other areas. A positive result is the attacker-supplied host appearing in a page response where a canonical hostname is expected.
  • Default IBM URL structures. The demonstration used custom URL structures, so the outcome may be influenced by custom coding. Testing a site on the default IBM URL structures would show whether the behaviour is present without customisation.

Glossary

  • Host header: A piece of information your browser sends with every web request, telling the server which website name you are trying to reach.
  • CVE: Common Vulnerabilities and Exposures, a unique identifier for a publicly known security flaw.
  • WebSphere Commerce: An IBM product that companies use to run online shops and manage e-commerce.
  • Password reset flow: The process a website uses to let you reset your password, usually by sending an email with a special link.
  • Token: A long random code that acts like a temporary password, used to prove you are allowed to perform an action such as resetting a password.
  • Burp Suite: A tool that sits between your browser and a web server, letting you intercept, view and modify web requests.
  • Host header poisoning: A vulnerability where a website trusts the host header from a request and uses it to build links or other content, allowing an attacker to redirect those links to a domain they control.
  • Canonical hostname: The official, correct domain name for a website, which the site should use when building links instead of trusting the request.
  • Reflected host: When a value from a request (like the host header) is echoed back in the response, such as in HTML.
  • Custom URL structures: Non-standard ways of organising web addresses, which may involve custom code that could affect test results.
  • Redact: To hide or remove sensitive information from a document or screenshot.
  • CVE-2017-1398: The specific identifier for the host header poisoning bug in IBM WebSphere Commerce described in this report.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.