Skip to content

Commit a823911

Browse files
Sudan Landgepb8o
authored andcommitted
fix: Add check for known vulnerabilities in guest
There is a REPTAR exception reported on m6i.metal for guest kernel versions 4.14/5.10/6.1 when spectre-meltdown-checker.sh script is run inside the guest from below the tests: test_spectre_meltdown_checker_on_guest and test_spectre_meltdown_checker_on_restored_guest The same script when run on host doesn't report the exception which means the instances are actually not vulnerable to REPTAR. The only reason why the script cannot determine if the guest is vulnerable or not is because Firecracker does not expose the microcode version to the guest. The check is check_CVE_2023_23583_linux in spectre-meltdown-checker.sh Since we have a test on host and the exception in guest is not valid, we add a check to ignore this exception. There could be more such exceptions added to check_vulnerabilities_on_guest() in the future but generalising this function based on instance kernel versions etc. without more data looked like overkill right now so, the function handles the exception only for REPTAR and m6i. Signed-off-by: Sudan Landge <sudanl@amazon.com>
1 parent 76c9028 commit a823911

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

tests/integration_tests/security/test_vulnerabilities.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,33 @@ def spectre_meltdown_reported_vulnerablities(
185185
}
186186

187187

188+
def check_vulnerabilities_on_guest(status):
189+
"""
190+
There is a REPTAR exception reported on INTEL_ICELAKE when spectre-meltdown-checker.sh
191+
script is run inside the guest from below the tests:
192+
test_spectre_meltdown_checker_on_guest and
193+
test_spectre_meltdown_checker_on_restored_guest
194+
The same script when run on host doesn't report the
195+
exception which means the instances are actually not vulnerable to REPTAR.
196+
The only reason why the script cannot determine if the guest
197+
is vulnerable or not because Firecracker does not expose the microcode
198+
version to the guest.
199+
200+
The check in spectre_meltdown_checker is here:
201+
https://github.com/speed47/spectre-meltdown-checker/blob/0f2edb1a71733c1074550166c5e53abcfaa4d6ca/spectre-meltdown-checker.sh#L6635-L6637
202+
203+
Since we have a test on host and the exception in guest is not valid,
204+
we add a check to ignore this exception.
205+
"""
206+
report_guest_vulnerabilities = spectre_meltdown_reported_vulnerablities(status)
207+
known_guest_vulnerabilities = set()
208+
if global_props.cpu_codename == "INTEL_ICELAKE":
209+
known_guest_vulnerabilities = {
210+
'{"NAME": "REPTAR", "CVE": "CVE-2023-23583", "VULNERABLE": true, "INFOS": "Your microcode is too old to mitigate the vulnerability"}'
211+
}
212+
assert report_guest_vulnerabilities == known_guest_vulnerabilities
213+
214+
188215
@pytest.mark.skipif(
189216
global_props.instance == "c7g.metal" and global_props.host_linux_version == "4.14",
190217
reason="c7g host 4.14 requires modifications to the 5.10 guest kernel to boot successfully.",
@@ -232,13 +259,16 @@ def test_spectre_meltdown_checker_on_guest(spectre_meltdown_checker, build_micro
232259
Test with the spectre / meltdown checker on guest.
233260
"""
234261

235-
git_ab_test_guest_command_if_pr(
262+
status = git_ab_test_guest_command_if_pr(
236263
with_checker(build_microvm, spectre_meltdown_checker),
237264
REMOTE_CHECKER_COMMAND,
238265
comparator=set_did_not_grow_comparator(
239266
spectre_meltdown_reported_vulnerablities
240267
),
268+
ignore_return_code_in_nonpr=True,
241269
)
270+
if status and status.returncode != 0:
271+
check_vulnerabilities_on_guest(status)
242272

243273

244274
@pytest.mark.skipif(
@@ -251,15 +281,18 @@ def test_spectre_meltdown_checker_on_restored_guest(
251281
"""
252282
Test with the spectre / meltdown checker on a restored guest.
253283
"""
254-
git_ab_test_guest_command_if_pr(
284+
status = git_ab_test_guest_command_if_pr(
255285
with_checker(
256286
with_restore(build_microvm, microvm_factory), spectre_meltdown_checker
257287
),
258288
REMOTE_CHECKER_COMMAND,
259289
comparator=set_did_not_grow_comparator(
260290
spectre_meltdown_reported_vulnerablities
261291
),
292+
ignore_return_code_in_nonpr=True,
262293
)
294+
if status and status.returncode != 0:
295+
check_vulnerabilities_on_guest(status)
263296

264297

265298
@pytest.mark.skipif(

0 commit comments

Comments
 (0)