Local File Inclusion path bypass
The fix for a local file inclusion issue used a blocklist that checked for forward-slash and backslash traversal sequences separately, but missed mixed sequences that combine both separators. On Unix-like systems, where a backslash is treated as a forward slash, an attacker could still traverse directories and include local files.
- Fixed in 23 days
- Disclosed after 53 days
Hey,
After reading egix's report #59665 and seeing your fix at https://github.com/concrete5/concrete5/commit/19d0cc81c7cd485b856289ac71ebc0389ea7c3da & https://github.com/concrete5/concrete5/commit/c646dd0defcfa79ef119dca8ba1beba2c5bc91ea I think the fixes are insufficient to stop lfi.
If you are going to stick with the strpos() trick, you missed something.
$path = $request->getPathInfo();
$path = rawurldecode($request->getPathInfo());
if (substr($path, 0, 3) == '../' || substr($path, -3) == '/..' || strpos($path, '/../') ||
substr($path, 0, 3) == '..\\' || substr($path, -3) == '\\..' || strpos($path, '\\..\\')) {
while that is one way to go. you forgot about "../", " ../", "/.." & "/.." this works because some oses (unix like) parse the backslash to forward slash and proceed. add those and I think you should be fine. :)
Thanks, P
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 path validation used a blocklist that checked forward-slash and backslash traversal patterns separately, so mixed-separator sequences slipped through on Unix-like systems that normalise backslashes to forward slashes.
Impact
An attacker could still perform local file inclusion on Unix-like systems despite the patch.
What the attacker needed
Unix-like server; Attacker controls the path input
The fix
The path check should also reject mixed forward-slash and backslash traversal sequences.
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.
Local file inclusion is when a web app lets a user influence which file on the server gets loaded. The developers tried to block this by rejecting paths containing '..' (which means 'go up a folder'), but they only checked for certain slash combinations. A clever attacker can mix forward and backward slashes to sneak past the check on systems that treat both the same way.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.