You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(core): add comprehensive security hardening to models
Implement multiple layers of security protection in core models to prevent
command injection, DoS attacks, and resource exhaustion.
Security Enhancements:
1. Command Injection Prevention (BashActionConfig):
- Added allow_shell_features flag (default: False)
- Validates commands to block shell metacharacters
- Rejects: pipes, redirects, command substitution, variable expansion
- Clear error messages guide users to explicit opt-in
- 13 tests for injection patterns
2. DoS Protection (SessionState):
- Validates option_values and variables for depth/size
- Maximum 1000 options/variables
- Integration with validators module
- 8 tests for DoS scenarios
3. Collection Size Limits:
- BranchConfig: 100 actions, 50 options, 20 menus
- WizardConfig: 100 branches
- Prevents memory exhaustion from config files
- 6 tests for collection limits
4. Entry Branch Validation (WizardConfig):
- Ensures entry_branch exists in branches list
- Helpful error messages show available branches
- 3 tests for validation scenarios
Test Coverage:
- 30 security-focused tests in test_security.py
- All existing tests updated and passing
- 100% coverage of new security code
Breaking Changes:
- Commands with shell features now require allow_shell_features=True
- Wizard configs with invalid entry_branch now fail validation
- Large collections/deep nesting now rejected
Migration:
- Set allow_shell_features=True for commands needing pipes/redirects
- Ensure entry_branch matches a branch ID
- Review any configs with >100 branches or >50 options
Part of security hardening (Priorities 1, 2, 3)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments