UAT: Config security scanner flags Jinja2 {{ template syntax as MEDIUM violation — false positive for spec-required actor YAML templating #2869

Open
opened 2026-04-04 21:13:02 +00:00 by freemo · 3 comments
Owner

Metadata

  • Branch: fix/config-security-scanner-jinja2-false-positive
  • Commit Message: fix(config): exclude Jinja2 template syntax from security scanner violations for actor YAML files
  • Milestone: v3.5.0
  • Parent Epic: (see orphan note below — no Configuration & Environment Epic found; requires manual linking)

Description

The configuration security scanner (src/cleveragents/config/security_scanner.py) registers {{ and {% as MEDIUM severity violations. However, the specification explicitly requires that actor YAML configuration files support Jinja2 preprocessing, which uses {{ and {% syntax. This creates false positives when validate_config_safety() is called on actor YAML files.

Expected behavior (from spec):

Actor configuration files support a two-phase loading process:

  1. Jinja2 Preprocessing: The file is first treated as a Jinja2 template, allowing for conditional blocks, loops, and variable injection (e.g., {{ context.value }}).
  2. Environment Variable Interpolation: After YAML parsing, string values are scanned for ${VAR} or ${VAR:default} patterns.

Actual behavior:

from cleveragents.config.security_scanner import scan_content, validate_config_safety

# A valid actor YAML file with Jinja2 templating
actor_yaml = '''
name: my-actor
model: {{ context.model }}
api_key: ${OPENAI_API_KEY}
'''

violations = scan_content(actor_yaml, 'actor.yaml')
# Returns 1 violation: Line 3: [MEDIUM] {{ — "Template directive may contain injected code"

# validate_config_safety() would raise ConfigurationError for valid actor YAML

Root cause:

# src/cleveragents/config/security_scanner.py
_register("{{", Severity.MEDIUM, "Template directive may contain injected code")
_register("{%", Severity.MEDIUM, "Template directive may contain injected code")

These patterns are registered as security violations, but they are the standard Jinja2 template syntax that the spec requires actor YAML files to support.

Impact: If validate_config_safety() is called on actor YAML files (as the SEC1 requirement implies), all actor YAML files using Jinja2 templating will be incorrectly rejected. This creates a conflict between SEC1 (config security scanning) and the actor YAML templating requirement.

Fix required: One of:

  1. Exclude actor YAML files from the {{ and {% pattern checks (since they are expected to contain Jinja2 templates), OR
  2. Change the severity to a lower level or add a whitelist for actor YAML file types, OR
  3. Document that validate_config_safety() should NOT be called on actor YAML files (only on global config files)

Code location: src/cleveragents/config/security_scanner.py_register("{{", ...) and _register("{%", ...) calls

Subtasks

  • Confirm which approach is correct per spec: file-type exclusion, severity downgrade, or documentation-only fix
  • Update security_scanner.py to implement the chosen fix (e.g., add file_type parameter or exclusion list for actor YAML)
  • Add/update Behave unit tests in features/ to cover the actor YAML false-positive scenario
  • Add/update Robot Framework integration tests in robot/ to verify validate_config_safety() does not reject valid actor YAML with Jinja2 syntax
  • Verify scan_content() still correctly flags {{ in non-actor config files (e.g., global config) if applicable
  • Run nox to confirm all quality gates pass

Definition of Done

  • scan_content(actor_yaml, 'actor.yaml') returns zero violations for valid Jinja2 template syntax ({{, {%)
  • validate_config_safety() does not raise ConfigurationError for actor YAML files containing spec-required Jinja2 templating
  • The fix does not regress security scanning for non-actor config files
  • All Behave unit tests pass (nox -e unit_tests)
  • All Robot Framework integration tests pass (nox -e integration_tests)
  • All nox stages pass
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/config-security-scanner-jinja2-false-positive` - **Commit Message**: `fix(config): exclude Jinja2 template syntax from security scanner violations for actor YAML files` - **Milestone**: v3.5.0 - **Parent Epic**: _(see orphan note below — no Configuration & Environment Epic found; requires manual linking)_ ## Description The configuration security scanner (`src/cleveragents/config/security_scanner.py`) registers `{{` and `{%` as MEDIUM severity violations. However, the specification explicitly requires that actor YAML configuration files support Jinja2 preprocessing, which uses `{{` and `{%` syntax. This creates false positives when `validate_config_safety()` is called on actor YAML files. **Expected behavior (from spec):** > Actor configuration files support a two-phase loading process: > 1. **Jinja2 Preprocessing**: The file is first treated as a Jinja2 template, allowing for conditional blocks, loops, and variable injection (e.g., `{{ context.value }}`). > 2. **Environment Variable Interpolation**: After YAML parsing, string values are scanned for `${VAR}` or `${VAR:default}` patterns. **Actual behavior:** ```python from cleveragents.config.security_scanner import scan_content, validate_config_safety # A valid actor YAML file with Jinja2 templating actor_yaml = ''' name: my-actor model: {{ context.model }} api_key: ${OPENAI_API_KEY} ''' violations = scan_content(actor_yaml, 'actor.yaml') # Returns 1 violation: Line 3: [MEDIUM] {{ — "Template directive may contain injected code" # validate_config_safety() would raise ConfigurationError for valid actor YAML ``` **Root cause:** ```python # src/cleveragents/config/security_scanner.py _register("{{", Severity.MEDIUM, "Template directive may contain injected code") _register("{%", Severity.MEDIUM, "Template directive may contain injected code") ``` These patterns are registered as security violations, but they are the standard Jinja2 template syntax that the spec requires actor YAML files to support. **Impact:** If `validate_config_safety()` is called on actor YAML files (as the SEC1 requirement implies), all actor YAML files using Jinja2 templating will be incorrectly rejected. This creates a conflict between SEC1 (config security scanning) and the actor YAML templating requirement. **Fix required:** One of: 1. Exclude actor YAML files from the `{{` and `{%` pattern checks (since they are expected to contain Jinja2 templates), OR 2. Change the severity to a lower level or add a whitelist for actor YAML file types, OR 3. Document that `validate_config_safety()` should NOT be called on actor YAML files (only on global config files) **Code location:** `src/cleveragents/config/security_scanner.py` — `_register("{{", ...)` and `_register("{%", ...)` calls ## Subtasks - [ ] Confirm which approach is correct per spec: file-type exclusion, severity downgrade, or documentation-only fix - [ ] Update `security_scanner.py` to implement the chosen fix (e.g., add `file_type` parameter or exclusion list for actor YAML) - [ ] Add/update Behave unit tests in `features/` to cover the actor YAML false-positive scenario - [ ] Add/update Robot Framework integration tests in `robot/` to verify `validate_config_safety()` does not reject valid actor YAML with Jinja2 syntax - [ ] Verify `scan_content()` still correctly flags `{{` in non-actor config files (e.g., global config) if applicable - [ ] Run `nox` to confirm all quality gates pass ## Definition of Done - [ ] `scan_content(actor_yaml, 'actor.yaml')` returns zero violations for valid Jinja2 template syntax (`{{`, `{%`) - [ ] `validate_config_safety()` does not raise `ConfigurationError` for actor YAML files containing spec-required Jinja2 templating - [ ] The fix does not regress security scanning for non-actor config files - [ ] All Behave unit tests pass (`nox -e unit_tests`) - [ ] All Robot Framework integration tests pass (`nox -e integration_tests`) - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.5.0 milestone 2026-04-04 21:13:08 +00:00
Author
Owner

⚠️ Orphan Issue — Manual Epic Linking Required

This issue was created by the automated UAT testing pipeline. A thorough search of all open and closed Type/Epic issues was performed, but no existing "Configuration & Environment" Epic was found in the cleveragents/cleveragents-core repository.

Per CONTRIBUTING.md, orphan issues are not permitted. A project owner must either:

  1. Link this issue to an existing Epic — if a Configuration & Environment or Config Security Epic exists that was not found (e.g., it may be a Type/Legendary or have a different title), please create the Forgejo dependency: this issue (#2869) blocks the parent Epic.
  2. Create a new "Configuration & Environment" Epic — if no such Epic exists, one should be created to group this and related config bugs (e.g., #2851, #2863, #2866, #2541) under a single parent.

Related config/settings issues that may belong to the same Epic:

  • #2851Settings.data_dir default is wrong
  • #2863configure_structlog() rejects TRACE log level
  • #2866Settings class missing server_url, server_token, format fields
  • #2541server.token config key missing from Settings
  • #2559 — Race condition in Settings singleton initialization

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

⚠️ **Orphan Issue — Manual Epic Linking Required** This issue was created by the automated UAT testing pipeline. A thorough search of all open and closed `Type/Epic` issues was performed, but **no existing "Configuration & Environment" Epic was found** in the `cleveragents/cleveragents-core` repository. Per `CONTRIBUTING.md`, orphan issues are not permitted. A project owner must either: 1. **Link this issue to an existing Epic** — if a Configuration & Environment or Config Security Epic exists that was not found (e.g., it may be a `Type/Legendary` or have a different title), please create the Forgejo dependency: this issue (#2869) **blocks** the parent Epic. 2. **Create a new "Configuration & Environment" Epic** — if no such Epic exists, one should be created to group this and related config bugs (e.g., #2851, #2863, #2866, #2541) under a single parent. **Related config/settings issues that may belong to the same Epic:** - #2851 — `Settings.data_dir` default is wrong - #2863 — `configure_structlog()` rejects `TRACE` log level - #2866 — `Settings` class missing `server_url`, `server_token`, `format` fields - #2541 — `server.token` config key missing from `Settings` - #2559 — Race condition in Settings singleton initialization --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — False positive in the security scanner for spec-required Jinja2 template syntax. The scanner flags {{ and {% as MEDIUM violations, but these are required by the spec for actor YAML preprocessing.
  • Milestone: v3.5.0 (already set correctly — this is an Autonomy Hardening milestone issue)
  • MoSCoW: Should Have — The spec requires Jinja2 preprocessing in actor YAML files. The security scanner should not flag spec-required syntax as violations. This creates a conflict between SEC1 (config security) and the actor YAML templating requirement that should be resolved.
  • Parent Epic: Orphan — no Configuration & Environment Epic exists. Linking to #362 (Epic: Security & Safety Hardening) as the closest match, since this is a security scanner behavior issue.

Note: The orphan status was flagged by the UAT bot. I am linking this to Epic #362 (Security & Safety Hardening) as the security scanner is within that epic's scope.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — False positive in the security scanner for spec-required Jinja2 template syntax. The scanner flags `{{` and `{%` as MEDIUM violations, but these are required by the spec for actor YAML preprocessing. - **Milestone**: v3.5.0 (already set correctly — this is an Autonomy Hardening milestone issue) - **MoSCoW**: Should Have — The spec requires Jinja2 preprocessing in actor YAML files. The security scanner should not flag spec-required syntax as violations. This creates a conflict between SEC1 (config security) and the actor YAML templating requirement that should be resolved. - **Parent Epic**: Orphan — no Configuration & Environment Epic exists. Linking to #362 (Epic: Security & Safety Hardening) as the closest match, since this is a security scanner behavior issue. Note: The orphan status was flagged by the UAT bot. I am linking this to Epic #362 (Security & Safety Hardening) as the security scanner is within that epic's scope. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

This issue has been moved to the backlog as part of an aggressive grooming of the v3.5.0 milestone. It has been deemed non-critical for the minimal viability of the milestone and will be addressed in a future release.

This issue has been moved to the backlog as part of an aggressive grooming of the v3.5.0 milestone. It has been deemed non-critical for the minimal viability of the milestone and will be addressed in a future release.
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#2869
No description provided.