Vault guarantees operation traceability by writing requests and responses to audit devices.
This article focuses on tamper-resistance and storage (retention, rotation, aggregation) of audit logs, covering both production practice and certification prep.
Vault audit devices emit metadata for every request and response. The main types are file, syslog, and socket, and you can enable multiple devices at once. In production, the standard practice is to enable at least one audit device, and ideally to duplicate audit output across different paths.
Sensitive values inside audit logs (tokens, secrets, and so on) are HMAC-hashed using a key unique to each audit device — the raw values are never recorded. This prevents leakage of sensitive data while still enabling correlation analysis via consistent hashes. Tamper-resistance comes from HMAC hashing combined with immutable storage (append-only/WORM/permissions) and a tamper-resistant transport path.
| Device | Primary Use | Tamper Defense Strategy | Availability / Latency Characteristics |
|---|---|---|---|
| file | Single-node or simple deployments. Writes JSON lines locally | Strict file permissions, append-only, disciplined logrotate, forward to a downstream audit server | Vulnerable to disk-full conditions. Stable at high throughput. Filesystem failures risk failing requests |
| syslog | Centralized aggregation via the OS syslog (SIEM, etc.) | WORM and tamper-detection on the remote receiver, choose TCP/TLS, separate privileges | Sensitive to network degradation. UDP risks loss, TCP increases latency |
| socket | Sends directly to a collector (TCP/UDP/UNIX) | Protect the path and endpoint with mTLS or UNIX permissions | Heavily dependent on the collector. Plan for redundancy in case backpressure fails requests |
Audit log tamper-resistance and storage paths (example)
Minimum enablement steps: list devices and add a file device
vault audit list
vault audit enable file file_path=/var/log/vault_audit.log mode=0640
# 推奨: root所有、ディレクトリは事前作成、監査専用パーティションも検討Audit devices are enabled by name and mounted under /sys/audit/<name>. You can configure multiple file/syslog/socket devices simultaneously. The operational rule of thumb is to duplicate across heterogeneous systems (local retention + remote aggregation).
For file, write permissions and rotation design are critical. For syslog/socket, network health directly drives audit availability. At initial configuration, prioritize permissions, paths, and network (firewall/TLS) checks.
Configuration examples via CLI and API (including syslog/socket)
# syslog 例
vault audit enable syslog tag=vault facility=AUTH
# socket 例 (TCPでコレクタへ)
vault audit enable socket socket_type=tcp address=collector.internal:1514
# APIでfileデバイスを有効化
curl -sS \
--header "X-Vault-Token: $VAULT_TOKEN" \
--request PUT \
--data '{"type":"file","options":{"file_path":"/var/log/vault_audit.log","mode":"0640"}}' \
$VAULT_ADDR/v1/sys/audit/file-1
# 無効化
vault audit disable file-1Audit logs are typically line-delimited JSON. Representative fields include time, type, request (operation/path/remote address/headers), auth (accessor/policies), response (status/warnings), and error. Sensitive values are HMAC-hashed using a per-device key.
To search for occurrences of a specific raw value, have Vault compute the hash for the target device and match against that. This lets you correlate operations involving the value without ever exposing the value itself.
Sample log line and hash-based search
# サンプル監査行(JSON一行)
{"time":"2026-04-19T09:12:34.567Z","type":"request","auth":{"client_token":"hmac-sha256:7f...","accessor":"hmac-sha256:62...","policies":["default"],"display_name":"token"},"request":{"id":"6f...","operation":"read","path":"secret/data/foo","remote_address":"10.0.0.5"},"response":{"status":200},"error":false}
# 値のハッシュを生成し、ログ検索に利用
vault audit hash file/ my-actual-token
# => hmac-sha256:abc123...
# 生成されたハッシュ文字列でログをgrep/jq検索Tamper-resistance hinges on hardening the storage layer. For file devices, minimize permissions and combine with append-only or WORM storage. For syslog/socket, ensure immutability on the remote receiver (tamper detection / chained protection of the audit trail).
Rotation is the basic safeguard against capacity exhaustion. For file devices, pick a reliable procedure that fits your environment, such as copytruncate or rename + SIGHUP. Since the default audit-device behavior is to fail requests when writes are blocked, rehearse link outages and disk-full scenarios to understand the SLO impact.
An example logrotate configuration for the file device
/var/log/vault_audit.log {
daily
rotate 14
compress
missingok
notifempty
copytruncate
create 0640 root root
}
# 監査要件に応じて保持期間/圧縮/暗号化を調整After configuration, automate write verification. As a simple check, intentionally call the API and verify that audit lines increase and the collector receives the same count.
When troubleshooting, check the state in vault audit list, output permissions and free space, and collector reachability. Because failed audit writes cause requests themselves to fail, a rise in application-side error rates is usually the easiest signal to spot.
Verification snippets
# 監査デバイス一覧
vault audit list -format=json | jq '.'
# ダミーリクエストで監査行を発生
vault kv get -field=value secret/data/foo || true
# fileに出る最新10行を確認
tail -n 10 /var/log/vault_audit.log | jq -c '{time,type,req:(.request|{op:.operation,path})}'
# 値検索に必要なHMACの生成
vault audit hash file/ my-actual-tokenCommon exam topics include enabling auditing, the device types, the purpose of HMAC, redundancy, failure-mode behavior, and search methods (audit hash). Lock in these points with their practical context in mind.
Associate / Ops
問題 1
You are designing Vault auditing for production. From a tamper-resistance and storage standpoint, which combination is most appropriate?
正解: A
Duplicated auditing (local append-only + remote WORM) plus minimum permissions delivers both tamper-resistance and availability. UDP-only risks loss, mode 777 invites tampering and leakage, and disabling audit is unacceptable for compliance.
What happens to Vault requests if an audit device becomes unwritable?
By default, if any enabled audit device cannot be written to, the request fails. This is intentional, to prevent unaudited operations. Validate the impact with fault injection at design time, and rely on redundancy and monitoring.
How do you correlate HMAC-hashed values in audit logs?
Run vault audit hash <device/> <value> to generate the HMAC for the target device, then search logs with that hash string. Each device uses a distinct key, so searches must be scoped per device.
Which is better for logrotate: rename or copytruncate?
It depends on your environment. Rename requires reopening the file descriptor, so pair it with a SIGHUP-style reload. Copytruncate is simpler to switch over but carries a small risk of momentary loss, so either way you should rehearse in production-like environments and combine with monitoring.
Practice with certification-focused question sets
無料で問題を解いてみる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.
Vault Core Concepts: Sealed/Unsealed, Auth, Secrets (2026)
Vault fundamentals — sealed/unsealed state, auth methods, se...
Vault Operations Professional (VOP-003): Complete Guide (2026)
Pass the Vault Operations Professional exam — enterprise pat...
Vault Path-Based Routing: API URL Structure (2026)
How Vault's path-based routing works — mount points, sub-pat...
Vault Tokens: Auth Token Mechanics (2026)
Token fundamentals — service vs. batch tokens, accessor, ren...
Vault Token Types: Service, Batch, Periodic (2026)
Service vs. batch tokens compared — performance, ACL behavio...