Unmasking an RFI to LFI Escalation
An endpoint that fetched CSV files from a user-supplied URL allowed remote file inclusion, and later a local file inclusion was found because uploaded files were saved and logged with an ID. An attacker could add unverified products, perform CSRF, cause a denial of service, and read local files.
Published on laburity.com
Greetings, we are going to share a recent security assessment that was performed for the client, where a seemingly innocent Remote File Inclusion (RFI) unfolded into a more intricate and fascinating Local File Inclusion (LFI) discovery.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application passed user-controlled input directly to a file-reading function without validating or restricting the path or URL, and it saved every fetched file to disk with a predictable name and ID.
Impact
An attacker could add unverified products, perform CSRF, cause a denial of service, and read local files, though SSRF was limited to HTTPS and some schemas failed.
What the attacker needed
Access to the endpoint; ability to host a file externally; victim visits a crafted page for CSRF
The fix
The application should validate and restrict the file parameter to allowed sources and paths, and avoid saving user-supplied files with predictable names.
How it was found
- Identify an endpoint that accepts a file parameter and fetches CSV data.
- Supply an external URL to the file parameter to include a remote CSV file.
- Craft an HTML form to perform CSRF and add products without a token.
- Use a local file path such as /dev/random to cause a denial of service.
- Probe for local files by observing 404 responses.
- Discover that uploaded files are saved and logged with an ID, then use a local file path to read arbitrary files.
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 write-up has not been written yet. The Original tab links to the source.
The website had a feature that let it download a file from a web address you provide. Because it did not check the address, you could make it download from any site, and later even read files stored on the server itself. This is dangerous because attackers can control what data goes into the site or read sensitive files.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.