🔍 CVE-2026-33940

8.1
CVSS Score
HIGH
2026-03-27
2026-10-26 22:10
✅ 완료

🇰🇷 한글 설명

Handlebars는 사용자가 의미론적 템플릿을 구성할 수 있도록 하는 라이브러리입니다. 4.0.0부터 4.7.8 버전에서는 템플릿 컨텍스트에 조작된 객체를 넣으면 resolvePartial()의 조건 검사를 우회하여 invokePartial()이 undefined를 반환하게 되며, 이때 해당 객체가 env.compile()로 전달되어 서버에서 임의의 명령이 실행될 수 있습니다. 버전 4.7.9에서 수정되었습니다.

💡 쉬운 설명

템플릿 엔진이 특정 조작된 데이터를 잘못 처리해서 공격자가 서버에서 원하는 명령을 실행할 수 있는 취약점입니다. 동적 partial 조회에 사용자 입력이 섞일 때 위험합니다.

🇺🇸 원문 (English)

Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, a crafted object placed in the template context can bypass all conditional guards in `resolvePartial()` and cause `invokePartial()` to return `undefined`. The Handlebars runtime then treats the unresolved partial as a source that needs to be compiled, passing the crafted object to `env.compile()`. Because the object is a valid Handlebars AST containing injected code, the generated JavaScript executes arbitrary commands on the server. The attack requires the adversary to control a value that can be returned by a dynamic partial lookup. Version 4.7.9 fixes the issue. Some workarounds are available. First, use the runtime-only build (`require('handlebars/runtime')`). Without `compile()`, the fallback compilation path in `invokePartial` is unreachable. Second, sanitize context data before rendering: Ensure no value in the context is a non-primitive object that could be passed to a dynamic partial. Third, avoid dynamic partial lookups (`{{> (lookup ...)}}`) when context data is user-controlled.

📍 영향받는 시스템

Handlebars 4.0.0 ~ 4.7.8 버전을 사용하는 Node.js 애플리케이션 (수정 버전: 4.7.9 이상)

⚔️ 공격 벡터

공격자가 동적 partial 조회로 반환될 수 있는 값을 제어하여 조작된 객체를 템플릿 컨텍스트에 주입, 서버에서 임의 코드 실행

🛡️ 대응 방법

Handlebars를 4.7.9 이상으로 업데이트하거나, runtime-only 빌드(require('handlebars/runtime'))를 사용하고, 사용자 입력 기반 동적 partial 조회를 피합니다.

🔧 검증 코드

출력된 버전이 4.0.0~4.7.8 범위에 해당하면 취약하며, 4.7.9 이상이면 수정된 것입니다. 출력이 없으면 프로젝트에 설치되어 있지 않습니다.

Shell / Script
npm ls handlebars 2>/dev/null | grep handlebars

📊 CVSS Vector String

CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

💻 영향받는 소프트웨어

Oracle Java SE