Skip to content
Path traversal Disclosed report Intermediate CVE-2021-22151

Fix for CVE-2021-22151 (Kibana path traversal issue) can be bypassed on Windows

The fix for a Kibana path traversal issue only checked whether a normalised path started with '..', which fails on Windows because a drive-letter prefix survives normalisation. An attacker on a Windows install could therefore read arbitrary .pbf files outside the fonts directory.

dee-see Follow

Originally disclosed on HackerOne

  • Triaged in 9 days
  • Fixed in 48 days
  • Paid in 9 days
  • Disclosed after 48 days

Summary

Hello team, I hope you're doing well! I was combing through your GitHub repository to look at the fixes for recent security releases and found the fix for CVE-2021-22151 to be incomplete. The current fix makes assumptions that are true on Linux but that don't hold on Windows.

Details

The fixed code looks like this

TypeScript
      const range = path.normalize(request.params.range);
      return range.startsWith('..')
        ? response.notFound()
        : new Promise((resolve) => {
            const fontPath = path.join(__dirname, 'fonts', 'open_sans', `${range}.pbf`);
            fs.readFile(fontPath, (error, data) => {
                // snipped
            });
          });

The assumption is that any path traversal attempts, once normalized, will start with ... This seems to hold on Linux, however on Windows this can happen (using the NodeJS REPL for demonstration here):

JavaScript
> let range = path.normalize('c:../../../../../../../path_traversal')
undefined
> console.log(range)
c:..\..\..\..\..\..\..\path_traversal
> range.startsWith('..')
false
> const fontPath = path.join(__dirname, 'fonts', 'open_sans', `${range}.pbf`);
undefined
> console.log(fontPath)
c:\path_traversal.pbf

Path traversal happened even if the range didn't start with ...

Steps to reproduce

This requires Kibana to be installed on Windows.

  1. Put a .pbf file somewhere on disk for demonstration. I did it with echo hax > c:\path_traversal.pbf
  2. Visit http://localhost:5601/api/maps/fonts/open_sans/c%3A..%2F..%2F..%2F..%2F..%2F..%2F..%2Fpath_traversal and the file from the previous step will be downloaded
    1. You might need to add some ..%2f depending on how deep Kibana is installed.

Remediation

Thom Heymann already had a great suggestion in their code review

The best way to solve this is to resolve the path from range and ensure it is inside your fonts directory.

I think this would fix the issue once and for all!

Impact

Path traversal disclosing .pbf files

The original report as published on HackerOne, by dee-see. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The validation assumed a normalised traversal path always begins with '..', which is untrue on Windows where a drive-letter prefix such as 'c:' remains and defeats the startsWith check.

Impact

Path traversal disclosing .pbf files, but only on Kibana installations running on Windows.

What the attacker needed

Kibana installed on Windows; Attacker can reach the maps fonts endpoint

The fix

The path should be resolved from the range value and then checked to ensure it stays inside the fonts directory, rather than relying on a prefix check.

How it was found

  1. Place a .pbf file somewhere on the Windows disk for the demonstration.
  2. Request the maps fonts endpoint with a crafted range value containing a drive letter and encoded parent-directory segments.
  3. The file placed on disk is downloaded in the response.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Kibana serves font files from a folder and takes part of the file name from the web address. The old fix tried to block tricks like '../' (which means 'go up a folder') by checking the cleaned-up path, but on Windows a path can start with a drive letter like 'c:' and still climb out of the folder. So a crafted web address could make the server hand back a file from elsewhere on the disk.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by dee-see

View all

9 more disclosed reports, best first.

More from Elastic

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.