Skip to content

Commit

Permalink
Remove now-unused security_context_directory (#5868)
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou authored Dec 19, 2023
1 parent bf36385 commit 2faaec3
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .daily_canary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-^- ___ ___
(- -) (= =) | Y & +--?
( V ) / . \ | +---=---'
/--x-m- /--n-n---xXx--/--yY------>>>----<<<>>]]{{}}---||-/\---/\__
/--x-m- /--n-n---xXx--/--yY------>>>----<<<>>]]{{}}---||-/\---..
2 changes: 1 addition & 1 deletion .snpcc_canary
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
(. =) Y (0 0) (x X) Y
O \ o | /
/-xXx--//-----x=x--/-xXx--/---x---->>>--/
......
........
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- `ccf::historical::adapter_v2` is removed, replaced by `ccf::historical::adapter_v3` first introduced in 2.0.0.
- `ccf::EnclaveAttestationProvider` has been removed. It is replaced by `ccf::AttestationProvider`
- The `attestation.environment.security_context_directory` configuration entry and `--snp-security-context-dir-var` CLI option have been removed. SNP collateral must now be provided through the `snp_security_policy_file`, `snp_uvm_endorsements_file` and `snp_endorsement_servers` configuration values. See [documentation](https://microsoft.github.io/CCF/main/operations/platforms/snp.html) for details and platform-specific configuration samples.

## [5.0.0-dev10]

Expand Down
12 changes: 0 additions & 12 deletions doc/host_config_schema/cchost_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,6 @@
"attestation": {
"type": "object",
"properties": {
"environment": {
"type": "object",
"properties": {
"security_context_directory": {
"type": ["string", "null"],
"description": "DEPRECATED: Replaced by --snp-security-context-dir-var CLI argument. Name of environment variable (e.g. ``UVM_SECURITY_CONTEXT_DIR``) specifying the directory containing the security context files (i.e. ``host-amd-cert-base64``, ``security-policy-base64`` and ``reference-info-base64``)."
}
},
"description": "Environment variables required to provide best auditability and serviceability for Azure Container Instance deployments (SEV-SNP only)",
"required": [],
"additionalProperties": false
},
"snp_security_policy_file": {
"type": ["string", "null"],
"description": "Path to file containing the security policy (SEV-SNP only), can contain environment variables, such as $UVM_SECURITY_CONTEXT_DIR"
Expand Down
9 changes: 4 additions & 5 deletions doc/operations/platforms/snp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ Confidential Azure Container Instance (ACI)

.. note:: See `here <https://learn.microsoft.com/en-us/azure/container-instances/container-instances-tutorial-deploy-confidential-containers-cce-arm>`_ for more information on the deployment of confidential containers in Azure.

Azure Confidential ACI provides a security context directory containing the following files. The content of these files are checked against the attestation report on node startup and join, and stored in the ledger for audit and improved serviceability.
Azure Confidential ACI provides a security context directory containing the following files.

- ``host-amd-cert-base64``: The certificate chain corresponding to the key (VCEK) used to sign the attestation report, up to the well-known AMD root of trust certificate authority (Base64 encoded).
- ``security-policy-base64``: The security policy [#security_policy]_ describing the state and transitions allowed for the container (Base64 encoded). The SHA256 hash of the decoded value should match the attestation report ``host_data``. This value is stored in the :ref:`audit/builtin_maps:``nodes.snp.host_data``` table.
- ``reference-info-base64``: The COSE Sign1 document containing the measurement [#measurement]_ of the utility VM (UVM) used to launch the container (Base64 encoded). The measurement contained in the document payload should match the report ``measurement``. If set, the value is stored in the :ref:`audit/builtin_maps:``nodes.snp.uvm_endorsements``` table and new nodes must present measurement endorsements from the same issuer (`did:x509`) to be trusted.

The location of the security context directory is passed to the container's startup command as the ``UVM_SECURITY_CONTEXT_DIR`` environment variable. The name of an alternative environment variable may be specified as the value of the ``--snp-security-context-dir-var`` CLI argument, if an alternative trust root is needed.
The location of the security context directory is passed to the container's startup command as the ``UVM_SECURITY_CONTEXT_DIR`` environment variable. CCF can be configured to fetch the security policy and UVM endorsements from the security context directory by setting the ``snp_security_policy_file`` and ``snp_uvm_endorsements_file`` configuration options, respectively.

AMD endorsements must be fetched, preferably from the THIM service, but configuring the Azure cache or the AMD server is also possible.

.. tip:: See :ccf_repo:`samples/config/start_config_aci_sev_snp.json` for a sample node configuration for ACI deployments.

Expand All @@ -41,8 +42,6 @@ The security policy must be provided by the operator, and will be picked up by C

AMD endorsements must be fetched, preferably from the THIM service, but configuring the Azure cache or the AMD server is also possible.

The location of the security context directory is passed to the container's startup command as the ``UVM_SECURITY_CONTEXT_DIR`` environment variable. The name of an alternative environment variable may be specified as the value of the ``--snp-security-context-dir-var`` CLI argument, if an alternative trust root is needed.

.. tip:: See :ccf_repo:`samples/config/start_config_aks_sev_snp.json` for a sample node configuration for Confidential AKS deployments.


Expand Down
3 changes: 0 additions & 3 deletions include/ccf/node/startup_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ struct CCFConfig

struct Environment
{
std::optional<std::string> security_context_directory = std::nullopt;

std::optional<std::string> security_policy = std::nullopt;
std::optional<std::string> uvm_endorsements = std::nullopt;
std::optional<std::string> report_endorsements = std::nullopt;

bool operator==(const Environment&) const = default;
};
Expand Down
7 changes: 2 additions & 5 deletions samples/config/start_config_aci_sev_snp.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@
}
},
"attestation": {
"environment": {
"security_context_directory": "UVM_SECURITY_CONTEXT_DIR"
},
"snp_endorsements_servers": [
{
"type": "THIM",
"url": "169.254.169.254"
"type": "Azure",
"url": "global.acccache.azure.net"
}
],
"snp_security_policy_file": "$UVM_SECURITY_CONTEXT_DIR/security-policy-base64",
Expand Down
6 changes: 1 addition & 5 deletions src/common/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ DECLARE_JSON_OPTIONAL_FIELDS(CCFConfig::JWT, key_refresh_interval);
DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::Attestation::Environment);
DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::Attestation::Environment);
DECLARE_JSON_OPTIONAL_FIELDS(
CCFConfig::Attestation::Environment,
security_context_directory,
security_policy,
uvm_endorsements,
report_endorsements);
CCFConfig::Attestation::Environment, security_policy, uvm_endorsements);

DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::Attestation);
DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::Attestation);
Expand Down
43 changes: 0 additions & 43 deletions src/host/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@ int main(int argc, char** argv)
enclave_file_path,
"Path to enclave application (security critical)");

std::string snp_security_context_dir_var = "UVM_SECURITY_CONTEXT_DIR";
app
.add_option(
"--snp-security-context-dir-var",
snp_security_context_dir_var,
"Name of environment variable specifying the directory containing the "
"SNP UVM security context files (security critical)")
->capture_default_str();

try
{
app.parse(argc, argv);
Expand Down Expand Up @@ -510,40 +501,6 @@ int main(int argc, char** argv)

startup_config.snapshot_tx_interval = config.snapshots.tx_count;

if (config.attestation.environment.security_context_directory.has_value())
{
LOG_FAIL_FMT(
"DEPRECATED: security_context_dir was specified in config file! This "
"should be removed from the config, and passed directly to the CLI. "
"Note that the CLI provides a default value, which may be sufficient");

snp_security_context_dir_var =
config.attestation.environment.security_context_directory.value();
}

// This will be deprecated in favour of explicit configuration entries,
// such as snp_security_policy_file and snp_endorsements_servers
if (config.enclave.platform == host::EnclavePlatform::SNP)
{
auto dir = read_required_environment_variable(
snp_security_context_dir_var, "security context directory");

constexpr auto security_policy_filename = "security-policy-base64";
startup_config.attestation.environment.security_policy =
files::try_slurp_string(
fs::path(dir) / fs::path(security_policy_filename));

constexpr auto uvm_endorsements_filename = "reference-info-base64";
startup_config.attestation.environment.uvm_endorsements =
files::try_slurp_string(
fs::path(dir) / fs::path(uvm_endorsements_filename));

constexpr auto report_endorsements_filename = "host-amd-cert-base64";
startup_config.attestation.environment.report_endorsements =
files::try_slurp_string(
fs::path(dir) / fs::path(report_endorsements_filename));
}

if (startup_config.attestation.snp_security_policy_file.has_value())
{
auto security_policy_file =
Expand Down
39 changes: 5 additions & 34 deletions src/node/node_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,12 @@ namespace ccf
// Note: Node lock is already taken here as this is called back
// synchronously with the call to pal::generate_quote

if (
qi.format == QuoteFormat::amd_sev_snp_v1 &&
!config.attestation.snp_endorsements_servers.empty())
if (qi.format == QuoteFormat::amd_sev_snp_v1)
{
CCF_ASSERT_FMT(
!config.attestation.snp_endorsements_servers.empty(),
"One or more SNP endorsements servers must be specified to fetch "
"the collateral for the attestation");
// On SEV-SNP, fetch endorsements from servers if specified
quote_endorsements_client =
std::make_shared<QuoteEndorsementsClient>(
Expand Down Expand Up @@ -440,37 +442,6 @@ namespace ccf
"SGX quote generation should have already fetched endorsements");

quote_info = qi;

if (
quote_info.format == QuoteFormat::amd_sev_snp_v1 &&
config.attestation.environment.report_endorsements.has_value())
{
// On SEV-SNP, if reports endorsements are passed via
// environment, read those
pal::snp::ACIReportEndorsements endorsements =
nlohmann::json::parse(crypto::raw_from_b64(
config.attestation.environment.report_endorsements.value()));

CCF_ASSERT_FMT(
quote_info.endorsements.empty(),
"No endorsements should be set by quote generation");

quote_info.endorsements.insert(
quote_info.endorsements.end(),
endorsements.vcek_cert.begin(),
endorsements.vcek_cert.end());
quote_info.endorsements.insert(
quote_info.endorsements.end(),
endorsements.certificate_chain.begin(),
endorsements.certificate_chain.end());

// Endianness of ACI report endorsements tcbm retrieved from
// environment is reversed
auto raw_tcb = ds::from_hex(endorsements.tcbm);
std::reverse(raw_tcb.begin(), raw_tcb.end());
quote_info.endorsed_tcb = ds::to_hex(raw_tcb);
}

launch_node();
};

Expand Down
5 changes: 0 additions & 5 deletions tests/infra/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,11 +865,6 @@ def __init__(
"--enclave-file",
self.enclave_file,
]
if snp_security_context_directory_envvar is not None:
cmd += [
"--snp-security-context-dir-var",
snp_security_context_directory_envvar,
]

if start_type == StartType.start:
members_info = kwargs.get("members_info")
Expand Down

0 comments on commit 2faaec3

Please sign in to comment.