As you can see, a user-controlled variable is being sent stright to include_once(). a person who managed to upload a .jpg file or any other content with PHP paylaod will just need to refer to that location and include_once() will execute it, making a code execution possible.
In Piwigo/admin/plugin.php
```
32: $sections = explode('/', $_GET['section']);
59: $filename = PHPWG_PLUGINS_PATH . implode('/', $sections);
60: if(is_file($filename))
62: include_once ($filename);
```
As you can see, a user-controlled variable is being sent stright to include_once(). a person who managed to upload a .jpg file or any other content with PHP paylaod will just need to refer to that location and include_once() will execute it, making a code execution possible.
<!-- github-sync-id:196307361 -->
There are quite some security checks before including anything. Uploading a JPEG in the "upload" directory won't be able to get his file included. You can't have ".." as part of the $sections, for example.
There are quite some security checks before including anything. Uploading a JPEG in the "upload" directory won't be able to get his file included. You can't have ".." as part of the $sections, for example.
<!-- github-comment-id:267938358 -->
if (!preg_match('/^[\w-]+$/', $plugin_id))
{
die('Invalid plugin identifier');
}
As a security fix, it isn't sufficent because it only sanitizes $plugin_id = $sections[0];
How about other $secution[i] other than [0]? they aren't sanitized, we just have to send in another array. all the security checks apply to the $plugin_id which is just the first occurance of $sections.
Thanks,
Hey @plegall,
If you are implying:
```
if (!preg_match('/^[\w-]+$/', $plugin_id))
{
die('Invalid plugin identifier');
}
```
As a security fix, it isn't sufficent because it only sanitizes $plugin_id = $sections[0];
How about other $secution[i] other than [0]? they aren't sanitized, we just have to send in another array. all the security checks apply to the $plugin_id which is just the first occurance of $sections.
Thanks,
<!-- github-comment-id:267975534 -->
$sections = explode('/', $_GET['section'] );
for ($i=0; $i<count($sections); $i++)
{
if (empty($sections[$i]) or $sections[$i]=='..')
{
unset($sections[$i]);
$i--;
}
}
No part of the $sections can be ".."
```
$sections = explode('/', $_GET['section'] );
for ($i=0; $i<count($sections); $i++)
{
if (empty($sections[$i]) or $sections[$i]=='..')
{
unset($sections[$i]);
$i--;
}
}
```
No part of the $sections can be ".."
<!-- github-comment-id:268241924 -->
@plegall not good enough. because that checks if $sections[i] is exactly "..", which is sad cause attackers can send in /..// or /..%2F and the $sections[$i]=='..' will return false. I suggest you doing a preg_replace() on it rather that one. tis easy to jump.
@plegall not good enough. because that checks if $sections[i] is exactly "..", which is sad cause attackers can send in /..// or /..%2F and the $sections[$i]=='..' will return false. I suggest you doing a preg_replace() on it rather that one. tis easy to jump.
<!-- github-comment-id:268259053 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In Piwigo/admin/plugin.php
As you can see, a user-controlled variable is being sent stright to include_once(). a person who managed to upload a .jpg file or any other content with PHP paylaod will just need to refer to that location and include_once() will execute it, making a code execution possible.
There are quite some security checks before including anything. Uploading a JPEG in the "upload" directory won't be able to get his file included. You can't have ".." as part of the $sections, for example.
Hey @plegall,
If you are implying:
As a security fix, it isn't sufficent because it only sanitizes $plugin_id = $sections[0];
How about other $secution[i] other than [0]? they aren't sanitized, we just have to send in another array. all the security checks apply to the $plugin_id which is just the first occurance of $sections.
Thanks,
No part of the $sections can be ".."
@plegall not good enough. because that checks if $sections[i] is exactly "..", which is sad cause attackers can send in /..// or /..%2F and the $sections[$i]=='..' will return false. I suggest you doing a preg_replace() on it rather that one. tis easy to jump.
Use CVE-2016-10105 for this.