CVE-2024-39915 (published 2024-07-15T20:15Z)

Thruk is a multibackend monitoring webinterface for Naemon, Nagios, Icinga and Shinken using the Livestatus API. This authenticated RCE in Thruk allows authorized users with network access to inject arbitrary commands via the URL parameter during PDF report generation. The Thruk web application does not properly process the url parameter when generating a PDF report. An authorized attacker with access to the reporting functionality could inject arbitrary commands that would be executed when the script /script/html2pdf.sh is called. The vulnerability can be exploited by an authorized user with network access. This issue has been addressed in version 3.16. Users are advised to upgrade. There are no known workarounds for this vulnerability.\n


Weakness information:
cwe_id: NVD-CWE-noinfo
cwe_name: Insufficient Information
description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
extended_description: Insufficient Information

Fix information:
repo_url: https://github.com/sni/Thruk
commit_details: repo_url: https://github.com/sni/Thruk
author: Sven Nierlein
author_date: 2024-07-12 15:26:56+02:00
msg: fix using unescaped url in reports

skip spawing a shell when generating pdf report from custom url. Insufficient
escaping of the url lead to remote code execution vulnerability.

references:

- https://github.com/sni/Thruk/security/advisories/GHSA-r7gx-h738-4w6f

credits:

- https://github.com/OOsipova
- https://github.com/BlackFan (Kaspersky)
repository: repo_url: https://github.com/sni/Thruk
repo_name: sni/Thruk
description: Thruk is a multibackend monitoring webinterface for Naemon, Nagios, Icinga and Shinken using the Livestatus API.
repo_language: Perl
owner: sni
file_changes: filename: Changes
change_type: ModificationType.MODIFY
diff: @@ -1,6 +1,7 @@
 This file documents the revision history for the Monitoring Webinterface Thruk.
 
 next:
+          - fix using unescaped url in reports
           - fix recurring downtimes crontab entry for 2nd/3rd days of month
           - fix sessions removed early when using kerberos authentication
           - fix using custom variables starting with multiple underlines

programming_language: Markdown
filename: Render.pm
change_type: ModificationType.MODIFY
diff: @@ -391,9 +391,8 @@ sub get_url {
     # directly convert external urls
     if($url =~ m/^https?:\/\/([^\/]+)/mx && $c->stash->{'param'}->{'pdf'} && $c->stash->{'param'}->{'pdf'} eq 'yes') {
         Thruk::Utils::External::update_status($ENV{'THRUK_JOB_DIR'}, 80, 'converting') if $ENV{'THRUK_JOB_DIR'};
-        my $cmd = $c->config->{home}.'/script/html2pdf.sh "'.$url.'" "'.$c->stash->{'attachment'}.'.pdf"';
         local $ENV{THRUK_SESSION_ID} = $sessionid;
-        Thruk::Utils::IO::cmd($cmd);
+        Thruk::Utils::IO::cmd($c, [$c->config->{home}.'/script/html2pdf.sh', $url, $c->stash->{'attachment'}.'.pdf']);
         move($c->stash->{'attachment'}.'.pdf', $c->stash->{'attachment'}) or die('move '.$c->stash->{'attachment'}.'.pdf to '.$c->stash->{'attachment'}.' failed: '.$!);
         $Thruk::Utils::PDF::ctype      = 'application/pdf';
         $Thruk::Utils::PDF::attachment = 'report.pdf';

programming_language: Perl