🇰🇷 한글 설명
Backstage 프레임워크의 @backstage/plugin-techdocs-node 패키지에서 발생하는 취약점으로, TechDocs를 로컬에서 실행할 때 mkdocs.yml 파일을 조작하여 임의의 파이썬 코드를 실행할 수 있는 취약점
💡 쉬운 설명
백스테이지 프레임워크의 특정 패키지에서 발생하는 취약점으로, 악의적인 사용자가 mkdocs.yml 파일을 수정하여 임의의 파이썬 코드를 실행할 수 있습니다. 이는 TechDocs를 로컬에서 실행할 때 발생하며, 패키지 업데이트나 설정 변경으로 조치할 수 있습니다.
🇺🇸 원문 (English)
Backstage is an open framework for building developer portals, and @backstage/plugin-techdocs-node provides common node.js functionalities for TechDocs. In versions of @backstage/plugin-techdocs-node prior to 1.13.11 and 1.14.1, when TechDocs is configured with `runIn: local`, a malicious actor who can submit or modify a repository's `mkdocs.yml` file can execute arbitrary Python code on the TechDocs build server via MkDocs hooks configuration. @backstage/plugin-techdocs-node versions 1.13.11 and 1.14.1 contain a fix. The fix introduces an allowlist of supported MkDocs configuration keys. Unsupported configuration keys (including `hooks`) are now removed from `mkdocs.yml` before running the generator, with a warning logged to indicate which keys were removed. Users of `@techdocs/cli` should also upgrade to the latest version, which includes the fixed `@backstage/plugin-techdocs-node` dependency. Some workarounds are available. Configure TechDocs with `runIn: docker` instead of `runIn: local` to provide container isolation, though it does not fully mitigate the risk. Limit who can modify `mkdocs.yml` files in repositories that TechDocs processes; only allow trusted contributors. Implement PR review requirements for changes to `mkdocs.yml` files to detect malicious `hooks` configurations before they are merged. Use MkDocs < 1.4.0 (e.g., 1.3.1) which does not support hooks. Note: This may limit access to newer MkDocs features. Building documentation in CI/CD pipelines using `@techdocs/cli` does not mitigate this vulnerability, as the CLI uses the same vulnerable `@backstage/plugin-techdocs-node` package.
📍 영향받는 시스템
@backstage/plugin-techdocs-node 버전 1.13.11 이전과 1.14.1 이전
⚔️ 공격 벡터
mkdocs.yml 파일을 수정하여 임의의 파이썬 코드를 실행
🛡️ 대응 방법
패키지 업데이트(@backstage/plugin-techdocs-node 버전 1.13.11 또는 1.14.1 이상), TechDocs를 도커 컨테이너에서 실행, mkdocs.yml 파일 수정 권한 제한, PR 리뷰 구현
🔧 검증 코드
로컬 시스템에서 npm 패키지 매니저를 사용하여 @backstage/plugin-techdocs-node 패키지의 버전을 확인합니다. 패키지 버전이 1.13.11 또는 1.14.1 이상이면 양호한 것으로 판단하고, 그렇지 않으면 취약한 것으로 판단합니다. 이 코드를 실행하기 위해서는 npm이 설치되어 있어야 합니다.
import subprocess
result = subprocess.run(['npm', 'ls', '@backstage/plugin-techdocs-node'], capture_output=True, text=True)
if '1.13.11' in result.stdout or '1.14.1' in result.stdout:
print({"result": "양호", "reason": "패키지 버전이 최신"})
else:
print({"result": "취약", "reason": "패키지 버전이 구버전"})