🇰🇷 한글 설명
js-toml은 TOML 1.0.0 사양을 완전히 준수하는 JavaScript용 TOML 파서입니다. 1.1.1 이하 버전은 16진수/8진수/2진수 정수 리터럴을 파싱할 때 입력 자릿수마다 BigInt 누적값에 기수를 곱하는 직접 구현 루프를 사용하며, 리터럴 길이에 대해 O(n²) 복잡도를 가집니다. 길이 제한이 없어 약 500kB의 리터럴 하나로 CPU 코어가 약 40초간 점유될 수 있습니다. 1.1.2 버전에서 수정되었습니다.
💡 쉬운 설명
TOML 설정 파일 안에 아주 긴 숫자 값을 넣으면 프로그램이 그 숫자를 처리하느라 컴퓨터 CPU를 오랫동안 독점합니다. 공격자가 이런 파일을 업로드하면 서비스가 멈추거나 느려질 수 있습니다.
🇺🇸 원문 (English)
js-toml is a TOML parser for JavaScript, fully compliant with the TOML 1.0.0 Spec. Versions up to and including 1.1.1 parse hexadecimal / octal / binary integer literals via a hand-written `parseBigInt` loop that multiplies a `BigInt` accumulator by the radix once per input digit. Each iteration performs a `BigInt * BigInt` operation on an accumulator that grows linearly with the number of digits already consumed, so the whole loop is O(n²) in the literal length. The lexer regex places no upper bound on the literal length, so a single TOML document containing one ~500 kB hex literal pins one CPU core for ~40 seconds on a modern laptop (Apple M-series, Node v22). Memory amplification is bounded but CPU amplification is severe and grows quadratically: doubling the literal length quadruples the work. A caller that invokes `load()` on attacker-controlled TOML (configuration upload endpoints, CI/CD systems ingesting third-party `*.toml`, IDE plugins, build tools) is exposed to a single-request CPU exhaustion DoS. Version 1.1.2 fixes the issue.
📍 영향받는 시스템
js-toml 1.1.1 이하 버전을 사용하는 Node.js 등 JavaScript 애플리케이션 (설정 업로드 서비스, CI/CD, IDE 플러그인, 빌드 도구 등)
⚔️ 공격 벡터
공격자가 수백 킬로바이트 길이의 16진수/8진수/2진수 리터럴을 포함한 TOML 문서를 제공하고, 이를 load()로 파싱하도록 유도하여 단일 요청으로 CPU를 고갈시킵니다.
🛡️ 대응 방법
js-toml을 1.1.2 이상으로 업그레이드하고, 신뢰할 수 없는 TOML 입력에 대해 입력 길이 제한 및 요청 타임아웃을 적용합니다.
🔧 검증 코드
출력된 js-toml 버전이 1.1.2 미만이면 취약하며, 1.1.2 이상이면 패치된 상태입니다. 출력이 없으면 설치되지 않은 것입니다.
npm ls js-toml 2>/dev/null | grep js-toml