diff --git a/README.md b/README.md index 2b55fdb..e30cd98 100644 --- a/README.md +++ b/README.md @@ -55,14 +55,16 @@ steps: role: iuclabs jwtGithubAudience: https://vault.service.consul:8200 secrets: | - kv/data/github/IUCLabs//event/push/deploy token | DEPLOY_TOKEN + kv/data/github/IUCLabs//ref/refs/heads/main/.secrets/deploy token | DEPLOY_TOKEN ``` The role attaches a templated read-only policy, so each run reads only its own KV-v2 secrets: -- `kv/github///event//*` +- `kv/github///event//*` is not ref-scoped: any run of that event in the repo, on any branch or tag a writer pushes, can read it; keep it for secrets every such run may use - `kv/github///ref//.secrets/*`, e.g. `ref/refs/heads/main/.secrets/`, `ref/refs/tags/v1.2.3/.secrets/`; git refnames can't contain a `.`-prefixed component, so branch `x` can never read branch `x/y`'s secrets +On OpenBao older than the fork's v2.6, a ref path component of exactly `+` acts as a single-segment wildcard in the templated policy. Public IUCLabs repos block such refs via a terraform-git ruleset; private repos are not protected, so a writer in a private repo can read that repo's other refs' secrets. + `user_claim` is `jti`, so every run creates its own Vault identity entity; Vault never garbage-collects these, so entity count grows with CI volume. Extra policies are granted via a policy yaml `auth: {jwt/github/iuclabs: [iuclabs]}`; the KV read policy is attached automatically. diff --git a/modules/vault_cluster/modules/auth_jwt_role/tests/bound_claims.tftest.hcl b/modules/vault_cluster/modules/auth_jwt_role/tests/bound_claims.tftest.hcl index 7e945ff..4041746 100644 --- a/modules/vault_cluster/modules/auth_jwt_role/tests/bound_claims.tftest.hcl +++ b/modules/vault_cluster/modules/auth_jwt_role/tests/bound_claims.tftest.hcl @@ -52,6 +52,11 @@ run "ref_paths_cannot_overlap_child_refs" { run "accept_exact_refs" { command = plan variables { bound_claims = { repository_owner = "IUCLabs", event_name = "push,release,schedule,pull_request", ref = "refs/heads/main,refs/tags/v1.2.3,refs/pull/7/merge" } } + + assert { + condition = vault_jwt_auth_backend_role.role.bound_claims.ref == "refs/heads/main,refs/tags/v1.2.3,refs/pull/7/merge" + error_message = "exact refs must pass through to bound_claims unchanged" + } } run "accept_with_repository" {