File Manipulation #536

Closed
opened 2026-10-05 00:02:44 +02:00 by adam · 3 comments
Owner

In Piwigo/install.php:

120: $filename = PHPWG_ROOT_PATH . $conf['data_location'] . 'pwg_' . $_GET['dl'];
127: unlink($filename);

As you can see, unlink() is being used to with a usercontrolled parameter dl, one can use path manipulation techniques like /../ and refer to files and get them removed by unlink(). this isn't as critical as the install.php file gets removed after install, it is when it isn't.

Thanks,

In Piwigo/install.php: 120: $filename = PHPWG_ROOT_PATH . $conf['data_location'] . 'pwg_' . $_GET['dl']; 127: unlink($filename); As you can see, unlink() is being used to with a usercontrolled parameter dl, one can use path manipulation techniques like /../ and refer to files and get them removed by unlink(). this isn't as critical as the install.php file gets removed after install, it is when it isn't. Thanks, <!-- github-sync-id:196307930 -->
adam closed this issue 2026-10-05 00:02:44 +02:00
Author
Owner

Hi @Shinkurt

Did you also see:

116: check_input_parameter('dl', $_GET, false, '/^[a-f0-9]{32}$/');

It should prevent any "../../" attempt :-)

Hi @Shinkurt Did you also see: ``` 116: check_input_parameter('dl', $_GET, false, '/^[a-f0-9]{32}$/'); ``` It should prevent any "../../" attempt :-) <!-- github-comment-id:267927776 -->
Author
Owner

@plegall yeah, that is one thing I'd like to mention. that parameter, although checks the input, it doesn't exit() if it occurs. check_input_parameter(), instead of closing with a die() or exit() if they are encountered, it instead calls fatal_error() which basically just prints out error. but adding a die or exit in that function will solve it.

Thanks,

@plegall yeah, that is one thing I'd like to mention. that parameter, although checks the input, it doesn't exit() if it occurs. check_input_parameter(), instead of closing with a die() or exit() if they are encountered, it instead calls fatal_error() which basically just prints out error. but adding a die or exit in that function will solve it. Thanks, <!-- github-comment-id:267973710 -->
Author
Owner

here is the end of fatal_error function:

  die(0); // just in case

it seems good enough for me :-)

here is the end of fatal_error function: ``` die(0); // just in case ``` it seems good enough for me :-) <!-- github-comment-id:268248713 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#536