UAT: validate_config_safety() never called when loading actor, skill, action, or resource YAML — malicious configs bypass security scan #3649

Open
opened 2026-04-05 21:05:23 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/v3.6.0/validate-config-safety-yaml-loaders
  • Commit Message: fix(security): call validate_config_safety() in all YAML loaders before yaml.safe_load()
  • Milestone: v3.6.0
  • Parent Epic: #362

Background

The validate_config_safety() function in src/cleveragents/config/security_scanner.py is designed to scan YAML content for dangerous patterns (eval, exec, subprocess calls, etc.) before it is processed. However, a codebase-wide search reveals that validate_config_safety() is never called when loading actor, skill, action, or resource type YAML definitions.

Actor and skill YAML definitions are user-supplied inputs. Per the specification's security model and CONTRIBUTING.md ("All inputs must be sanitized"), every YAML file must be scanned before it is parsed and executed. The current gap means a user could register an actor with a YAML config containing eval(os.environ['SECRET']) in a string field and the scanner would never flag it.

Affected Files

The following loaders call yaml.safe_load directly without first invoking validate_config_safety():

  1. Actor loadersrc/cleveragents/actor/loader.py, line 128
  2. Actor configsrc/cleveragents/actor/config.py, line 116
  3. Actor schemasrc/cleveragents/actor/schema.py, line 883
  4. Skills schemasrc/cleveragents/skills/schema.py, line 411
  5. Skills discoverysrc/cleveragents/skills/discovery.py, line 111
  6. Action schemasrc/cleveragents/action/schema.py, line 369
  7. Resource schemasrc/cleveragents/resource/schema.py, line 368

Steps to Reproduce

  1. Create an actor YAML config containing description: "eval(os.system('id'))"
  2. Run agents actor add --config malicious.yaml
  3. Observe: the actor is registered without any security warning or rejection

Expected Behaviour

validate_config_safety() is called before yaml.safe_load() in every YAML loader. If dangerous patterns are detected, a ConfigurationError is raised and the registration is rejected immediately.

Actual Behaviour

validate_config_safety() is defined and exported from src/cleveragents/config/security_scanner.py but has zero call sites in production code. All YAML loaders bypass the security scan entirely.

Subtasks

  • Add validate_config_safety() pre-scan call in src/cleveragents/actor/loader.py before yaml.safe_load() (line 128)
  • Add validate_config_safety() pre-scan call in src/cleveragents/actor/config.py before yaml.safe_load() (line 116)
  • Add validate_config_safety() pre-scan call in src/cleveragents/actor/schema.py before yaml.safe_load() (line 883)
  • Add validate_config_safety() pre-scan call in src/cleveragents/skills/schema.py before yaml.safe_load() (line 411)
  • Add validate_config_safety() pre-scan call in src/cleveragents/skills/discovery.py before yaml.safe_load() (line 111)
  • Add validate_config_safety() pre-scan call in src/cleveragents/action/schema.py before yaml.safe_load() (line 369)
  • Add validate_config_safety() pre-scan call in src/cleveragents/resource/schema.py before yaml.safe_load() (line 368)
  • Raise ConfigurationError (not a generic exception) when validate_config_safety() detects dangerous patterns
  • Write Behave BDD unit test scenarios verifying that YAML containing eval, exec, and subprocess patterns is rejected at load time for each affected loader
  • Confirm that the --unsafe flag on agents actor add does NOT bypass the security scan (unsafe controls sandboxing only, not injection scanning)
  • Ensure all type annotations are correct and Pyright passes (nox -e typecheck)
  • Run full nox suite and confirm all stages pass

Definition of Done

  • validate_config_safety() is called before yaml.safe_load() in all seven affected YAML loaders listed above
  • A ConfigurationError is raised and registration is rejected when dangerous patterns are found in any YAML input
  • Behave BDD unit test scenarios cover malicious YAML rejection for actor, skill, action, and resource loaders
  • The --unsafe flag does NOT bypass the security scan — confirmed by a dedicated test scenario
  • All nox stages pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests)
  • Coverage >= 97%

Note: This is a Priority/Critical bug. validate_config_safety() exists precisely to prevent YAML injection attacks on user-supplied configs. Its absence from all production call sites is a complete security control bypass. This issue was found during UAT and is assigned to v3.6.0 (the active security milestone) because v3.3.0 — where Epic #362 lives — is converging (closed issues outnumber open issues) and cannot accept new work per the Milestone Scope Guard.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/v3.6.0/validate-config-safety-yaml-loaders` - **Commit Message**: `fix(security): call validate_config_safety() in all YAML loaders before yaml.safe_load()` - **Milestone**: v3.6.0 - **Parent Epic**: #362 ## Background The `validate_config_safety()` function in `src/cleveragents/config/security_scanner.py` is designed to scan YAML content for dangerous patterns (`eval`, `exec`, `subprocess` calls, etc.) before it is processed. However, a codebase-wide search reveals that `validate_config_safety()` is **never called** when loading actor, skill, action, or resource type YAML definitions. Actor and skill YAML definitions are user-supplied inputs. Per the specification's security model and CONTRIBUTING.md ("All inputs must be sanitized"), every YAML file must be scanned before it is parsed and executed. The current gap means a user could register an actor with a YAML config containing `eval(os.environ['SECRET'])` in a string field and the scanner would never flag it. ## Affected Files The following loaders call `yaml.safe_load` directly without first invoking `validate_config_safety()`: 1. **Actor loader** — `src/cleveragents/actor/loader.py`, line 128 2. **Actor config** — `src/cleveragents/actor/config.py`, line 116 3. **Actor schema** — `src/cleveragents/actor/schema.py`, line 883 4. **Skills schema** — `src/cleveragents/skills/schema.py`, line 411 5. **Skills discovery** — `src/cleveragents/skills/discovery.py`, line 111 6. **Action schema** — `src/cleveragents/action/schema.py`, line 369 7. **Resource schema** — `src/cleveragents/resource/schema.py`, line 368 ## Steps to Reproduce 1. Create an actor YAML config containing `description: "eval(os.system('id'))"` 2. Run `agents actor add --config malicious.yaml` 3. Observe: the actor is registered without any security warning or rejection ## Expected Behaviour `validate_config_safety()` is called before `yaml.safe_load()` in every YAML loader. If dangerous patterns are detected, a `ConfigurationError` is raised and the registration is rejected immediately. ## Actual Behaviour `validate_config_safety()` is defined and exported from `src/cleveragents/config/security_scanner.py` but has **zero call sites** in production code. All YAML loaders bypass the security scan entirely. ## Subtasks - [ ] Add `validate_config_safety()` pre-scan call in `src/cleveragents/actor/loader.py` before `yaml.safe_load()` (line 128) - [ ] Add `validate_config_safety()` pre-scan call in `src/cleveragents/actor/config.py` before `yaml.safe_load()` (line 116) - [ ] Add `validate_config_safety()` pre-scan call in `src/cleveragents/actor/schema.py` before `yaml.safe_load()` (line 883) - [ ] Add `validate_config_safety()` pre-scan call in `src/cleveragents/skills/schema.py` before `yaml.safe_load()` (line 411) - [ ] Add `validate_config_safety()` pre-scan call in `src/cleveragents/skills/discovery.py` before `yaml.safe_load()` (line 111) - [ ] Add `validate_config_safety()` pre-scan call in `src/cleveragents/action/schema.py` before `yaml.safe_load()` (line 369) - [ ] Add `validate_config_safety()` pre-scan call in `src/cleveragents/resource/schema.py` before `yaml.safe_load()` (line 368) - [ ] Raise `ConfigurationError` (not a generic exception) when `validate_config_safety()` detects dangerous patterns - [ ] Write Behave BDD unit test scenarios verifying that YAML containing `eval`, `exec`, and `subprocess` patterns is rejected at load time for each affected loader - [ ] Confirm that the `--unsafe` flag on `agents actor add` does NOT bypass the security scan (unsafe controls sandboxing only, not injection scanning) - [ ] Ensure all type annotations are correct and Pyright passes (`nox -e typecheck`) - [ ] Run full nox suite and confirm all stages pass ## Definition of Done - [ ] `validate_config_safety()` is called before `yaml.safe_load()` in all seven affected YAML loaders listed above - [ ] A `ConfigurationError` is raised and registration is rejected when dangerous patterns are found in any YAML input - [ ] Behave BDD unit test scenarios cover malicious YAML rejection for actor, skill, action, and resource loaders - [ ] The `--unsafe` flag does NOT bypass the security scan — confirmed by a dedicated test scenario - [ ] All nox stages pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`) - [ ] Coverage >= 97% > **Note:** This is a `Priority/Critical` bug. `validate_config_safety()` exists precisely to prevent YAML injection attacks on user-supplied configs. Its absence from all production call sites is a complete security control bypass. This issue was found during UAT and is assigned to v3.6.0 (the active security milestone) because v3.3.0 — where Epic #362 lives — is converging (closed issues outnumber open issues) and cannot accept new work per the Milestone Scope Guard. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.6.0 milestone 2026-04-05 21:05:27 +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.

Blocks
#362 Epic: Security & Safety Hardening
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3649
No description provided.