]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/vulnerabilities.cgi
vulnearabilities.cgi: add tsx async abort and itlb_multihit
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / vulnerabilities.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2019 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 use strict;
23
24 # enable only the following on debugging purpose
25 #use warnings;
26 #use CGI::Carp 'fatalsToBrowser';
27
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31
32 my %VULNERABILITIES = (
33 "itlb_multihit" => "$Lang::tr{'itlb multihit'} (CVE-2018-12207)",
34 "l1tf" => "$Lang::tr{'foreshadow'} (CVE-2018-3620)",
35 "mds" => "$Lang::tr{'fallout zombieload ridl'} (CVE-2018-12126, CVE-2018-12130, CVE-2018-12127, CVE-2019-11091)",
36 "meltdown" => "$Lang::tr{'meltdown'} (CVE-2017-5754)",
37 "spec_store_bypass" => "$Lang::tr{'spectre variant 4'} (CVE-2018-3639)",
38 "spectre_v1" => "$Lang::tr{'spectre variant 1'} (CVE-2017-5753)",
39 "spectre_v2" => "$Lang::tr{'spectre variant 2'} (CVE-2017-5715)",
40 "tsx_async_abort" => "$Lang::tr{'taa zombieload2'} (CVE-2019-11135)",
41 );
42
43 my $errormessage = "";
44 my $notice = "";
45
46 my %mainsettings = ();
47 my %color = ();
48 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
49 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
50
51 my %settings = (
52 "ENABLE_SMT" => "auto",
53 );
54 &General::readhash("${General::swroot}/main/security", \%settings);
55
56 &Header::showhttpheaders();
57
58 &Header::getcgihash(\%settings);
59
60 if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
61 if ($settings{'ENABLE_SMT'} !~ /^(auto|on)$/) {
62 $errormessage = $Lang::tr{'invalid input'};
63 }
64
65 unless ($errormessage) {
66 &General::writehash("${General::swroot}/main/security", \%settings);
67 $notice = $Lang::tr{'please reboot to apply your changes'};
68 }
69 }
70
71 my %checked = ();
72 $checked{'ENABLE_SMT'}{'auto'} = '';
73 $checked{'ENABLE_SMT'}{'on'} = '';
74 $checked{'ENABLE_SMT'}{$settings{'ENABLE_SMT'}} = "checked";
75
76 &Header::openpage($Lang::tr{'processor vulnerability mitigations'}, 1, '');
77
78 &Header::openbigbox("100%", "left", "", $errormessage);
79
80 if ($errormessage) {
81 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
82 print "<font color='red'>$errormessage</font>";
83 &Header::closebox();
84 }
85
86 if ($notice) {
87 &Header::openbox('100%', 'left', $Lang::tr{'notice'});
88 print "<font color='red'>$notice</font>";
89 &Header::closebox();
90 }
91
92 &Header::openbox('100%', 'center', $Lang::tr{'processor vulnerability mitigations'});
93
94 print <<END;
95 <table class="tbl" width='100%'>
96 <thead>
97 <tr>
98 <th align="center">
99 <strong>$Lang::tr{'vulnerability'}</strong>
100 </th>
101 <th align="center">
102 <strong>$Lang::tr{'status'}</strong>
103 </th>
104 </tr>
105 </thead>
106 <tbody>
107 END
108
109 my $id = 0;
110 for my $vuln (sort keys %VULNERABILITIES) {
111 my ($status, $message) = &check_status($vuln);
112 next if (!$status);
113
114 my $colour = "";
115 my $bgcolour = "";
116 my $status_message = "";
117
118 # Not affected
119 if ($status eq "Not affected") {
120 $status_message = $Lang::tr{'not affected'};
121 $colour = "white";
122 $bgcolour = ${Header::colourgreen};
123
124 # Vulnerable
125 } elsif ($status eq "Vulnerable") {
126 $status_message = $Lang::tr{'vulnerable'};
127 $colour = "white";
128 $bgcolour = ${Header::colourred};
129
130 # Mitigated
131 } elsif ($status eq "Mitigation") {
132 $status_message = $Lang::tr{'mitigated'};
133 $colour = "white";
134 $bgcolour = ${Header::colourblue};
135
136 # Unknown report from kernel
137 } else {
138 $status_message = $status;
139 $colour = "black";
140 $bgcolour = ${Header::colouryellow};
141 }
142
143 my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
144
145 print <<END;
146 <tr bgcolor="$table_colour">
147 <td align="left">
148 <strong>$VULNERABILITIES{$vuln}</strong>
149 </td>
150
151 <td bgcolor="$bgcolour" align="center">
152 <font color="$colour">
153 END
154 if ($message) {
155 print "<strong>$status_message</strong> - $message";
156 } else {
157 print "<strong>$status_message</strong>";
158 }
159
160 print <<END;
161 </font>
162 </td>
163 </tr>
164 END
165 }
166
167 print <<END;
168 </tbody>
169 </table>
170 END
171
172 &Header::closebox();
173
174 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
175
176 &Header::openbox('100%', 'center', $Lang::tr{'settings'});
177
178 my $smt_status = &smt_status();
179
180 print <<END;
181 <table class="tbl" width="66%">
182 <tbody>
183 <tr>
184 <th colspan="2" align="center">
185 <strong>$smt_status</strong>
186 </th>
187 </tr>
188
189 <tr>
190 <td width="50%" align="left">
191 $Lang::tr{'enable smt'}
192 </td>
193
194 <td width="50%" align="center">
195 <label>
196 <input type="radio" name="ENABLE_SMT"
197 value="auto" $checked{'ENABLE_SMT'}{'auto'}>
198 $Lang::tr{'automatic'}
199 </label> /
200 <label>
201 <input type="radio" name="ENABLE_SMT"
202 value="on" $checked{'ENABLE_SMT'}{'on'}>
203 $Lang::tr{'force enable'} ($Lang::tr{'dangerous'})
204 </label>
205 </td>
206 </tr>
207
208 <tr>
209 <td colspan="2" align="right">
210 <input type="submit" name="ACTION" value="$Lang::tr{'save'}">
211 </td>
212 </tr>
213 </tbody>
214 </table>
215 END
216
217 &Header::closebox();
218
219 print "</form>\n";
220
221 &Header::closebigbox();
222
223 &Header::closepage();
224
225 sub check_status($) {
226 my $vuln = shift;
227
228 open(FILE, "/sys/devices/system/cpu/vulnerabilities/$vuln") or return undef;
229 my $status = <FILE>;
230 close(FILE);
231
232 chomp($status);
233
234 # Fix status when something has been mitigated, but not fully, yet
235 if ($status =~ /^(Mitigation): (.*vulnerable.*)$/) {
236 return ("Vulnerable", $status);
237 }
238
239 if ($status =~ /^(Vulnerable|Mitigation): (.*)$/) {
240 return ($1, $2);
241 }
242
243 return $status;
244 }
245
246 sub smt_status() {
247 open(FILE, "/sys/devices/system/cpu/smt/control");
248 my $status = <FILE>;
249 close(FILE);
250
251 chomp($status);
252
253 if ($status eq "on") {
254 return $Lang::tr{'smt enabled'};
255 } elsif (($status eq "off") || ($status eq "forceoff")) {
256 return $Lang::tr{'smt disabled'};
257 } elsif ($status eq "notsupported") {
258 return $Lang::tr{'smt not supported'};
259 }
260
261 return $status;
262 }