Skip to content

Commit 8e226b3

Browse files
authored
[release/6.x] Accept UVM endorsements with integer SVN (#7316) (#7318)
1 parent c7dbf7a commit 8e226b3

File tree

5 files changed

+78
-31
lines changed

5 files changed

+78
-31
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [6.0.14]
9+
10+
[6.0.14]: https://github.com/microsoft/CCF/releases/tag/ccf-6.0.14
11+
12+
### Added
13+
14+
- Improved handling of socket errors in curlm callbacks (#7308)
15+
- Accept UVM endorsements with SVNs encoded as integers, and use integer comparison for UVM (#7316)
16+
817
## [6.0.13]
918

1019
[6.0.13]: https://github.com/microsoft/CCF/releases/tag/ccf-6.0.13

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "ccf"
7-
version = "6.0.13"
7+
version = "6.0.14"
88
authors = [
99
{ name="CCF Team", email="CCF-Sec@microsoft.com" },
1010
]

src/node/uvm_endorsements.cpp

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,35 @@ namespace ccf
99
const pal::UVMEndorsements& endorsements,
1010
const std::vector<pal::UVMEndorsements>& uvm_roots_of_trust)
1111
{
12-
for (const auto& uvm_root_of_trust : uvm_roots_of_trust)
13-
{
14-
if (
15-
uvm_root_of_trust.did == endorsements.did &&
16-
uvm_root_of_trust.feed == endorsements.feed &&
17-
uvm_root_of_trust.svn <= endorsements.svn)
18-
{
19-
return true;
20-
}
21-
}
22-
return false;
12+
return std::ranges::any_of(
13+
uvm_roots_of_trust, [&](const auto& uvm_root_of_trust) {
14+
size_t root_of_trust_svn = 0;
15+
auto result = std::from_chars(
16+
uvm_root_of_trust.svn.data(),
17+
uvm_root_of_trust.svn.data() + uvm_root_of_trust.svn.size(),
18+
root_of_trust_svn);
19+
if (result.ec != std::errc())
20+
{
21+
throw std::runtime_error(fmt::format(
22+
"Unable to parse svn value {} to unsigned in UVM root of trust",
23+
uvm_root_of_trust.svn));
24+
}
25+
size_t endorsement_svn = 0;
26+
result = std::from_chars(
27+
endorsements.svn.data(),
28+
endorsements.svn.data() + endorsements.svn.size(),
29+
endorsement_svn);
30+
if (result.ec != std::errc())
31+
{
32+
throw std::runtime_error(fmt::format(
33+
"Unable to parse svn value {} to unsigned in UVM endorsements",
34+
endorsements.svn));
35+
}
36+
37+
return uvm_root_of_trust.did == endorsements.did &&
38+
uvm_root_of_trust.feed == endorsements.feed &&
39+
root_of_trust_svn <= endorsement_svn;
40+
});
2341
}
2442

2543
namespace cose
@@ -263,25 +281,58 @@ namespace ccf
263281
cose::headers::CONTENT_TYPE_APPLICATION_JSON_VALUE));
264282
}
265283

266-
UVMEndorsementsPayload payload = nlohmann::json::parse(raw_payload);
267-
if (payload.sevsnpvm_launch_measurement != uvm_measurement.hex_str())
284+
auto payload = nlohmann::json::parse(raw_payload);
285+
std::string sevsnpvm_launch_measurement =
286+
payload["x-ms-sevsnpvm-launchmeasurement"].get<std::string>();
287+
auto sevsnpvm_guest_svn_obj = payload["x-ms-sevsnpvm-guestsvn"];
288+
std::string sevsnpvm_guest_svn;
289+
if (sevsnpvm_guest_svn_obj.is_string())
290+
{
291+
sevsnpvm_guest_svn = sevsnpvm_guest_svn_obj.get<std::string>();
292+
size_t uintval = 0;
293+
auto result = std::from_chars(
294+
sevsnpvm_guest_svn.data(),
295+
sevsnpvm_guest_svn.data() + sevsnpvm_guest_svn.size(),
296+
uintval);
297+
if (result.ec != std::errc())
298+
{
299+
throw std::logic_error(fmt::format(
300+
"Unable to parse sevsnpvm_guest_svn value {} to unsigned in UVM "
301+
"endorsements "
302+
"payload",
303+
sevsnpvm_guest_svn));
304+
}
305+
}
306+
else if (sevsnpvm_guest_svn_obj.is_number_unsigned())
307+
{
308+
sevsnpvm_guest_svn = std::to_string(sevsnpvm_guest_svn_obj.get<size_t>());
309+
}
310+
else
311+
{
312+
throw std::logic_error(fmt::format(
313+
"Unexpected type {} for sevsnpvm_guest_svn in UVM endorsements "
314+
"payload, expected string or unsigned integer",
315+
sevsnpvm_guest_svn_obj.type_name()));
316+
}
317+
318+
if (sevsnpvm_launch_measurement != uvm_measurement.hex_str())
268319
{
269320
throw std::logic_error(fmt::format(
270321
"Launch measurement in UVM endorsements payload {} is not equal "
271322
"to UVM attestation measurement {}",
272-
payload.sevsnpvm_launch_measurement,
323+
sevsnpvm_launch_measurement,
273324
uvm_measurement.hex_str()));
274325
}
275326

276327
LOG_INFO_FMT(
277328
"Successfully verified endorsements for attested measurement {} against "
278329
"{}, feed {}, svn {}",
279-
payload.sevsnpvm_launch_measurement,
330+
sevsnpvm_launch_measurement,
280331
did,
281332
phdr.feed,
282-
payload.sevsnpvm_guest_svn);
333+
sevsnpvm_guest_svn);
283334

284-
pal::UVMEndorsements end{did, phdr.feed, payload.sevsnpvm_guest_svn};
335+
pal::UVMEndorsements end{did, phdr.feed, sevsnpvm_guest_svn};
285336

286337
if (
287338
enforce_uvm_roots_of_trust &&

src/node/uvm_endorsements.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@
1919

2020
namespace ccf
2121
{
22-
struct UVMEndorsementsPayload
23-
{
24-
std::string sevsnpvm_guest_svn;
25-
std::string sevsnpvm_launch_measurement;
26-
};
27-
DECLARE_JSON_TYPE(UVMEndorsementsPayload);
28-
DECLARE_JSON_REQUIRED_FIELDS_WITH_RENAMES(
29-
UVMEndorsementsPayload,
30-
sevsnpvm_guest_svn,
31-
"x-ms-sevsnpvm-guestsvn",
32-
sevsnpvm_launch_measurement,
33-
"x-ms-sevsnpvm-launchmeasurement");
34-
3522
struct UvmEndorsementsProtectedHeader
3623
{
3724
int64_t alg;
10.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)