Chapter 94: HashiCorp Vault and Secrets Management
94.10 AppRole and workload identity — avoid the secret-zero trap
Story (fictional teaching scenario). At a fictional Thane firm, Ben from Melbourne asks where the credential used to fetch credentials will come from. This is the bootstrap question, not something Vault magically removes.
Why
An app still needs an initial trusted way to prove its identity.
What
- AppRole is an auth method often using a role ID plus a SecretID under configured constraints.
- RoleID identifies the role; SecretID is sensitive authentication proof in the common two-part setup.
- Workload identity uses an existing trusted identity assertion, such as a correctly validated signed JWT (JSON Web Token: a signed set of identity claims).
- Response wrapping places a response behind a short-lived single-use wrapping token. It limits delivery exposure, not identity verification.
How
-
Use an approved platform identity when possible.
-
If using AppRole, separate bootstrap delivery channels and constrain SecretID use/lifetime.
-
Validate assertion issuer, audience and subject; never trust arbitrary JWT text.
-
Never place root tokens or SecretIDs in Git or image layers.
Example 1: AppRole request shape only
- Read the command or request.
{"role_id":"DEMO_ROLE_ID","secret_id":"DEMO_SECRET_ID_NOT_VALID"}
- Read the result.
Output (illustrative; NOT executed against Vault)
Login can return a scoped token if configured proof is valid.
- Line by line: These are obvious placeholders and do not authenticate anywhere. The server verifies configured role requirements. The sensitive token response is omitted. No auth method is enabled or modified here.
Example 2: Wrapping is delivery, not encryption for your app
- Read the command or request.
Producer -> one-time wrapping token -> intended consumer unwraps once
- Read the result.
Output (illustrative; NOT executed against Vault)
Wrapping response has a short expiry and one-time unwrap semantics.
- Line by line: The wrapper is itself sensitive. A stolen wrapper can be consumed by an attacker; the receiver must validate expected delivery and handle failures. Wrapping does not make an untrusted runner safe.
Ravindra Bagale's Tip
Do not trade one long-lived secret for another hidden long-lived secret.
एक long-lived secret काढून दुसरं लपवलेलं long-lived secret ठेवू नका.
एक long-lived secret हटाकर दूसरा छिपा long-lived secret मत रखो.
Did you understand? Let us try it once more.