🇰🇷 한글 설명
Handlebars 4.0.0부터 4.7.8 버전의 CLI 프리컴파일러에서 사용자 제어 문자열이 적절한 이스케이프 처리 없이 JavaScript에 직접 결합되는 취약점이 발견되었습니다. 공격자가 템플릿 파일 이름이나 CLI 옵션을 조작할 경우, 생성된 번들이 로드될 때 임의의 JavaScript 코드가 실행될 수 있습니다.
💡 쉬운 설명
프로그램이 템플릿을 만드는 과정에서 사용자가 입력한 이름을 검사하지 않고 그대로 코드에 넣어버리는 문제입니다. 이를 통해 해커가 악성 코드를 몰래 끼워 넣어 컴퓨터에서 실행하게 만들 수 있습니다.
🇺🇸 원문 (English)
Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, the Handlebars CLI precompiler (`bin/handlebars` / `lib/precompiler.js`) concatenates user-controlled strings — template file names and several CLI options — directly into the JavaScript it emits, without any escaping or sanitization. An attacker who can influence template filenames or CLI arguments can inject arbitrary JavaScript that executes when the generated bundle is loaded in Node.js or a browser. Version 4.7.9 fixes the issue. Some workarounds are available. First, validate all CLI inputs before invoking the precompiler. Reject filenames and option values that contain characters with JavaScript string-escaping significance (`"`, `'`, `;`, etc.). Second, use a fixed, trusted namespace string passed via a configuration file rather than command-line arguments in automated pipelines. Third, run the precompiler in a sandboxed environment (container with no write access to sensitive paths) to limit the impact of successful exploitation. Fourth, audit template filenames in any repository or package that is consumed by an automated build pipeline.
📍 영향받는 시스템
Handlebars versions 4.0.0 through 4.7.8
⚔️ 공격 벡터
조작된 템플릿 파일 이름 또는 CLI 옵션 인젝션을 통한 임의 JavaScript 코드 실행
🛡️ 대응 방법
Handlebars를 4.7.9 버전 이상으로 업데이트하거나, CLI 입력값에 대한 엄격한 검증 및 샌드박스 환경 사용
🔧 검증 코드
명령어 결과에 4.0.0에서 4.7.8 사이의 버전이 나타나면 취약한 버전이 설치된 상태입니다.
npm list handlebars | grep -E 'handlebars@4\.[0-4]\.'