Bypass front server restrictions and access to forbidden files and directories through X-Rewrite-Url/X-original-url header on account.mackeeper.com
The front nginx server blocks access to the /admin directory with a 403 response, but the back-end server processes the X-Rewrite-Url and X-original-url headers, allowing an attacker to bypass the restriction and reach the admin login page.
Originally disclosed on HackerOne
- Triaged in 1 hour
- Fixed in 3 months
- Paid in 11 days
- Disclosed after 6 months
Summary by the program
Summary
Normally a client can't access /admin directory because of front nginx server which returns 403. But we can use X-Rewrite-Url or X-original-url because back server processes these headers and front server doesn't.
Steps to reproduce:
This request shows normal behavior
curl -i -s -k -X $'GET' -H $'Host: account.mackeeper.com' $'https://account.mackeeper.com/admin/login'
and returns 403
Here you can see how we can bypass these restrictions
curl -i -s -k -X $'GET' -H $'Host: account.mackeeper.com' -H $'X-rewrite-url: admin/login' $'https://account.mackeeper.com/'
and return login page
What the report shows
The target is account.mackeeper.com, part of the Clario program on HackerOne. The researcher, rumiljonov, reported a misconfiguration that let a client reach files and directories the front server was supposed to keep out of reach. The report was rated medium severity with a CVSS score of 6.1, paid a bounty of 300.00 USD, and was disclosed on 2020-05-15.
The feature at issue is the /admin directory. Under normal conditions the front nginx server answers requests for it with 403, so a client cannot get in. The researcher found that the back-end server processes certain rewrite headers that the front server does not, and that sending one of those headers lets the request reach the back end as if it were aimed at a different path.
Step by step:
- Confirm the normal behaviour. A plain request to the admin login path is refused by the front server:
curl -i -s -k -X $'GET' -H $'Host: account.mackeeper.com' $'https://account.mackeeper.com/admin/login'
This returns 403.
- Send the same logical request to the site root, but add a rewrite header that names the protected path:
curl -i -s -k -X $'GET' -H $'Host: account.mackeeper.com' -H $'X-rewrite-url: admin/login' $'https://account.mackeeper.com/'
This returns the login page instead of a 403.
The report names two headers, X-Rewrite-Url and X-original-url, and demonstrates the bypass with X-rewrite-url. The front server evaluates the request path it sees, which is /, and lets it through; the back server then honours the rewrite header and serves admin/login. The outcome is that the front server's restriction on the admin directory is bypassed and the login page is reachable.
The report does not describe any further exploitation beyond reaching the login page, and it does not state what fix was applied.
Root cause
The front nginx server blocks /admin with 403, while the back server processes X-Rewrite-Url and X-original-url. The front nginx server makes its access decision on the request line, so a request for / passes its rules. The back-end server processes a client-supplied rewrite header that the front server does not, so the request reaches the protected path. The header is accepted by the back end even though the front server does not act on it.
In other words, the access control is enforced on one representation of the request (the URL) while the resource is selected using another (the header). Any control that only inspects the first representation can be sidestepped.
Impact
The direct impact shown is access to a directory the front server intended to block: the admin login page becomes reachable through the bypass. The report's title refers to forbidden files and directories, but the only path demonstrated is the admin login page. What an attacker could do with that access once inside is not demonstrated in the report; the finding is the bypass of the restriction itself, which is why it sits at medium severity rather than higher.
How this kind of bug works
Many deployments put a reverse proxy or CDN in front of an application. The proxy terminates TLS, applies host and path rules, blocks sensitive prefixes, and forwards what is left. The application behind it may support headers that let a client or an upstream layer indicate the "real" URL: common names include X-Rewrite-Url, X-Original-URL, X-Forwarded-Prefix and similar. These exist so that a proxy can rewrite paths without breaking link generation or routing in the application.
The bug appears when the proxy does not strip or reject these headers from untrusted clients, and the back end gives them precedence over the request line. The proxy authorises one path; the application serves another. The same class of problem appears with path normalisation differences (encoded slashes, dot segments, case, trailing characters), where the proxy and the application parse the path differently and each believes it is enforcing the same rule.
Defences are straightforward in principle: strip or reject routing headers at the edge, make the proxy and the application agree on exactly one canonical path, and enforce authorisation at the layer that actually selects the resource rather than only at the perimeter.
How to test for it
- Identify paths that the front layer refuses. Request a known sensitive prefix such as an admin area, a status page or a backup directory and note the response. A 403 or a generic block page from the proxy is the signal to dig further.
- Send the same request to a path the proxy allows, typically
/or a public page, and add one candidate rewrite header at a time, with the value set to the protected path without a leading slash. Try the header names the report uses:X-Rewrite-UrlandX-original-url. - Compare responses. A positive result is a response body or status that matches what the protected path would return, for example the admin login page appearing where the root page was expected, or a 200 where the direct request gave 403.
Confirm by requesting a path that should not exist and checking that the response differs. Also confirm the back end is really serving the protected resource, not just echoing the header value back.
How it is fixed
The report does not state what fix was applied. Where the application genuinely needs such a header, it should come only from the trusted proxy, and the proxy should overwrite any client value rather than pass it through. Beyond that, access control should be enforced at the application layer for the resource actually being served, not only at the perimeter, and proxy and application should be configured to normalise paths identically. Blocking the sensitive prefixes at the back end as well as the front removes the single point of failure.
Hunting notes
This bug class hides wherever a proxy, CDN or WAF sits in front of an application that supports URL-override headers. Good places to look are admin panels, internal tooling, debug and status endpoints, and anything the edge blocks with a distinctive 403.
Demonstrate that the content returned is the protected resource and not a generic page. Keep the scope to what you actually observed.
What happened, in plain words
This report is about a website called account.mackeeper.com, which belongs to a company running a bug bounty programme on HackerOne. A bug bounty programme is a deal where a company says: if you find a security problem in our systems and tell us privately, we will pay you. The researcher who found this one is credited as rumiljonov. The problem was rated medium severity, given a CVSS score of 6.1, paid a bounty of 300.00 USD, and made public on 2020-05-15. CVSS is a standard scoring system that turns the seriousness of a flaw into a number, where higher means worse.
The site is account.mackeeper.com, and it contains a directory called /admin. Inside that site there is a directory called /admin. A directory is just a folder on a web server, and /admin is the conventional name for the part of a site reserved for staff. The company did not want ordinary visitors reaching it.
To understand the flaw, you need a small picture of how a modern website is built. Often there are two computers in a row. The first one, the front server, faces the internet. It is like a receptionist in a building lobby: it checks who is coming in, looks at where they say they are going, and turns away anyone heading somewhere they should not. Behind it sits the back-end server, the computer that actually holds the pages and data. The front server here runs a piece of software called nginx, a very common web server. When someone asked for the admin area, nginx answered with 403, which is the standard HTTP status code for "forbidden". HTTP status codes are the short numbers a server sends back to say how a request went: 200 means fine, 404 means not found, 403 means you are not allowed.
The researcher noticed something the receptionist and the back office disagreed about. The back-end server processes certain headers, such as X-rewrite-url, that the front server does not. The front server did not read that header at all. So a visitor could walk up to the receptionist, ask for the front door (the site root, /), be waved through, and then hand the back office a note saying "by the way, I meant the admin area". The back office obeyed the note. That is the whole bug: the check was made on one thing, and the page was chosen using another.
Step 1: show the normal behaviour
First the researcher confirmed that the admin area really is blocked. This command sends a plain request to the admin login page:
curl -i -s -k -X $'GET' -H $'Host: account.mackeeper.com' $'https://account.mackeeper.com/admin/login'
Line by line:
curlis a free command-line tool for sending web requests by hand, without a browser.-itells it to show the response headers as well as the page body, so you can see the status code.-shides the progress meter, keeping the output clean.-ktells curl to ignore certificate problems. Certificates are the padlocks that prove a site is genuine; skipping the check is common in testing.-X $'GET'sets the method to GET, which is the ordinary "please give me this page" request a browser makes when you open a link.-H $'Host: account.mackeeper.com'sets the Host header. The Host header is how a request says which website on a shared server it wants, a bit like writing a department name on an envelope sent to one building.- The last part is the address being requested.
This returned 403. That matters because it proves the restriction exists and is working when you ask for the admin path directly.
Step 2: bypass the restriction
The second command asks for the harmless site root, but adds a header naming the protected path:
curl -i -s -k -X $'GET' -H $'Host: account.mackeeper.com' -H $'X-rewrite-url: admin/login' $'https://account.mackeeper.com/'
This is the same command with two changes. The address at the end is now just /, the site root, which the front server allows. And there is a new line, -H $'X-rewrite-url: admin/login', which adds a header called X-rewrite-url carrying the value admin/login. The report also names a second header, X-original-url.
This returned the login page instead of a 403. The front server looked at the address, saw /, and let it through. The back-end server then read the rewrite header and served admin/login. The restriction was bypassed.
The report stops there: it shows the login page being reached, and does not describe anything done after that, nor what fix the company applied. The finding is the bypass itself.
In general, how this kind of bug works
Many websites put a reverse proxy or CDN in front of the application. A reverse proxy is the receptionist above: a server that sits between the internet and the real application, handling encryption, blocking bad traffic and forwarding the rest. A CDN is a network of such servers spread around the world. The application behind may support headers that say "the real address is this one", so the proxy can rearrange paths without breaking the application's own links and routing. X-Rewrite-Url, X-Original-URL and X-Forwarded-Prefix are examples of such names.
The bug appears when the proxy does not remove these headers from requests coming from ordinary visitors, and the back end trusts them more than the address in the request. The proxy checks one path; the application serves another. The same mismatch shows up with paths written in unusual ways, such as encoded slashes or .. segments, where the two layers read the same address differently and each thinks it is enforcing the rule.
- Find a path the front layer refuses, such as an admin area or a status page. A 403 from the proxy is the signal to dig.
- Request an allowed path, usually
/, and add one candidate rewrite header at a time, with the protected path as its value and no leading slash. - Compare the responses. Success looks like the protected page appearing where the root page should be, or a 200 where the direct request gave 403.
The report does not state what fix the company applied.
Glossary
- Bug bounty programme: a scheme where a company pays researchers who privately report security flaws.
- Severity / CVSS: a rating of how serious a flaw is; CVSS turns it into a number, higher being worse.
- Bounty: the money paid for a valid report.
- Disclosed: made public, usually after the company has had time to fix the issue.
- Directory: a folder on a web server;
/adminis the usual name for a staff-only area. - Front server: the server facing the internet that checks and forwards requests.
- Back-end server: the server behind the front one that holds the actual pages and data.
- nginx: a widely used web server and reverse proxy.
- Reverse proxy: a server placed in front of an application to handle traffic, encryption and blocking.
- CDN: a network of proxy servers spread geographically to speed up and protect a site.
- HTTP status code: the number a server returns to say how a request went, such as 200 (fine), 403 (forbidden) or 404 (not found).
- 403: the status meaning the server understood the request but refuses to allow it.
- Request: the message a browser or tool sends to a server asking for a page.
- Header: an extra labelled line in a request or response carrying information, such as the Host or a rewrite instruction.
- Host header: the header naming which website on a server the request is for.
- Method (GET): the type of request; GET means "give me this page".
- curl: a command-line tool for sending web requests by hand.
- Certificate: the padlock mechanism proving a site is genuine;
-kmakes curl skip checking it. - X-Rewrite-Url / X-original-url: headers that can tell a back end to serve a different path than the one requested.
- Bypass: getting past a restriction without being authorised to.
- Misconfiguration: a security problem caused by settings rather than a coding mistake.
- Path normalisation: how a system tidies up an address (slashes,
.., encoding) before using it; layers that tidy differently can disagree. - False positive: a test result that looks like a problem but is not.