본문으로 건너뛰기
cccskills
무료GitHub에 공개

recursion-dos

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

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(4)

  • SKILL.md3.9 KB
  • references/false-positive-indicators.md1.1 KB
  • references/poc-skeleton.md2.1 KB
  • references/sinks.md1.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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 TypeSeverityCatchable?Process Dies?
OOM (heap exhaustion)HIGH 7.5NOYES -- uncatchable, process killed
RangeError (stack overflow)MEDIUM 5.3-6.5YES (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*<\|depth\s*<=" .
grep -rn "recursion.*limit\|stack.*limit\|nesting.*limit" .

Step 3: Test with Nested Input

Create deeply nested input matching the data format:

// JSON-like nesting
let nested = "x";
for (let i = 0; i < 100000; i++) {
  nested = { a: nested };
}

// String-based nesting
let nested = "a";
for (let i = 0; i < 100000; i++) {
  nested = "[" + nested + "]";
}

Step 4: Measure Stack Consumption

// Run in subprocess to avoid crashing main process
const { execSync } = require('child_process');
try {
  execSync('node -e "const pkg = require('./'); pkg.parse(payload)"', {
    timeout: 10000,
    maxBuffer: 1024
  });
} catch (e) {
  if (e.status === null) {
    console.log('[+] OOM: process killed (HIGH severity)');
  } else {
    console.log('[!] RangeError: catchable (MEDIUM severity)');
  }
}

Common Vulnerable Patterns

Pattern 1: Recursive Parser Without Depth Limit

function parse(node) {
  if (node.children) {
    return node.children.map(child => parse(child)); // No depth limit
  }
  return node.value;
}

Pattern 2: Recursive Serializer

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

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:

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

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

You are helping a penetration tester exploit misconfigured Active Directory

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ajtazer/heckit22026년 10월 7일 업데이트

You are helping a penetration tester enumerate an Active Directory domain and

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ajtazer/heckit22026년 10월 7일 업데이트

You are helping a penetration tester establish persistent access in Active

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ajtazer/heckit22026년 10월 7일 업데이트

You are helping a penetration tester exploit ADCS through template/CA access

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ajtazer/heckit22026년 10월 7일 업데이트

You are helping a penetration tester establish persistence through AD CS

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ajtazer/heckit22026년 10월 7일 업데이트

You are helping a penetration tester exploit misconfigured AD CS certificate

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ajtazer/heckit22026년 10월 7일 업데이트

ajtazer의 스킬 모두 보기

이 스킬의 문제 신고