UAT: enforce_permission decorator not wired to CLI commands or service boundaries in server mode — access control is bypassed #2551

Open
opened 2026-04-03 18:52:33 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/permission-enforcement-wiring
  • Commit Message: feat(security): wire enforce_permission decorator to CLI and service boundaries
  • Milestone: v3.6.0
  • Parent Epic: #397

Bug Description

The PermissionService and enforce_permission decorator exist in src/cleveragents/application/services/permission_service.py, but the decorator is not applied to any CLI command or service method. The docstring in permission_service.py explicitly acknowledges this:

"Actual wiring of the decorator into CLI and service call sites is deferred to a future integration pass."

In server mode (CLEVERAGENTS_SERVER_MODE=1), PermissionService.check_permission() evaluates role bindings against the permission policy. However, since enforce_permission is never applied at CLI or service boundaries, all server-mode permission checks are effectively bypassed — any user can perform any action regardless of their role.

Expected Behavior (from spec)

Per the spec section Core Concepts > Server > Multi-user Risks and Prompt Injection:

Server mode must include:

  • access boundaries
  • prompt sanitization / safe templating
  • resource access controls
  • auditing

The enforce_permission decorator must be applied at CLI command boundaries and/or service method boundaries to enforce access control in server mode.

Code Location

  • Decorator definition: src/cleveragents/application/services/permission_service.pyenforce_permission() function
  • Not applied anywhere: No @enforce_permission(...) decorator usage found in the codebase
  • Acknowledgment in docstring: "Actual wiring of the decorator into CLI and service call sites is deferred to a future integration pass"

Steps to Reproduce

# Set server mode
export CLEVERAGENTS_SERVER_MODE=1

# Even with a restricted role binding, all operations succeed
# because enforce_permission is never applied
agents plan list  # Should check permission, but doesn't
agents actor add ...  # Should check permission, but doesn't

Subtasks

  • Identify all CLI commands that require permission checks in server mode
  • Apply @enforce_permission(action=..., scope=...) to relevant CLI commands
  • Apply @enforce_permission(...) to service methods that mutate shared state
  • Wire PermissionService into the DI container
  • Add BDD tests verifying permission enforcement in server mode
  • Add BDD tests verifying local mode bypasses permission checks

Definition of Done

  • @enforce_permission is applied to all write operations in server mode
  • Unauthorized users receive PermissionError when attempting restricted operations
  • Local mode (default) continues to allow all operations without permission checks
  • All permission enforcement paths have BDD test coverage

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/permission-enforcement-wiring` - **Commit Message**: `feat(security): wire enforce_permission decorator to CLI and service boundaries` - **Milestone**: v3.6.0 - **Parent Epic**: #397 ## Bug Description The `PermissionService` and `enforce_permission` decorator exist in `src/cleveragents/application/services/permission_service.py`, but the decorator is **not applied to any CLI command or service method**. The docstring in `permission_service.py` explicitly acknowledges this: > "Actual wiring of the decorator into CLI and service call sites is deferred to a future integration pass." In server mode (`CLEVERAGENTS_SERVER_MODE=1`), `PermissionService.check_permission()` evaluates role bindings against the permission policy. However, since `enforce_permission` is never applied at CLI or service boundaries, all server-mode permission checks are effectively bypassed — any user can perform any action regardless of their role. ## Expected Behavior (from spec) Per the spec section **Core Concepts > Server > Multi-user Risks and Prompt Injection**: > Server mode must include: > * access boundaries > * prompt sanitization / safe templating > * resource access controls > * auditing The `enforce_permission` decorator must be applied at CLI command boundaries and/or service method boundaries to enforce access control in server mode. ## Code Location - **Decorator definition**: `src/cleveragents/application/services/permission_service.py` — `enforce_permission()` function - **Not applied anywhere**: No `@enforce_permission(...)` decorator usage found in the codebase - **Acknowledgment in docstring**: "Actual wiring of the decorator into CLI and service call sites is deferred to a future integration pass" ## Steps to Reproduce ```bash # Set server mode export CLEVERAGENTS_SERVER_MODE=1 # Even with a restricted role binding, all operations succeed # because enforce_permission is never applied agents plan list # Should check permission, but doesn't agents actor add ... # Should check permission, but doesn't ``` ## Subtasks - [ ] Identify all CLI commands that require permission checks in server mode - [ ] Apply `@enforce_permission(action=..., scope=...)` to relevant CLI commands - [ ] Apply `@enforce_permission(...)` to service methods that mutate shared state - [ ] Wire `PermissionService` into the DI container - [ ] Add BDD tests verifying permission enforcement in server mode - [ ] Add BDD tests verifying local mode bypasses permission checks ## Definition of Done - `@enforce_permission` is applied to all write operations in server mode - Unauthorized users receive `PermissionError` when attempting restricted operations - Local mode (default) continues to allow all operations without permission checks - All permission enforcement paths have BDD test coverage --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: Should Have

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: Should Have --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo added this to the v3.7.0 milestone 2026-04-05 05:07:05 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#2551
No description provided.