step-ca: give the CA's own secret material to the uid the CA runs as
The upstream `smallstep/step-ca` image runs as uid 1000. An own-secret lands as
a file the host writes root:root 0600 — the module says only a name and a path,
so there is nowhere to say who must be able to read it — and the container
crash-looped on `permission denied` reading its own root key. The lab got past
it first with `chmod 0644`, which hands the root key to every local user, and
then by running the CA as root, which is worse.
Neither is needed. A module composes its own files, and a `file` resource takes
both a `mode` and an `owner`, with `${secret:name}` reaching the module's own
secrets — the mechanism redis already uses to hand its password to a server
running as 999. So the three pieces of init material are declared as owned
files: still 0600, owned by 1000:1000, and those are what the container mounts.
The raw own-secret files stay where they were. Nothing mounts them now; they are
how the secret comes to exist on the machine, and the host is the only thing
that reads them. Same shape as redis's `default.secret`.
Verified against the real code rather than by inspection: mesh-control attaches
the sealed value to each of the three resources and keeps `owner` and `mode`
(`sealedFor` + `intoFile` over this manifest), and mesh-host parses `owner` on a
sealed-substituted file and lands it 0600 owned by 1000:1000 (`applyFile`).
This commit is contained in:
@@ -59,6 +59,30 @@
|
|||||||
"mode": "0600",
|
"mode": "0600",
|
||||||
"content": "DOCKER_STEPCA_INIT_PASSWORD=${secret:password}\n"
|
"content": "DOCKER_STEPCA_INIT_PASSWORD=${secret:password}\n"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "root-cert-file",
|
||||||
|
"type": "file",
|
||||||
|
"path": "/var/lib/mesh/step-ca/root-cert.pem",
|
||||||
|
"mode": "0600",
|
||||||
|
"owner": "1000:1000",
|
||||||
|
"content": "${secret:root-cert}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "root-key-file",
|
||||||
|
"type": "file",
|
||||||
|
"path": "/var/lib/mesh/step-ca/root-key.pem",
|
||||||
|
"mode": "0600",
|
||||||
|
"owner": "1000:1000",
|
||||||
|
"content": "${secret:root-key}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "root-key-password-file",
|
||||||
|
"type": "file",
|
||||||
|
"path": "/var/lib/mesh/step-ca/root-key-password.txt",
|
||||||
|
"mode": "0600",
|
||||||
|
"owner": "1000:1000",
|
||||||
|
"content": "${secret:root-key-password}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "server",
|
"id": "server",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
@@ -79,9 +103,9 @@
|
|||||||
},
|
},
|
||||||
"volumes": [
|
"volumes": [
|
||||||
"/var/lib/step-ca:/home/step",
|
"/var/lib/step-ca:/home/step",
|
||||||
"/var/lib/mesh/step-ca/root-cert:/run/secrets/root_ca.crt:ro",
|
"/var/lib/mesh/step-ca/root-cert.pem:/run/secrets/root_ca.crt:ro",
|
||||||
"/var/lib/mesh/step-ca/root-key:/run/secrets/root_ca_key:ro",
|
"/var/lib/mesh/step-ca/root-key.pem:/run/secrets/root_ca_key:ro",
|
||||||
"/var/lib/mesh/step-ca/root-key-password:/run/secrets/root_ca_key_password:ro",
|
"/var/lib/mesh/step-ca/root-key-password.txt:/run/secrets/root_ca_key_password:ro",
|
||||||
"/var/lib/mesh/step-ca/config.json:/run/config/config.json:ro"
|
"/var/lib/mesh/step-ca/config.json:/run/config/config.json:ro"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user