Skip to content

Commit 47f8a85

Browse files
committed
Added entombment of secrets
[*Major Security Improvement*] * This release introduces 'entombment' of Vault secrets into Credhub for increased security in the transport of your secrets on deployment. In previous versions, the `(( vault ... ))` operators in the manifest fragments, your environment and ops/ YAML files would resolve locally, placing the secrets needed from vault into the manifest. Unfortunately, this would be done in clear text. The alternative secret store is Credhub, and a few kits still use Credhub to contain the deployments secrets. However, Credhub lacks the ability to manage your secrets as well as Vault, requiring a different tooling, or just simply deleting all secrets and allowing them to be generated again. The final issue is that becase the placeholder variable doesn't change, there is no visual confirmation that you have changed the value of a Credhub secret on deployment. Genesis 2.9.0 brings you the best of both worlds! Vault remains the single source of truth, and you can manage your secrets with the Genesis add-secrets, check-secrets, rotate-secrets and remove-secrets commands, independent of the BOSH director. However, when it comes time to deploy your manifest, Genesis determines what Vault paths are being used by the manifest, pulls them into memory, runs a sha1sum on the values, then determines Credhub path to inject each of those Vault values into based on its vault path and value. This results in a unique and idempotent variable that only changes if the value it contains changes. The value is stored at that path in Credhub if it doesn't already exist. When merging the manifest, the vault operators now resolve to that unique Credhub path that contains the desired value, and there are no longer any cleartext secrets in the manifest, the log, or even if you pull down the manifest using the `bosh manifest` command. This is enabled on default for the `genesis deploy` command, and can be enabled using the `--entomb` option for the manifest and lookup commands. Likewise, it can be disabled on the deploy command with --no-entomb option. You can also set it as a local setting in your ~/.genesis/config file with `entomb_secrets` key that can be set true or false. The command line options will take precedent over the config file. Note: The values are left in Credhub after the deploy to ensure any recreate or other BOSH operations that require the manifest to be intact still work. Over time, this will result in Credhub containing values that are no longer used, including expired X509 certificates, which may trigger false positives in Doomsday cert expiry monitoring tool. Future version of Genesis will enable cleaning out any old values that are no longer being used.
1 parent 5378d27 commit 47f8a85

File tree

6 files changed

+268
-1783
lines changed

6 files changed

+268
-1783
lines changed

bin/genesis

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ define_command("manifest", {
312312
"Determines if vault values are fetched or redacted. By default, the ".
313313
"manifest will be redacted unless being output to the live console.",
314314

315+
'entomb' =>
316+
"Will entomb valut secrets into the BOSH director's credhub as is done ".
317+
"when deploying, providing a manifest that does not contain any clear ".
318+
"text secrets",
319+
315320
'prune!' =>
316321
"Determines if the build metadata is pruned. Defaults to true.",
317322

@@ -384,6 +389,14 @@ define_command("deploy", {
384389

385390
'max-in-flight=i' =>
386391
"Override the default number of maximum VMs in flight per instance group.",
392+
393+
'entomb!' =>
394+
"By default, deployments to BOSH directors will entomb vault secrets into ".
395+
"the director's CredHub, then use CredHub variable operators to prevent ".
396+
"secrets from being present in clear text in the manifest. This can be ".
397+
"prevented by specifying --no-entomb as an option, or by setting ".
398+
"'entomb_secrets: false' in your #C{~/.genesis/config} file. The option ".
399+
"will override the configuration file setting.",
387400
]
388401
});
389402
# }}}
@@ -450,7 +463,7 @@ define_command("info", {
450463
# genesis lookup - Find a key set in environment manifests. {{{
451464
define_command("lookup", {
452465
summary => "Look up values from an environment's file, manifest, deployment, exodus or env state.",
453-
usage => "<env> lookup [--merged|--deployed|--env|--exodus|] key [default-value|--defined]\n".
466+
usage => "<env> lookup [--merged|--deployed|--env|--exodus|] key [default-value|--defined] [--entomb]\n".
454467
"lookup --exodus-for <env/type> key [default-value|--defined]",
455468
alias => 'get',
456469
description =>
@@ -474,6 +487,11 @@ define_command("lookup", {
474487
"Takes an argument of the form 'env-name/deployment-type'",
475488
"env" =>
476489
"Lookup environment variables used by Genesis for the given environment.",
490+
"entomb" =>
491+
"Entomb the vault secrets in the BOSH director's credhub before ".
492+
"rendering the manifest, so that if looking up a secret, return the ".
493+
"reference to credhub instead. Not applicable to exodus or deployed ".
494+
"manifests",
477495
"defined" =>
478496
"Exit with 0 if key defined in specified source, 9 otherwise. No output ".
479497
"is produced, making it useful in 'if lookup ... ; then'"

lib/Genesis/Commands/Env.pm

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,24 +254,26 @@ sub manifest {
254254
);
255255
}
256256

257-
print $env
257+
output {raw => 1}, $env
258258
->download_required_configs('blueprint', 'manifest')
259259
->manifest(
260260
partial => get_options->{partial},
261261
redact => get_options->{redact},
262262
prune => get_options->{prune},
263-
vars_only => get_options->{'bosh-vars'}
263+
vars_only => get_options->{'bosh-vars'},
264+
entomb => get_options->{entomb}
264265
);
265266
}
266267

267268
sub deploy {
268269
option_defaults(
269-
redact => ! -t STDOUT
270+
redact => ! -t STDOUT,
271+
entomb => $Genesis::RC->get('entomb_secrets',1)
270272
);
271273
command_usage(1) if @_ != 1;
272274

273275
my %options = %{get_options()};
274-
my @invalid_create_env_opts = grep {$options{$_}} (qw/fix dry-run/);
276+
my @invalid_create_env_opts = grep {$options{$_}} (qw/fix dry-run entomb/);
275277

276278
$options{'disable-reactions'} = ! delete($options{reactions});
277279
my $env = Genesis::Top->new('.')->load_env($_[0])->with_vault();
@@ -286,6 +288,8 @@ sub deploy {
286288
join(", ", @invalid_create_env_opts)
287289
) if $env->use_create_env && @invalid_create_env_opts;
288290

291+
$options{entomb} = 1 unless defined($options{entomb}) || $env->use_create_env;
292+
289293
info "Preparing to deploy #C{%s}:\n - based on kit #c{%s}\n - using Genesis #c{%s}", $env->name, $env->kit->id, $Genesis::VERSION;
290294
if ($env->use_create_env) {
291295
info " - as a #M{create-env} deployment\n";

lib/Genesis/Commands/Info.pm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ sub lookup {
133133
}
134134
my $env = $top->load_env($name);
135135
my $v;
136+
if (get_options->{entomb}) {
137+
bail(
138+
"Cannot use --entombed option with --exodus, --exodus-for or --deployed",
139+
) if scalar( grep {$_} (@{get_options()}{qw/exodus exodus-for deployed/}));
140+
$env->entombed_secrets_enabled(1);
141+
}
142+
136143
if (get_options->{merged}) {
137144
bail(
138145
"Circular reference detected while trying to lookup merged manifest of $name"
@@ -167,7 +174,7 @@ sub lookup {
167174
exit(ref($v) eq "NotFound" ? 4 : 0);
168175
} elsif (defined($v)) {
169176
$v = encode_json($v) if ref($v);
170-
output {raw => 1}, "$v\n";
177+
output {raw => 1}, $v;
171178
}
172179
exit 0;
173180
}

0 commit comments

Comments
 (0)