| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| privatebin/privatebin | composer | >= 1.7.7, < 2.0.3 | 2.0.3 |
The vulnerability is a local file inclusion (LFI) in PrivateBin's template-switching feature, identified as CVE-2025-64714. The flaw was introduced in version 1.7.7 (commit 44f8cfbfb8df4b4bec1cbf79aa8ce51abdb18be3) and fixed in version 2.0.3 (commit 4434dbf73ac53217fda0f90d8cf9b6110f8acc4f).
The root cause lies in the PrivateBin\TemplateSwitcher::isTemplateAvailable function. When the templateselection option is enabled, this function trusts user input from the template cookie. The vulnerable code path retrieves the cookie value via PrivateBin\TemplateSwitcher::getSelectedByUserTemplate, constructs a file path using PrivateBin\View::getTemplateFilePath, and then uses file_exists() to check for the template. Because the cookie value is not sanitized, an attacker can use path traversal sequences (e.g., ../) to check for the existence of arbitrary PHP files on the server.
If the file exists, the application proceeds to include it using include $path; within the PrivateBin\View::draw function, resulting in the execution of the specified local PHP file. The patch resolves this by using basename() on the cookie input to strip directory traversal characters and by removing the dangerous file_exists() check, instead relying on a strict allowlist of templates.
PrivateBin\TemplateSwitcher::isTemplateAvailablelib/TemplateSwitcher.php
PrivateBin\View::drawlib/View.php
PrivateBin\View::getTemplateFilePathlib/View.php
PrivateBin\TemplateSwitcher::getSelectedByUserTemplatelib/TemplateSwitcher.php
salt, purge_ and traffic_limiter files, they get included, but no data is displayed (variables or comments only), and a webserver specific error message is returned.index.php, you get a PHP error (possibly visible, depending on the webserver setup), due to define being called twice.$_SERVER['argc'].That said, the vulnerability could be used to chain more attacks or execute other non-PrivateBin related PHP files on the host system, if such other files exist and the (relative) path to them can be guessed. Also, should for some reason the PHP “protection line” be missing on your deployment the impact could be much worse and e.g. data like the URL shortener token or the database configuration from the configuration file could possibly be exfiltrated.
PrivateBin has checked all instances versioned 1.7.7 and above listed in the PrivateBin directory and did find 11 instances that had the template switcher enabled. The following script was used to detect this:
for URL in $(
curl --silent --header 'Accept: application/json' 'https://privatebin.info/directory/api?top=100&version=1.7.7' | jq --raw-output '.[].url'
) $(
curl --silent --header 'Accept: application/json' 'https://privatebin.info/directory/api?top=100&version=1.7.8' | jq --raw-output '.[].url'
) $(
curl --silent --header 'Accept: application/json' 'https://privatebin.info/directory/api?top=100&version=2' | jq --raw-output '.[].url'
)
do
curl --silent "$URL" | grep -q 'id="template"' && echo "$URL uses template switcher"
done
None of these instances had an unprotected PrivateBin configuration file in use. The following script was used and may be adapted to check any single instance:
curl --silent --cookie 'template=../cfg/conf' https://privatebin.net
Users can select their preferred template via the template cookie, as seen in TemplateSwitcher::getSelectedByUserTemplate:
private static function getSelectedByUserTemplate(): ?string
{
$selectedTemplate = null;
$templateCookieValue = $_COOKIE['template'] ?? '';
if (self::isTemplateAvailable($templateCookieValue)) {
$selectedTemplate = $templateCookieValue;
}
return $selectedTemplate;
}
In this commit, introduced in 1.7.7, the TemplateSwitcher::isTemplateAvailable method went from this:
public static function isTemplateAvailable(string $template): bool
{
return in_array($template, self::getAvailableTemplates());
}
to this:
public static function isTemplateAvailable(string $template): bool
{
$available = in_array($template, self::getAvailableTemplates());
if (!$available && !View::isBootstrapTemplate($template)) {
$path = View::getTemplateFilePath($template);
$available = file_exists($path);
}
return $available;
}
The new code will now blindly trust $template, unless it starts with the string bootstrap-.
View::getTemplateFilePath will return PATH . 'tpl' . DIRECTORY_SEPARATOR . $file . '.php', allowing directory traversal, but preventing non-PHP files to be included.
View::draw will then include the user-submitted template:
public function draw($template)
{
$path = self::getTemplateFilePath($template);
if (!file_exists($path)) {
throw new Exception('Template ' . $template . ' not found!', 80);
}
extract($this->_variables);
include $path;
}
Note: this is only possible if templateselection configuration is enabled, or if no template has been set. The template will be rewritten if this condition isn't met:
private function _setDefaultTemplate()
{
$templates = $this->_conf->getKey('availabletemplates');
$template = $this->_conf->getKey('template');
TemplateSwitcher::setAvailableTemplates($templates);
TemplateSwitcher::setTemplateFallback($template);
// force default template, if template selection is disabled and a default is set
if (!$this->_conf->getKey('templateselection') && !empty($template)) {
$_COOKIE['template'] = $template;
setcookie('template', $template, array('SameSite' => 'Lax', 'Secure' => true));
}
}
template=../cfg/conf, where the relative path points to a PHP file without its file suffixThe issue has been patched in version 2.0.3.
Set templateselection = false in cfg/conf.php or remove it, it's default is false.
PrivateBin would like to thank Benoit Esnard, who reported this vulnerability.
In general, PrivateBin would like to thank everyone reporting issues and potential vulnerabilities to us.
If a user suspects they have found a vulnerability or potential security risk, PrivateBin kindly asks them to follow the security policy and report it to PrivateBin. After submssion the report is assessed and necessary actions will be taken to address it.
Ongoing coverage of React2Shell