feat: add auto-lock support for vault agent#7
Merged
danpasecinic merged 4 commits intomainfrom Jan 25, 2026
Merged
Conversation
Add automatic locking capability to AgentServer based on inactivity: - Accept auto_lock_minutes parameter in init() - Track last_activity timestamp, reset on each client interaction - Use poll() with 10s timeout instead of blocking accept - Auto-lock when inactivity exceeds configured timeout - Set auto_lock_minutes=0 to disable (auto_lock_ns becomes null) Includes tests for timeout calculation and disabled state.
Wire up auto-lock configuration to the agent: - Pass config.auto_lock_minutes to AgentServer.init() - Display auto-lock status message on successful unlock - Update help text documenting auto-lock behavior and config
Security fixes: - Zero derived_key immediately when auto-lock triggers - Zero derived_key on repeated poll errors (>10 consecutive) Robustness improvements: - Handle clock skew by resetting activity on negative elapsed time - Track consecutive poll errors, exit if threshold exceeded - Only reset activity timer on active commands (GET_KEY), not STATUS Code quality: - Add comment explaining poll timeout tradeoff - handleClient now returns bool indicating active vs passive command - Add test for max timeout value (24 hours)
Cap auto_lock_minutes at 1440 (24 hours) to prevent unreasonable configuration values. Values above 24 hours are silently clamped. Includes tests for validation behavior.
265b486 to
4b08dd0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[security] auto_lock_minutes)Changes
Test plan
zig build test- all tests passzault unlockshows auto-lock status messagezault unlock --helpdocuments auto-lock behaviorauto_lock_minutes = 0disables auto-lock