VibeGuard: AI 생성 코드를 위한 보안 게이트 프레임워크 — Claude Code 소스 유출 사건에서 배운 것
VibeGuard: A Security Gate Framework for AI-Generated Code
TL;DR Highlight
AI가 짠 코드를 검토 없이 배포하는 'Vibe Coding' 환경에서, 패키징 설정 실수로 소스 코드가 통째로 유출되는 걸 막아주는 pre-publish 보안 스캐너.
Who Should Read
AI 코딩 도구(Claude Code, GitHub Copilot 등)로 생성된 코드를 프로덕션에 배포하는 개발자. 특히 npm/pip 패키지를 퍼블리시하거나 CI/CD 파이프라인에 보안 게이트를 추가하려는 DevSecOps 담당자.
Core Mechanics
- 2026년 3월 31일, Anthropic의 Claude Code npm 패키지에 59.8MB짜리 source map 파일이 포함돼 TypeScript 소스코드 약 51만 2천 줄이 통째로 유출됐음. 원인은 코드 버그가 아니라 .npmignore 설정 누락이었음.
- AI가 생성한 코드는 인간이 작성한 코드보다 보안 이슈가 1.7배 많고, XSS 같은 특정 취약점은 2.74배까지 올라감(CodeRabbit 2025). 하지만 기존 연구는 대부분 로직 버그에 집중하고, 패키징/빌드 설정 실수는 거의 다루지 않았음.
- VibeGuard는 기존 SAST(정적 코드 분석 도구), secret 스캐너, 의존성 감사 도구가 모두 놓치는 5가지 취약점 카테고리를 커버함: 아티팩트 위생, 패키징 설정 드리프트, source map 노출, 하드코딩된 시크릿, 공급망 위험.
- 툴이 publish 시점에 동작하는 게 핵심 설계 결정임. Claude Code 유출은 소스 map이 합법적인 빌드 결과물이었기 때문에 pre-commit 훅으론 막을 수 없었음.
- AI 코드 생성기는 '무언가를 추가하는 것'(빌드 스텝 추가, 의존성 추가)에는 최적화돼 있지만, '무언가를 제외하는 것'(.npmignore에 파일 추가 등)에는 취약함. 패키징 보안은 본질적으로 '제외'에 관한 것.
- AI 코딩 어시스턴트에 VibeGuard를 툴로 등록하면, AI가 publish 명령을 제안하기 전에 자동으로 스캔을 돌릴 수 있음. 개발자가 코드를 직접 읽지 않아도 되는 Vibe Coding 워크플로우에 맞는 방어 방식.
Evidence
- 8개 합성 프로젝트(취약 7개 + 정상 1개)에서 Recall 100%, Precision 89.47%, F1 Score 94.44% 달성. 모든 프로젝트에서 pass/fail 게이트 판단 정확도 100%.
- False Negative 0개: 심어놓은 취약점을 하나도 빠뜨리지 않았음. False Positive 2개는 config 스캐너가 .npmignore 누락을 과하게 잡은 것으로, 보안 게이트 맥락에서 허용 가능한 트레이드오프.
- Source Map, Artifact, Secret, Dependency 4개 카테고리는 Precision 100% + Recall 100% 달성. Config 카테고리만 Precision 71.4%(의도적으로 넓은 scope 때문).
- Veracode 보고서에 따르면 LLM이 생성한 코드의 45%가 보안 결함을 포함(80개 벤치마크 태스크 기준). GitHub Copilot은 보안 민감 시나리오의 약 40%에서 취약한 코드를 생성(Pearce et al., IEEE S&P 2022).
How to Apply
- npm 패키지를 퍼블리시하는 프로젝트라면 package.json의 scripts에 `"prepublishOnly": "vibeguard scan"` 한 줄 추가하면 됨. 이렇게 하면 `npm publish` 실행 시 자동으로 보안 게이트가 동작해서 취약점이 있으면 퍼블리시 자체가 막힘.
- CI/CD 파이프라인(GitHub Actions 등)에 VibeGuard를 필수 체크로 추가하면 됨. 특히 merge 전에 실행되도록 설정하면, 개발자가 직접 코드를 리뷰하지 않아도 패키징 설정 실수를 자동으로 차단할 수 있음.
- Claude Code, Cursor 같은 AI 코딩 어시스턴트에 VibeGuard를 MCP 툴로 등록하면, AI가 배포 명령을 내리기 전에 자동으로 스캔을 실행하게 만들 수 있음. Vibe Coding 루프 안에서 보안 검사를 닫아주는 방식.
Code Example
# VibeGuard 설치 및 기본 사용
pip install vibeguard # 또는 GitHub에서 직접 설치
# 프로젝트 스캔 (default 정책)
vibeguard scan ./my-project
# strict 정책으로 스캔 (info 이상 모든 findings에서 차단)
vibeguard scan ./my-project --policy strict
# package.json에 prepublishOnly 훅 추가
# package.json
{
"scripts": {
"prepublishOnly": "vibeguard scan ."
}
}
# .npmignore 체크 예시 - VibeGuard가 감지하는 패턴
# 아래가 없으면 ConfigScanner가 CRITICAL로 플래그
# *.map <- source map 제외
# .env* <- 환경변수 파일 제외
# tsconfig.json <- 빌드 설정 제외
# **/*.d.ts.map <- 타입 정의 source map 제외Terminology
Related Resources
- https://github.com/yxie2/vibeguard
- https://x.com/karpathy/status/1886192184808149383
- https://vibe-radar-ten.vercel.app/
- https://github.com/oven-sh/bun/issues/28001
- https://alex000kim.com/posts/2026-03-31-claude-code-source-leak/
- https://www.coderabbit.ai/blog/state-of-ai-vs-human-code-generation-report
- https://www.veracode.com/resources/analyst-reports/2025-genai-code-security-report/
Original Abstract (Expand)
"Vibe coding," in which developers delegate code generation to AI assistants and accept the output with little manual review, has gained rapid adoption in production settings. On March 31, 2026, Anthropic's Claude Code CLI shipped a 59.8 MB source map file in its npm package, exposing roughly 512,000 lines of proprietary TypeScript. The tool had itself been largely vibe-coded, and the leak traced to a misconfigured packaging rule rather than a logic bug. Existing static-analysis and secret-scanning tools did not cover this failure mode, pointing to a gap between the vulnerabilities AI tends to introduce and the vulnerabilities current tooling is built to find. We present VibeGuard, a pre-publish security gate that targets five such blind spots: artifact hygiene, packaging-configuration drift, source-map exposure, hardcoded secrets, and supply-chain risk. In controlled experiments on eight synthetic projects (seven vulnerable, one clean control), VibeGuard achieved 100% recall, 89.47% precision (F1 = 94.44%), and correct pass/fail gate decisions on all eight projects across three policy levels. We discuss how these results inform a defense-in-depth workflow for teams that rely on AI code generation.