Skip to content

Path traversal in static router

High
driusan published GHSA-rfj5-58hv-wc5f Apr 8, 2026

Package

No package listed

Affected versions

LORIS >= 20.0.0 and <= 28.0.0

Patched versions

27.0.3+, 28.0.1+

Description

Impact

A bug in the static file router can allow an attacker to traverse outside of the intended directory, allowing unintended files to be downloaded through the static, css, and js endpoints.

Patches

The router can be adjusted to validate the user is not trying to escape the configured subdirectory with the
following patch:

--- a/src/Router/ModuleFileRouter.php
+++ b/src/Router/ModuleFileRouter.php
@@ -76,13 +76,20 @@ class ModuleFileRouter implements RequestHandlerInterface
      */
     public function handle(ServerRequestInterface $request) : ResponseInterface
     {
-        $fullpath = (
-            $this->moduledir .
-            "/" .
-            $this->subdir .
-            "/"
-            . $request->getURI()->getPath()
-        );
+        $fullpath =
+            realpath(\Utility::pathJoin($this->moduledir, $this->subdir, $request->getURI()->getPath()));
+
+        $basedir = realpath(\Utility::pathJoin($this->moduledir, $this->subdir));
+
+        // The moduledir and subdir come from the code, while the url comes from the user and should not be trusted.
+        if ($fullpath == false || $basedir == false || str_starts_with($fullpath, $basedir) == false) {
+            return (new \LORIS\Http\Error(
+                $request,
+                404,
+                htmlspecialchars($request->getURI()->getPath()) . ": File not found"
+            ))
+            ->withHeader("Content-Type", "text/html");
+        }
 
         if (is_file($fullpath)) {
             $resp = (new \LORIS\Http\Response)
@@ -96,7 +103,7 @@ class ModuleFileRouter implements RequestHandlerInterface
         return (new \LORIS\Http\Error(
             $request,
             404,
-            $fullpath . ": File not found"
+            htmlspecialchars($request->getURI()->getPath()) . ": File not found"
         ))
             ->withHeader("Content-Type", "text/html");
     }

Workarounds

None

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

CVE ID

CVE-2026-34392

Weaknesses

Files or Directories Accessible to External Parties

The product makes files or directories accessible to unauthorized actors, even though they should not be. Learn more on MITRE.

Credits