Vault

Token-Scoped Temporary Storage with Vault Cubbyhole

2026-04-19
NicheeLab Editorial Team

Cubbyhole is a built-in Vault secrets engine that gives every token its own private namespace. When the token is revoked, the contents disappear, making it a great fit for short-lived secret storage and handoff.

This article covers how Cubbyhole works, its lifecycle, how it pairs with response wrapping, hands-on workflows, operational constraints, and the gotchas commonly tested on the exam.

Cubbyhole Basics: A Private Vault Per Token

Cubbyhole is a secrets engine that ships with Vault by default. It gives each access token its own dedicated storage area. Values written by one token can only be read by that same token. There is no way to grant access from another token or via policy delegation.

The API is simple, with no versioning or metadata management. TTL is not attached to the secret itself; it follows the lifecycle of the associated token. When the token expires or is revoked, the Cubbyhole data is automatically purged.

  • Default mount path: cubbyhole/
  • Access boundary: per-token (no access from other tokens)
  • Use cases: startup bootstrapping, short-lived token staging, and a scaffold for one-way secure handoff
AspectCubbyholeKV v2Response Wrapping
Access scopeToken-only (same token only)Shareable via policyHolder of the wrapping token only (one-time)
RetentionWhile the token livesConfigurable (versions can be kept or deleted)Within wrap-ttl (destroyed immediately on unwrap)
VersioningNoneYesTemporarily stores the target response (the actual data lives in the source engine)
Ease of sharingNot possible (intentionally closed)Possible (depends on policy design)Ideal for secure one-way handoff
Primary useBootstrapping / temporary storageLong-term key-value managementSecure delivery of secrets
When data is removedOn token expiry or revocationExplicit delete, TTL, or versioning rulesOn unwrap or wrap-ttl expiry

Basic CLI operations

vault write cubbyhole/bootstrap token=child-abc note="startup"
vault read cubbyhole/bootstrap
vault delete cubbyhole/bootstrap

Security Properties and Lifecycle: TTL, Revocation, and Inheritance

The availability of Cubbyhole data tracks the associated token, not the stored entry. Renewing the token preserves the data, while revoking it wipes the data immediately. This prevents secrets from being left behind.

Pay attention to the parent-child token relationship. Child tokens have their own Cubbyhole, isolated from the parent. When parent revocation cascades to children, the child tokens are invalidated too, and their Cubbyhole contents become inaccessible.

  • Token renewal preserves Cubbyhole contents
  • Token revocation or expiry destroys the contents
  • Policy cannot grant access to another token's Cubbyhole
  • Behavior is consistent regardless of HA setup or storage backend (per Vault's design)

Token renewal/revocation and Cubbyhole behavior (CLI example)

# トークン発行 (例)
vault token create -ttl=1h -policy=default -format=json | jq -r .auth.client_token > parent.token

# 子トークン発行 (親の権限範囲内)
VAULT_TOKEN=$(cat parent.token) vault token create -ttl=15m -format=json | jq -r .auth.client_token > child.token

# 子でCubbyholeへ保存
VAULT_TOKEN=$(cat child.token) vault write cubbyhole/boot key=value

# 親を取り消すと、親由来の子も無効化されアクセス不能に
vault token revoke $(cat parent.token)

# 以降の child.token での read は失敗する想定
VAULT_TOKEN=$(cat child.token) vault read cubbyhole/boot

Hands-On: Token-Scoped Temporary Storage Flow

Cubbyhole shines for bootstrapping: a freshly started process uses a least-privilege child token to receive temporary config or a follow-on retrieval token. The distributor writes to a location only the target process's token can see, and the process retrieves and discards it right after startup. That pattern is safe.

Direct Cubbyhole reads and writes are NOT one-time. If you need to guarantee single-use behavior, use response wrapping (covered below).

  • Issue a child token per process
  • Keep child token TTLs short and renew as needed
  • After retrieval, clean up via explicit delete or token revocation

Temporary storage via CLI / HTTP API

# CLI: 子トークンで書き込み/読み出し
VAULT_TOKEN=$CHILD_TOKEN vault write cubbyhole/config db_user=app db_pass=s3cr3t
VAULT_TOKEN=$CHILD_TOKEN vault read cubbyhole/config

# HTTP API: 書き込み
curl \
  -H "X-Vault-Token: $CHILD_TOKEN" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"db_user":"app","db_pass":"s3cr3t"}' \
  $VAULT_ADDR/v1/cubbyhole/config

# HTTP API: 読み出し
curl -H "X-Vault-Token: $CHILD_TOKEN" $VAULT_ADDR/v1/cubbyhole/config

Response Wrapping and Cubbyhole: Secure One-Time Handoff

Response wrapping seals a Vault response inside a wrapping token so it can be retrieved exactly once. Internally, Cubbyhole is used, and if the token is not unwrapped within wrap-ttl, the contents are automatically destroyed. This lets you ship only a token instead of the secret itself.

The producer attaches -wrap-ttl to any read operation, and the consumer calls vault unwrap or POSTs to /sys/wrapping/unwrap with the wrapping token. On a successful unwrap, the contents are returned and the token is invalidated.

  • Keep wrap-ttl short (e.g., 60s to 5m)
  • Wrapping tokens are single-use. Enable audit logging to watch for leaks
  • Decide your retry strategy in advance (re-wrap on failure)

Response wrapping handoff

ProducerProducer sideVaultsecret engine / cubbyholeConsumerConsumer sideread (-wrap-ttl)wrap → Wrapping Tokendeliver wrapping tokenunwrapreturn one-time secretResponse wrapping: the producer wraps and the consumer unwraps for single-use retrieval

Response wrapping example

# 秘密データを読む際にラップ (例: kv v2 上のシークレット)
# ここでは対象エンジンが何であれ、応答をラップトークン化する点がポイント
vault kv get -wrap-ttl=60s kv/app/api
# 出力: wrapping_token=... (一度だけ使用可能)

# 受け取り側: unwrap して中身を取得 (トークンは失効)
VAULT_TOKEN=$WRAPPING_TOKEN vault unwrap

# HTTP APIでも同様
curl -s -H "X-Vault-Token: $VAULT_TOKEN" \
  "$VAULT_ADDR/v1/kv/data/app/api?wrap_ttl=60s"
# レスポンスJSONの auth.client_token がラップトークン

# unwrap
curl -s -H "X-Vault-Token: $WRAPPING_TOKEN" \
  -X POST "$VAULT_ADDR/v1/sys/wrapping/unwrap"

Operations and Constraints: What to Store and What Not To

Cubbyhole is ideal for lightweight temporary storage but unsuitable for large binaries or long-lived config files. Size limits depend on the underlying storage and operational policy, so as a rule, target small secrets and tokens only.

If audit logging is enabled, access under cubbyhole/ is also recorded (the data itself is masked). This is useful for leak detection and monitoring how wrapping tokens are handled.

  • Default policy: small values, short-lived, disposable
  • Clean up via explicit delete or token revocation when no longer needed
  • Use other engines like KV v2 for long-term storage or sharing

Make cleanup explicit

# 取り出し後に削除
VAULT_TOKEN=$CHILD_TOKEN vault delete cubbyhole/config

# 役目が終わった子トークンを取り消す
vault token revoke $CHILD_TOKEN

Exam Prep: Common Misconceptions and Terminology

Cubbyhole is private storage attached to a token. It is not designed to be shared with others via policy. Do not confuse it with the sharing and versioning model of KV v2.

Response wrapping is the mechanism that delivers one-time retrieval, and you should remember that it uses Cubbyhole internally. Contents are destroyed on wrap-ttl expiry or on a successful unwrap.

  • Keywords: per-token isolation, deleted on revoke, wrap-ttl, unwrap = single-use
  • Design choices: KV for sharing/long-term, wrapping for single-use delivery, Cubbyhole for short-lived same-token handoff
  • Gotcha: putting data in Cubbyhole alone does not make it single-use (only wrapping does)

One-liner sanity check

# Cubbyholeはこのトークンでしか読めるべきでない
VAULT_TOKEN=$OTHER_TOKEN vault read cubbyhole/boot  # -> 権限外エラーになる想定

Check Your Understanding

Associate

問題 1

Which statement about Vault's Cubbyhole is correct? Assume Associate level.

  1. Only the same token can access its own Cubbyhole, and the contents become unreachable when the token expires
  2. With the right ACL policy, you can share another token's Cubbyhole
  3. Cubbyhole supports versioning just like KV v2
  4. Response wrapping is unrelated to Cubbyhole and does not use it internally

正解: A

Cubbyhole is isolated per token, and only the same token can read or write its contents. Token revocation or expiry makes the contents unreachable. You cannot share another token's Cubbyhole via ACL, and there is no versioning. Response wrapping internally uses Cubbyhole to deliver one-time retrieval.

Frequently Asked Questions

Can I set a TTL directly on Cubbyhole?

No. The lifetime of a Cubbyhole entry follows the lifecycle of the associated token. To control expiration, use the token TTL/Max TTL/renewal, or use wrap-ttl with response wrapping.

Can Cubbyhole be disabled or remounted at a different path?

Cubbyhole ships as a built-in engine in Vault and is used at the default cubbyhole/ path. It is not designed to be freely disabled or remounted like a typical secrets engine.

How can I guarantee single-use, one-time delivery?

Use response wrapping. Add -wrap-ttl to wrap the response, and the recipient calls unwrap. On a successful unwrap or TTL expiry, the contents are destroyed, guaranteeing one-time retrieval.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Vault

Vault Core Concepts: Sealed/Unsealed, Auth, Secrets (2026)

Vault fundamentals — sealed/unsealed state, auth methods, se...

Vault

Vault Operations Professional (VOP-003): Complete Guide (2026)

Pass the Vault Operations Professional exam — enterprise pat...

Vault

Vault Path-Based Routing: API URL Structure (2026)

How Vault's path-based routing works — mount points, sub-pat...

Vault

Vault Tokens: Auth Token Mechanics (2026)

Token fundamentals — service vs. batch tokens, accessor, ren...

Vault

Vault Token Types: Service, Batch, Periodic (2026)

Service vs. batch tokens compared — performance, ACL behavio...

Browse all Vault articles (101)
© 2026 NicheeLab All rights reserved.