Skip to content
XSS Write-up Intermediate

XSS bypass using META tag in realestate.postnl.nl

A reflected cross-site scripting flaw existed in the Lang parameter of a PostNL real estate subdomain, where input was placed inside a META tag's content attribute. By injecting an http-equiv refresh directive, an attacker could redirect victims to another site or execute script via a data URI.

Prial Islam Khan Follow

Published on medium.com

{{media:0}}

Prial Islam Khan, 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. 4 min read.

Context

realestate.postnl.nl is a web property belonging to PostNL, and the researcher reported the issue through the postnl.nl bug bounty programme. The vulnerable feature is the Lang query parameter on the site root. The application reflects the value of Lang into the content attribute of a <meta name="language"> tag in the page source. That reflection is the whole attack surface described in the report: there is no login, no account and no privileged role involved.

Setup

No special tooling is described. The researcher worked with a browser and the page source, sending payloads in the Lang parameter of the endpoint:

Text
http://realestate.postnl.nl/?Lang=

Finding it

To test for ordinary reflected XSS, the researcher submitted "><xsstest> in Lang. The value was reflected inside the META tag, and the resulting source looked like this:

HTML
<meta name="language" content=""><xsstest>" />

That is a plain reflection with no encoding of the angle brackets or quotes. The next payload, "><img src=x>, did not execute. The researcher drew two conclusions from the attempts with many HTML tags:

  • any valid HTML tag is not allowed;
  • arbitrary attributes can be created.

So the filter blocked tags but left attribute injection open. The researcher then looked up META tag attributes and focused on http-equiv. The relevant behaviour is that http-equiv lets you define the equivalent of an HTTP header in HTML, and with the value refresh it can redirect a user to another page.

Exploitation

Step 1: confirm attribute injection and open redirect

The researcher submitted the following value in Lang:

Text
0;http://evil.com"HTTP-EQUIV="refresh"

The response source was:

HTML
<meta name="language" content="0;http://evil.com"HTTP-EQUIV="refresh"" />

The injected quote closes the content attribute, and the injected HTTP-EQUIV="refresh" adds a second attribute to the same META tag. The browser treats the tag as a refresh directive and redirects to evil.com, giving an open redirect.

Step 2: try a JavaScript URI

The next attempt used a javascript: URI in the same refresh construction:

Text
0;javascript:alert(1)"HTTP-EQUIV="refresh"

The report says this was triaged for the keyword javascript used in the payload.

Step 3: bypass with a Base64 data URI

To avoid the javascript keyword, the researcher encoded the script as a data URI:

Text
0;data:text/html;base64,[redacted]=="HTTP-EQUIV="refresh"

The response source was:

HTML
<meta name="language" content="0;data:text/html;base64,[redacted]=="HTTP-EQUIV="refresh"" />

Visiting the encoded URL:

Text
http://realestate.postnl.nl/?Lang=0%3Bdata%3Atext%2fhtml%3Bbase64%[redacted]%3D%3D%22HTTP-EQUIV%3D%22refresh%22

produced the XSS popup.

Image for post
Image for post From the original on medium.com

Step 4: report and observe the first fix

The researcher reported the issue through the Zerocopter report form. A fix was deployed that blacklisted the keyword data:text/html;base64, in the same way the javascript keyword had been blacklisted. The open redirect still worked, however, when a user visited:

Text
http://realestate.postnl.nl/?Lang=0%3Bhttp%3A%2f%2fevil.com%22HTTP-EQUIV%3D%22refresh%22
Image for post
Looks cool πŸ™„πŸ™„πŸ™„ From the original on medium.com

Step 5: final fix

The issue was fixed again, and the researcher was listed on the PostNL Hall of Fame page and offered some goodies.

Image for post
😍😍😍 From the original on medium.com

Root cause

The Lang parameter is written into the content attribute of a META tag without encoding quotes or angle brackets. The application rejected HTML tags, and later the strings javascript and data:text/html;base64 were blocked. Because the quote character was still allowed through, an attacker could close the content attribute and add a new http-equiv="refresh" attribute to the same tag. The refresh directive then accepts a URL, and a data:text/html;base64 URI carries the script past the keyword filter.

Impact

An attacker who can get a victim to open a crafted link can execute script in the context of realestate.postnl.nl (reflected XSS), or redirect the victim to an arbitrary site (open redirect). Both require the victim to visit the attacker-supplied URL. The report does not describe any authentication, stored payload or other precondition beyond that visit.

Fix

The report states that the application blacklisted data:text/html;base64 after the first report, and that the issue was fixed again after the open redirect was shown to survive. It does not describe the final change. The durable fix is to HTML-encode the reflected value so quotes and angle brackets cannot break out of the content attribute, rather than extending the keyword blacklist.

Variants to test

  1. Attribute injection in any reflected parameter. Submit a value containing a double quote and a new attribute, for example x" onmouseover="alert(1), and check whether the response source shows a second attribute on the element. A positive result is a new attribute appearing outside the original quoted value.
  2. META refresh with a data URI. Where a reflection lands inside a META tag, try 0;data:text/html;base64,<base64 script>"HTTP-EQUIV="refresh". A positive result is the browser navigating to the decoded data URI and running the script.
  3. Keyword blacklist probing. Send javascript: and data:text/html;base64 variants and observe which are rejected; then try alternative schemes or encodings that reach the same sink. A positive result is a payload that executes while the blocked keywords are absent.
  4. Open redirect via refresh. Submit 0;https://example.org"HTTP-EQUIV="refresh" and check whether the browser is redirected. A positive result is navigation to the external host without any script executing.
  5. Tag versus attribute filtering. Send a bare valid tag such as <img src=x> and then an attribute-only payload. If the tag is stripped but the attribute injection survives, the filter is incomplete.

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. 11 min read.

What happened, in plain words

A security researcher found a way to make a PostNL website run code of his choosing, and separately to send visitors off to another website. The site is realestate.postnl.nl, a web property belonging to PostNL. The researcher reported the problem through the postnl.nl bug bounty programme, which is a scheme where companies invite people to report security problems in exchange for recognition or a reward.

The weak spot was a single piece of the web address: the Lang parameter. When you open a page, the address can carry extra pieces of information after a question mark, and each of those is called a parameter. The site took whatever was in Lang and pasted it into the page's source code without cleaning it first. That is the whole attack surface described here: no login, no account and no special role were involved.

Prial Islam Khan
Prial Islam Khan From the original on medium.com

The idea you need first: what a page's source code is

When your browser loads a web page, the server sends back text. Your browser reads that text and draws the page from it. That text is the page's source code, written in a language called HTML. HTML is made of tags, which are instructions in angle brackets like <meta ...> or <img ...>. A tag can carry extra settings called attributes, written as name="value" inside the tag.

A <meta> tag is a tag that gives the browser information about the page rather than showing anything on screen. One common use is telling the browser what language the page is in.

Here is the important part. If a website takes something a visitor typed and pastes it into that source code without cleaning it, the visitor can type characters that the browser will read as new HTML rather than as harmless text. The two characters that matter most are the double quote " and the angle brackets < and >. A double quote can end an attribute early, and angle brackets can start a whole new tag.

When a site pastes a visitor's input straight back into the page it returns, that is called reflection, and if the pasted input can run code, the bug is called reflected cross-site scripting, usually shortened to XSS. Cross-site scripting means an attacker gets their own code to run inside a page that belongs to the real site, so the browser treats that code as if the site itself had written it.

Setting up

The report describes no special tools. The researcher used a browser and looked at the page source, sending test values in the Lang parameter of this address:

Text
http://realestate.postnl.nl/?Lang=

Everything after ? is the query string, and Lang= is one parameter in it with an empty value. To send a test value you simply put it after the equals sign. To see what came back, you view the page source in the browser, which shows the text the server actually sent rather than the finished picture.

Finding it

To test for ordinary reflected XSS, the researcher sent this value in Lang:

Text
"><xsstest>

This is a probe. The "> part is designed to close whatever attribute the value lands inside, and <xsstest> is a made-up tag that does nothing. If the made-up tag shows up in the source as a real tag, the site is not cleaning the input, and the door is open.

The value came back inside the META tag, and the resulting source looked like this:

HTML
<meta name="language" content=""><xsstest>" />

Line by line: <meta name="language" starts a META tag that says the page language. content="" is the attribute holding the language value, and the researcher's "> closed it early, which is why the quotes look doubled up. Then <xsstest> appears as a separate tag of its own, and the leftover " /> is the tail of the original tag. Nothing was encoded: the angle brackets and quotes went through exactly as typed. Encoding, in this context, means replacing dangerous characters with safe stand-ins so the browser reads them as text and not as instructions.

The next payload was:

Text
"><img src=x>

This tries to insert an image tag pointing at a file called x that does not exist. It did not run. After trying many HTML tags, the researcher drew two conclusions:

  • any valid HTML tag is not allowed;
  • arbitrary attributes can be created.

In plain words: the site had a filter that removed or rejected real tags like <img>, but it still let the quote character through, so a visitor could still add new attributes to the existing META tag. A filter that blocks some strings but not the underlying problem is called a blacklist, and blacklists are fragile because there is usually another way to write the same thing.

So the researcher looked up what attributes a META tag can have, and focused on one called http-equiv.

The behaviour that matters is this: http-equiv lets a page define the equivalent of an HTTP header in HTML. HTTP headers are small pieces of information a server sends alongside a page, and one of them can tell the browser to go somewhere else. With the value refresh, the META tag becomes a redirect instruction: the browser reads it and navigates to another address. A redirect that will send a visitor to any address someone supplies is called an open redirect.

Exploitation

Step 1: confirm attribute injection and open redirect

The researcher sent this value in Lang:

Text
0;http://evil.com"HTTP-EQUIV="refresh"

The response source was:

HTML
<meta name="language" content="0;http://evil.com"HTTP-EQUIV="refresh"" />

Line by line: the site pasted the value into content="...". The " in the payload closed the content attribute early, so content now holds 0;http://evil.com. Then HTTP-EQUIV="refresh" was read by the browser as a brand new attribute on the same META tag, and the trailing " from the payload plus the site's own closing " are leftovers. Because the tag now carries a refresh instruction, the browser redirects to evil.com. The 0; at the start is the delay in seconds, so zero means go immediately. evil.com is a placeholder domain used in examples, not a real target.

Step 2: try a JavaScript URI

The next attempt used a javascript: URI in the same refresh construction:

Text
0;javascript:alert(1)"HTTP-EQUIV="refresh"

A URI is just an address. The javascript: scheme is a special kind of address that tells the browser to run the code that follows instead of loading a page, and alert(1) is a tiny built-in function that pops up a box saying 1. If this worked, it would prove code execution.

The report says this was triaged for the keyword javascript used in the payload. In other words, the site had added javascript to its blacklist and was now blocking that word.

Step 3: bypass with a Base64 data URI

To avoid the javascript keyword, the researcher encoded the script as a data URI:

Text
0;data:text/html;base64,[redacted]=="HTTP-EQUIV="refresh"

A data URI is an address that carries the content itself instead of pointing at a file on a server. The text/html part says the content is a web page, and base64, says the rest is Base64, which is a way of writing any data using only ordinary letters, digits and a few symbols. Base64 is not encryption; anyone can decode it. The point here is that the decoded content contains no javascript word, so the blacklist does not notice it.

The response source was:

HTML
<meta name="language" content="0;data:text/html;base64,[redacted]=="HTTP-EQUIV="refresh"" />

Line by line: the same trick as before. The quote closes content, the injected HTTP-EQUIV="refresh" becomes a second attribute, and the browser is told to refresh to the data URI. A <script> tag tells the browser to run the code inside it, and prompt shows a box asking the visitor to type something. So the decoded page is a tiny page whose only job is to run that one line.

Visiting the encoded URL:

Text
http://realestate.postnl.nl/?Lang=0%3Bdata%3Atext%2fhtml%3Bbase64%[redacted]%3D%3D%22HTTP-EQUIV%3D%22refresh%22

produced the XSS popup. The %3B, %3A, %2F and %3D pieces are percent-encoding, a way of writing characters that are awkward in a web address, such as ;, :, / and =, so the browser sends them intact. This is the same payload as above, just written in the form a browser can put in the address bar.

Image for post
Image for post From the original on medium.com

Step 4: report and observe the first fix

The researcher reported the issue through the Zerocopter report form. Zerocopter is a platform that companies use to receive security reports. A fix was then deployed that blacklisted the keyword data:text/html;base64, in the same way the javascript keyword had been blacklisted. Blacklisting means adding a word to a list of things to block.

The open redirect still worked, however, when a user visited:

Text
http://realestate.postnl.nl/?Lang=0%3Bhttp%3A%2f%2fevil.com%22HTTP-EQUIV%3D%22refresh%22

This is the Step 1 payload again, percent-encoded for the address bar. It contains no script at all, just a redirect to evil.com, so blocking the data URI keyword did nothing to stop it. That is the weakness of blacklists: each fix only closes the exact spelling that was reported.

Image for post
Looks cool πŸ™„πŸ™„πŸ™„ From the original on medium.com

Step 5: final fix

The issue was fixed again, and the researcher was listed on the PostNL Hall of Fame page and offered some goodies. A Hall of Fame is a public page where a company thanks the people who reported problems.

Image for post
😍😍😍 From the original on medium.com

Root cause

The Lang parameter is written into the content attribute of a META tag without encoding quotes or angle brackets. The application rejected HTML tags and later blocked certain keywords. Output encoding means converting dangerous characters into safe stand-ins before they are placed in the page, so they can never be read as instructions. HTML tags were rejected, and later the strings javascript and data:text/html;base64 were blocked. Because the quote character was still allowed through, an attacker could close the content attribute and add a new http-equiv="refresh" attribute to the same tag. The refresh directive then accepts a URL, and a data:text/html;base64 URI carries the script past the keyword filter.

Impact

An attacker who can get a victim to open a crafted link can execute script in the context of realestate.postnl.nl (reflected XSS), or redirect the victim to an arbitrary site (open redirect). Running script in the context of a site means the browser treats the code as coming from that site, so it can do things the site itself could do. Both attacks require the victim to visit the attacker-supplied URL. The report does not describe any authentication, stored payload or other precondition beyond that visit.

Fix

The report states that the application blacklisted data:text/html;base64 after the first report, and that the issue was fixed again after the open redirect was shown to survive. It does not describe the final change. The durable fix is to HTML-encode the reflected value so quotes and angle brackets cannot break out of the content attribute, rather than extending the keyword blacklist.

Variants to test

  1. Attribute injection in any reflected parameter. Submit a value containing a double quote and a new attribute, for example x" onmouseover="alert(1), and check whether the response source shows a second attribute on the element. A positive result is a new attribute appearing outside the original quoted value.
  2. META refresh with a data URI. Where a reflection lands inside a META tag, try 0;data:text/html;base64,<base64 script>"HTTP-EQUIV="refresh". A positive result is the browser navigating to the decoded data URI and running the script.
  3. Keyword blacklist probing. Send javascript: and data:text/html;base64 variants and observe which are rejected; then try alternative schemes or encodings that reach the same sink. A positive result is a payload that executes while the blocked keywords are absent.
  4. Open redirect via refresh. Submit 0;https://example.org"HTTP-EQUIV="refresh" and check whether the browser is redirected. A positive result is navigation to the external host without any script executing.
  5. Tag versus attribute filtering. Send a bare valid tag such as <img src=x> and then an attribute-only payload. If the tag is stripped but the attribute injection survives, the filter is incomplete.

Glossary

  • Parameter: a named piece of information in a web address, after the question mark, such as Lang in ?Lang=.
  • Query string: everything after the ? in a web address, made of one or more parameters.
  • Source code: the text a server sends that the browser turns into a page.
  • HTML: the language web pages are written in, made of tags in angle brackets.
  • Tag: an instruction in HTML, such as <meta> or <img>.
  • Attribute: a setting inside a tag, written as name="value".
  • META tag: an HTML tag that gives the browser information about the page rather than showing content.
  • Reflection: when a site pastes a visitor's input straight back into the page it returns.
  • XSS (cross-site scripting): a bug where an attacker's code runs inside a page belonging to the real site.
  • Reflected XSS: XSS where the malicious input is sent in a request and reflected back in the response.
  • Encoding (output encoding): replacing dangerous characters with safe stand-ins so the browser reads them as text, not instructions.
  • Blacklist: a list of strings a filter blocks; it only stops the exact spellings listed.
  • http-equiv: a META tag attribute that defines the equivalent of an HTTP header in HTML.
  • HTTP header: a small piece of information sent alongside a page, such as a redirect instruction.
  • Refresh directive: a META tag setting that tells the browser to navigate to another address after a delay.
  • Open redirect: a redirect that will send a visitor to any address someone supplies.
  • URI: an address, such as a web address.
  • javascript: URI: an address that tells the browser to run the code that follows.
  • Data URI: an address that carries the content itself instead of pointing at a file on a server.
  • Base64: a way of writing any data using only ordinary characters; not encryption, anyone can decode it.
  • Percent-encoding: a way of writing awkward characters in a web address, such as %3B for ;.
  • Bug bounty programme: a scheme where companies invite people to report security problems in exchange for recognition or a reward.
  • Triaged: reviewed and accepted as a real issue by the receiving team.
  • Zerocopter: a platform companies use to receive security reports.
  • Hall of Fame: a public page where a company thanks the people who reported problems.
  • Context (of a site): the browser's view that code belongs to a particular site, so it can do what that site could do.

More by Prial Islam Khan

View all

8 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.