Skip to content

Commit 8b3b678

Browse files
committed
Fix command injection vulnerability
1 parent 0a4f089 commit 8b3b678

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

check_smart.pl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@
6767
# Dec 15, 2025: Florian Sager - Fix evaluating ATA Error Count: 0 as a warning (6.17.0)
6868
# Dec 15, 2025: Philippe Beaumont - Add areca devices (6.17.0)
6969
# Apr 21, 2026: Claudio Kuenzler - Fix sys path for sudo command. Detect NVME input/output error (6.18.0)
70+
# Apr 22, 2026: Claudio Kuenzler - Fix command injection vulnerability in interface parameter (6.18.1)
7071

7172
use strict;
7273
use Getopt::Long;
7374
use File::Basename qw(basename);
7475

7576
my $basename = basename($0);
76-
my $revision = '6.18.0';
77+
my $revision = '6.18.1';
7778

7879
# Standard Nagios return codes
7980
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
@@ -174,8 +175,11 @@
174175

175176
# Allow all device types currently supported by smartctl
176177
# See http://www.smartmontools.org/wiki/Supported_RAID-Controllers
177-
178-
if ($opt_i =~ m/^(ata|scsi|3ware|areca|hpt|aacraid|cciss|megaraid|sat|auto|nvme|usbjmicron)/) {
178+
# Validate interface parameter strictly to prevent command injection
179+
# Simple interfaces must match exactly; RAID interfaces allow device specifiers (see --help)
180+
if ($opt_i =~ m/^(ata|scsi|sat|auto|nvme)$/ ||
181+
$opt_i =~ m/^(3ware|areca|aacraid|cciss|megaraid|usbjmicron),(\d+|\[\d+-\d+\])$/ ||
182+
$opt_i =~ m/^hpt,\d+\/\d+\/\d+$/) {
179183
$interface = $opt_i;
180184
if($interface =~ m/megaraid,\[(\d{1,2})-(\d{1,2})\]/) {
181185
$interface = "";

0 commit comments

Comments
 (0)