MEDIUM: Add input validation and allowlist to /config/set API endpoint #43
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The /config/set API endpoint in bot/api.py accepts arbitrary key paths and values without any validation or restrictions. A caller can overwrite ANY configuration key with ANY value, including:
Since the dashboard is accessible on the local network (port 3939), any device on the network can modify arbitrary configuration.
Current Behavior
Proposed Solution
1. Allowlist of modifiable keys
Define which configuration keys are safe to modify at runtime:
2. Type validation
Validate that the provided value matches the expected type for that key (leveraging Pydantic models if the config unification issue is completed first).
3. Value range validation
For numeric values, add min/max constraints:
Impact
Files Affected