# Recursion Dos

> Detect stack overflow and infinite recursion DoS in recursive parsers, tree walkers, and serializers that lack depth limits.

- **Type:** Skill
- **Install:** `agentstack add skill-byamb4-find-cve-agent-recursion-dos`
- **Verified:** Pending review
- **Seller:** [ByamB4](https://agentstack.voostack.com/s/byamb4)
- **Installs:** 0
- **Category:** [Security](https://agentstack.voostack.com/c/security)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [ByamB4](https://github.com/ByamB4)
- **Source:** https://github.com/ByamB4/find-cve-agent/tree/main/skills/recursion-dos

## Install

```sh
agentstack add skill-byamb4-find-cve-agent-recursion-dos
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Recursion DoS Detection

## When to Use

Audit parsers, serializers, tree walkers, deep clone/merge functions, and any recursive function that processes user-controlled data structures with unbounded nesting depth.

## Key Distinction: OOM vs RangeError

| Crash Type | Severity | Catchable? | Process Dies? |
|------------|----------|------------|---------------|
| OOM (heap exhaustion) | HIGH 7.5 | NO | YES -- uncatchable, process killed |
| RangeError (stack overflow) | MEDIUM 5.3-6.5 | YES (try/catch) | Only if uncaught |

**OOM crash** = process dies regardless of error handling. This is HIGH severity.
**RangeError** = catchable in try/catch. Only HIGH if the library does NOT catch it.

## Process

### Step 1: Find Recursive Functions

```
grep -rn "function.*recurse\|function.*recursive\|function.*walk\|function.*traverse" .
grep -rn "function.*serialize\|function.*stringify\|function.*clone\|function.*deep" .
grep -rn "function.*parse\|function.*process\|function.*visit\|function.*transform" .
```

Look for functions that call themselves:
```
# Find function definitions and then check if they self-reference
grep -rn "function\s\+\w\+" . --include="*.js" | head -50
# Then for each function name, check if it calls itself
```

### Step 2: Check for Depth Limits

```
grep -rn "maxDepth\|max_depth\|depthLimit\|depth_limit\|MAX_DEPTH" .
grep -rn "depth\s*>\|depth\s*>=\|depth\s* parse(child)); // No depth limit
  }
  return node.value;
}
```

### Pattern 2: Recursive Serializer
```js
function serialize(obj) {
  if (typeof obj === 'object' && obj !== null) {
    return '{' + Object.keys(obj).map(k => k + ':' + serialize(obj[k])).join(',') + '}';
  }
  return String(obj);
}
```

### Pattern 3: Deep Clone Without Limit
```js
function deepClone(obj) {
  if (typeof obj !== 'object' || obj === null) return obj;
  const clone = Array.isArray(obj) ? [] : {};
  for (const key in obj) {
    clone[key] = deepClone(obj[key]); // Unbounded recursion
  }
  return clone;
}
```

### Pattern 4: Circular Reference (Infinite Loop)
Some recursive functions do not detect circular references:
```js
const a = {}; a.self = a;
deepClone(a); // Infinite recursion -> stack overflow
```

## CVSS Guidance

- OOM crash (process dies, unauthenticated): HIGH 7.5
- OOM crash (authenticated): MEDIUM 6.5
- RangeError (catchable but uncaught): HIGH 7.5
- RangeError (caught by library): LOW -- not a vulnerability
- Infinite loop (CPU DoS): MEDIUM 5.3

## References

- [Sinks](references/sinks.md) -- Recursive operation patterns
- [False Positive Indicators](references/false-positive-indicators.md)
- [PoC Skeleton](references/poc-skeleton.md)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [ByamB4](https://github.com/ByamB4)
- **Source:** [ByamB4/find-cve-agent](https://github.com/ByamB4/find-cve-agent)
- **License:** Apache-2.0

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** yes
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: flagged — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-byamb4-find-cve-agent-recursion-dos
- Seller: https://agentstack.voostack.com/s/byamb4
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
