Skip to content

Recursive confirm fallbacks in YAML cause unbounded stack overflow #7

Description

@nimser

What happened?

src/infrastructure/yaml-pack-loader.ts:209-214 accepts any BeforeToolAction (including another confirm) as a fallback. The validator accepts it, the types allow it (src/core/types.ts:19), and the resolver recurses on the fallback (src/resolver/action-resolver.ts:144).

A YAML rule like the following, evaluated with capabilities.confirm: false, will infinite-recurse and stack-overflow:

defaultAction:
  type: confirm
  fallback:
    type: confirm
    fallback:
      type: confirm
      fallback:
        type: confirm
        # ... ad infinitum

There is no depth limit in the loader, validator, or resolver.

What did you expect to happen?

The loader or resolver should reject (or break out of) recursive fallback chains beyond a reasonable depth (e.g. 5), or at minimum not stack-overflow on a malformed/unbounded chain.

Steps to reproduce

  1. Create a YAML rule pack with a confirm action whose fallback is itself a confirm with another confirm fallback (≥ a few levels deep)
  2. Load it with loadYamlRulePack
  3. Evaluate with capabilities.confirm: false
  4. Observe RangeError: Maximum call stack size exceeded in resolveAction

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions