TDD: BUG-HUNT: [security] Template rendering resource exhaustion vulnerability allows denial of service #7173

Open
opened 2026-04-10 08:29:07 +00:00 by HAL9000 · 1 comment
Owner

Background and Context

This is the TDD issue for bug #7172. Its sole deliverable is a set of BDD scenarios tagged @tdd_issue, @tdd_issue_7172, and @tdd_expected_fail that demonstrate the resource exhaustion vulnerabilities in YAMLTemplateEngine (src/cleveragents/actor/yaml_template_engine.py).

The @tdd_expected_fail tag inverts the test result so that CI passes while the bug is unfixed. The bug fix developer must remove @tdd_expected_fail (leaving @tdd_issue and @tdd_issue_7172 permanently) when implementing the fix in #7172.

Current Behavior

See #7172 for full vulnerability details. In summary:

  • _render_and_parse() has no timeout or memory limits on template rendering
  • _fix_common_yaml_issues() has O(n²) worst-case string processing
  • _preprocess_for_rendering() has no input size limits

Expected Behavior (Test Deliverable)

Three BDD scenarios must be written and tagged appropriately:

  1. Memory exhaustion scenario: A template expression that creates a large in-memory list (e.g., {{ range(10000000) | list | length }}) must raise a TemplateMemoryLimitError or equivalent within the configured memory limit.
  2. CPU/timeout exhaustion scenario: A template with deeply nested loops must raise a TemplateRenderTimeoutError or equivalent within the configured timeout.
  3. Pathological input scenario: Input with extremely long lines or excessive line count must raise an InputSizeLimitError or equivalent before rendering begins.

All scenarios must be tagged @tdd_issue, @tdd_issue_7172, and @tdd_expected_fail.

Metadata

  • Branch: tdd/m3.5.0-security-yaml-template-resource-exhaustion-dos
  • Commit Message: test(actor): add @tdd_expected_fail scenarios for YAMLTemplateEngine resource exhaustion DoS
  • Milestone: v3.5.0
  • Parent Epic: #5502

Subtasks

  • Write BDD scenario for memory exhaustion attack vector (tagged @tdd_issue @tdd_issue_7172 @tdd_expected_fail)
  • Write BDD scenario for CPU/timeout exhaustion attack vector (tagged @tdd_issue @tdd_issue_7172 @tdd_expected_fail)
  • Write BDD scenario for pathological input size attack vector (tagged @tdd_issue @tdd_issue_7172 @tdd_expected_fail)
  • Verify all scenarios pass CI with @tdd_expected_fail (i.e., assertions fail as expected while bug is unfixed)
  • Open PR from tdd/m3.5.0-security-yaml-template-resource-exhaustion-dos to master

Definition of Done

  • Three BDD scenarios exist in features/ covering all three attack vectors
  • All scenarios carry @tdd_issue, @tdd_issue_7172, and @tdd_expected_fail tags
  • CI passes with @tdd_expected_fail active (assertions fail = bug confirmed present)
  • PR merged to master
  • This TDD issue is closed
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: new-issue-creator

## Background and Context This is the TDD issue for bug #7172. Its sole deliverable is a set of BDD scenarios tagged `@tdd_issue`, `@tdd_issue_7172`, and `@tdd_expected_fail` that demonstrate the resource exhaustion vulnerabilities in `YAMLTemplateEngine` (`src/cleveragents/actor/yaml_template_engine.py`). The `@tdd_expected_fail` tag inverts the test result so that CI passes while the bug is unfixed. The bug fix developer must remove `@tdd_expected_fail` (leaving `@tdd_issue` and `@tdd_issue_7172` permanently) when implementing the fix in #7172. ## Current Behavior See #7172 for full vulnerability details. In summary: - `_render_and_parse()` has no timeout or memory limits on template rendering - `_fix_common_yaml_issues()` has O(n²) worst-case string processing - `_preprocess_for_rendering()` has no input size limits ## Expected Behavior (Test Deliverable) Three BDD scenarios must be written and tagged appropriately: 1. **Memory exhaustion scenario**: A template expression that creates a large in-memory list (e.g., `{{ range(10000000) | list | length }}`) must raise a `TemplateMemoryLimitError` or equivalent within the configured memory limit. 2. **CPU/timeout exhaustion scenario**: A template with deeply nested loops must raise a `TemplateRenderTimeoutError` or equivalent within the configured timeout. 3. **Pathological input scenario**: Input with extremely long lines or excessive line count must raise an `InputSizeLimitError` or equivalent before rendering begins. All scenarios must be tagged `@tdd_issue`, `@tdd_issue_7172`, and `@tdd_expected_fail`. ## Metadata - **Branch**: `tdd/m3.5.0-security-yaml-template-resource-exhaustion-dos` - **Commit Message**: `test(actor): add @tdd_expected_fail scenarios for YAMLTemplateEngine resource exhaustion DoS` - **Milestone**: v3.5.0 - **Parent Epic**: #5502 ## Subtasks - [ ] Write BDD scenario for memory exhaustion attack vector (tagged `@tdd_issue @tdd_issue_7172 @tdd_expected_fail`) - [ ] Write BDD scenario for CPU/timeout exhaustion attack vector (tagged `@tdd_issue @tdd_issue_7172 @tdd_expected_fail`) - [ ] Write BDD scenario for pathological input size attack vector (tagged `@tdd_issue @tdd_issue_7172 @tdd_expected_fail`) - [ ] Verify all scenarios pass CI with `@tdd_expected_fail` (i.e., assertions fail as expected while bug is unfixed) - [ ] Open PR from `tdd/m3.5.0-security-yaml-template-resource-exhaustion-dos` to `master` ## Definition of Done - [ ] Three BDD scenarios exist in `features/` covering all three attack vectors - [ ] All scenarios carry `@tdd_issue`, `@tdd_issue_7172`, and `@tdd_expected_fail` tags - [ ] CI passes with `@tdd_expected_fail` active (assertions fail = bug confirmed present) - [ ] PR merged to `master` - [ ] This TDD issue is closed - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-10 08:29:11 +00:00
Author
Owner

Verified — TDD test for critical security bug: template rendering resource exhaustion DoS. MoSCoW: Must-have. Priority: Critical.


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

✅ **Verified** — TDD test for critical security bug: template rendering resource exhaustion DoS. MoSCoW: Must-have. Priority: Critical. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

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