Skip to content
Path traversal Write-up Intermediate

elFinder: The story of a repwning

A path traversal vulnerability in elFinder allowed reading arbitrary files because the path normalisation regex failed to handle double slashes. An attacker could exploit this to read files outside the web root, and potentially achieve remote code execution depending on the deployment context.

synacktiv.com

Published on synacktiv.com

Rédigé par Gaetan Ferry - 30/03/2022 - dans Exploit, Pentest - Téléchargement

The author, on synacktiv.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.

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

The regular expression used to normalise paths did not account for double slashes, so sequences like '//../' were not removed, allowing directory traversal.

Impact

An attacker could read arbitrary files on the server, and depending on the deployment, this could lead to remote code execution by writing to sensitive files like authorized_keys or crontabs.

What the attacker needed

ElFinder version before 2.1.61; knowledge of the file system path to elFinder root

The fix

The vulnerability was fixed in elFinder 2.1.61 by correcting the path normalisation logic.

How it was found

  1. Identify the elFinder connector endpoint and the target parameter format.
  2. Craft a target path that includes the root directory prefix followed by a double slash and '../' sequences to traverse directories.
  3. Send a request to the connector with the crafted target to read an arbitrary file.

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.

elFinder is a web-based file manager. A path traversal bug lets an attacker use special sequences like '../' to escape the intended folder and access other files on the server. Here, a mistake in the code that was supposed to clean up these sequences allowed the attack to succeed.

What is Path traversal?

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

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.