Published
Last updated
6.8
CVSS V3
Pebble has Arbitrary Local File Inclusion (LFI) Vulnerability via include
macro
If untrusted user input is used to dynamically create a PebbleTemplate
with the method PebbleEngine#getLiteralTemplate
, then an attacker can include arbitrary local files from the file system into the generated template, leaking potentially sensitive information into the output of PebbleTemplate#evaluate
. This is done via the include
macro.
The include
macro calls PebbleTempateImpl#resolveRelativePath
with the relativePath
argument passed within the template:
Example template:
When resolveRelativePath
is called, the relativePath
is resolved against the PebbleTemplateImpl.name
variable.
Unfortunately, when the template is created from a string, as is the case when PebbleEngine#getLiteralTemplate
is used, the PebbleTemplateImpl.name
variable is actually the entirety of the contents of the template, not a filename as the logic expects. The net result is that the relativePath
is resolved against the system root directory. As a result, files accessible from the root directory of the filesystem can be included into a template.
The following test demonstrates the vulnerability:
As an attacker, the following malicious template demonstrates the vulnerability:
This is an arbitrary Local File Inclusion (LFI) vulnerability. It can allow attackers to exfiltrate the contents of the local filesystem, including sensitive files into PebbleTemplate
output. This can also be used to access the /proc
filesystem which can give an attacker access to environment variables.
There exists no published fix for this vulnerability. The best way to mitigate this vulnerability is to disable the include
macro in Pebble Templates.
The following can safeguard your application from this vulnerability:
Vulnerability was reported under the Open Source Security Foundation (OpenSSF) Model Outbound Vulnerability Disclosure Policy: Version 0.1.
For further discussion, see this issue: https://github.com/PebbleTemplates/pebble/issues/688
This vulnerability was discovered by @JLLeitschuh while at Chainguard Labs. Jonathan is currently independent.