Skip to content

Route Constraint Bypass via Double Percent-Decoding (>= 4.0.0, <=4.15.2)

Moderate
akrabat published GHSA-h377-p8x2-prf9 Sep 1, 2026

Package

composer slim/slim (Composer)

Affected versions

>=4.0.0, <=4.15.2

Patched versions

4.15.3

Description

A route parameter constraint can be bypassed with doubly percent-encoded input, so a handler receives characters that the router was configured to reject.

Impact

A route parameter constraint can be bypassed with doubly percent-encoded input, so a handler receives characters that the router was configured to reject.

Slim (4.0.0-4.15.2) decodes the request path before matching a route, then decodes each captured argument a second time before passing it to the handler. This means that validation will run against a different value than the one the application receives.

Given the route /test/{value:[^/]+}, which forbids a path separator:

Stage Value
Incoming request /test/a%252Fb
Path decoded, before matching a%2Fb
Checked against [^/]+ passes, no separator present
Argument decoded again, at the handler a/b

Singly-encoded input is not affected. /test/a%2Fb is a 404, since the decode happens before matching and the resulting separator breaks the capture. Only doubly-encoded input reaches a handler in a different form than the router validated.

You are affected if you run Slim 4.0.0 through 4.15.2 and use route placeholder values without revalidating them.

For example consider a file download controller that maps the value to the filesystem:

$app->get('/download/{file:[^/]+}', function ($request, $response, array $args) {
    // The route restricts $file to a single path segment.
    $path = __DIR__ . '/files/' . $args['file'];
    $response->getBody()->write(file_get_contents($path));
    return $response;
});

On affected versions, /download/subdir%252Fsecret.txt would reach the handler as files/subdir/secret.txt, including the subdirectory that was restricted in the route pattern.

Note that this would also defeat filtering applied ahead of the application. A proxy or WAF that decodes once sees the inert %2e%2e%2f while the handler receives ../.

Slim 3.x is not affected.

Patches

Fixed in version 4.15.3. Upgrade with:

composer require slim/slim:^4.15.3

RoutingResults::getRouteArguments() no longer decodes captured values. It never needed to as the path they were captured from already decoded them.

This means that the $urlDecode parameter of getRouteArguments() is now ignored.

Workarounds

If you cannot upgrade, revalidate route placeholder values in the handler and do not rely on the route pattern. Reject any argument containing a path separator before using it.

References

Credits

Thanks to NomanProdhan and Ilia Alshanetsky for independently reporting this issue.

Severity

Moderate

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
Low
Integrity
Low
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:L/I:L/A:N

CVE ID

No known CVE

Weaknesses

Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. Learn more on MITRE.

Double Decoding of the Same Data

The product decodes the same input twice, which can limit the effectiveness of any protection mechanism that occurs in between the decoding operations. Learn more on MITRE.

Credits