[harp] File access even when they have been set to be ignored.
Harp's server is meant to refuse to serve files and directories whose names begin with an underscore, but the check can be evaded by percent-encoding the underscore in the request path. An attacker could then read files the developer intended to keep private, such as partials and layout files.
- Triaged in 26 days
- Fixed in 4 months
- Disclosed after 4 months
I would like to report information disclosure through file access in harp. It allows to access files that are supposed to be ignored according to the harp server rules.
Module
module name: harp
version: 0.29.0
npm page: https://www.npmjs.com/package/harp
Module Description
zero-configuration web server with built in pre-processing
Module Stats
3,576 downloads in the last week
Vulnerability
Vulnerability Description
Ignore those which start with underscore.
Any files or directories that begin with underscore will be ignored by the server. This is the recommended naming convention for layout and partial files. Harp will honour this rule for both files and directories.
Design Rationale
By having a simple convention, it is easy to specify and identify which assets will not be served to the end user.
Example
myapp.harp.io/
+- public/
|- index.html <-- will be served
|- _some-partial.jade <-- won't be served
+- _shared-partials/ <-- won't be served
+- nav.jade
This rule can be bypassed by url encoding the name of the file or directory that has been forbidden.
Steps To Reproduce:
- Install harpjs
yarn global add harp
- Run harp server
harp server
- Create a file
_secretwhich should be ignored inside project directory
echo secret text >> _secret.txt
- Request the file with
curl
curl --path-as-is 0.0.0.0:9000/_secret.txt
...
<h1>404</h1><h2>Page Not Found</h2>
...
- The url encoded value for _ is %5f. So after replacing an e with its url encoded form, we are able to access the file.
curl --path-as-is 0.0.0.0:9000/%5fsecret.txt
secret text
Supporting Material/References:
- Ubuntu 16.04
- node v11.3.0
- npm 6.4.1
Wrap up
- I contacted the maintainer to let them know: N
- I opened an issue in the related repository: N
Impact
The essentially bypasses the ignore files/folders feature and allows an attacker to read from a directory/file that the victim has not allowed access to.
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
Likely the server compares the raw, still-encoded request path against the underscore rule instead of decoding it first, so an encoded underscore slips past the check.
Impact
The ignore rule for underscore-prefixed files and folders is effectively bypassed, so an attacker could read files the victim did not intend to expose.
What the attacker needed
Network access to the harp server; a file or folder named with a leading underscore
How it was found
- Install harp globally and start the harp server in the project directory.
- Create a file whose name begins with an underscore inside the project directory.
- Request that file directly and observe the server returns a not-found page.
- Request the same file again with the underscore percent-encoded and observe its contents are returned.
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.
A small web server called harp deliberately hides files whose names start with an underscore, treating them as private building blocks rather than pages. The server checks the name as it appears in the request, so if the underscore is written in its encoded form (a percent sign followed by two characters) the check no longer matches and the file is handed over. Anyone who can reach the server can therefore read files the owner thought were hidden.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.