This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
fix(secu): Authenticated Remote Code Execution in getStats.php #7083
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to the way preg_replace handles backslahes, the expression:
wouldn't work as expected because 3 backslashes are needed to properly refer to the backslash inside the regex.
Therefore the following GET parameter would lead to arbitrary remote code execution:
http://x.x.x.x/centreon/include/Administration/corePerformance/getStats.php?key=active_service_check&ns_id=1=/var/lib/centreon/nagios-perf/perfmon-1/nagios_active_service_execution.rrd:Min:AVERAGE %26 touch /tmp/das %26
Because it would be interpreted as ' which still makes it valid for a shell to execute.
I'm not very confident in the multiple layers of filtering in this PHP file. It really needs to NOT use GET parameters.
PLEASE NOTE THAT THIS PULL REQUEST IS TO INFORM YOU OF A SECURITY PROBLEM AND HAS NOT BEEN PROPERLY TESTED.