microsoft / microsoft/agent-governance-toolkit
supervisor.validate_hierarchy is O(max_level): a huge integer level hangs validation
- Dominant language
- Python
- Stars
- 6.3k
- Forks
- 1.1k
- Avg merge
- 5d 11h
- Merged PRs (30d)
- 142
Description
`agent-governance-python/agent-os/src/agent_os/supervisor.py:109-110` scans every integer from 0 to the maximum registered level to detect gaps. A supervisor registered with a pathologically large integer level (e.g. `level=10**100`) makes `validate_hierarchy()` hang — Python ints are unbounded, so the gap scan never completes in practice.
Since levels come from configuration that may be attacker-influenced in multi-tenant setups, this is a denial-of-service vector against any caller that validates before acting.
Suggested direction: derive gaps from the *sorted set of registered levels* (O(n log n) in the number of supervisors) instead of iterating the numeric range, and/or reject levels above a sane bound at registration.
Noticed while reviewing #3748, which fixes the adjacent non-integer-level crash but does not change the gap scan (present on `main` before and after).
Contributor guide
Research direction
Start in agent-governance-python/agent-os/src/agent_os/supervisor.py at lines 109-110 and inspect validate_hierarchy(). Reproduce the problem with a registered supervisor at level=10**100, then verify that validation completes without scanning every integer level and still detects gaps among registered levels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100