블로그로 돌아가기기술

LangChain CVE-2025-68664: RAG 파이프라인을 통한 개인정보 유출 경로

CVSS 9.3. LangChain의 직렬화 함수가 환경 변수와 비밀 정보를 공격자가 제어하는 LLM에 노출합니다. 개인정보 유출을 탐지하고 수정하는 방법을 설명합니다.

March 16, 20268 분 읽기
LangChainRAG pipelineCVEPII leakagedeveloper securityAPI keysLLM security

LangChain CVE-2025-68664: RAG 파이프라인을 통한 개인정보 유출 경로

2026년 기준 최신화.

2025년 말, LangChain에서 심각한 취약점이 발견됐습니다. CVE 번호는 CVE-2025-68664이며 CVSS 점수는 **9.3 (Critical)**입니다.

이 취약점은 LangChain의 직렬화 코드를 표적으로 합니다.

CVE-2025-68664의 작동 방식

LangChain에는 두 가지 직렬화 함수가 있습니다. dumps()dumpd()입니다. 이 함수들은 Python 객체를 텍스트로 변환합니다.

취약점은 클로저 처리에 있습니다.

LangChain이 콜러블을 직렬화할 때 클로저 컨텍스트를 캡처합니다.

LLM 응답을 제어하는 공격자는 dumps()를 트리거할 수 있습니다. 그러면 함수가 Python 프로세스에서 환경 변수를 읽습니다.

결과는 데이터 노출입니다. API 키, 데이터베이스 연결 문자열, JWT 비밀, AWS 자격 증명이 모델 출력에 나타날 수 있습니다.

RAG 소스 문서에 텍스트를 주입하는 공격자는 프로덕션 비밀 정보를 읽을 수 있습니다.

영향받는 버전: LangChain Python 0.3.22 미만. 버전 0.3.22에 수정사항이 포함됐습니다.

PyPI 데이터에 따르면 2026년 3월까지 이전 버전의 사용이 광범위하게 나타납니다.

RAG 파이프라인에서 개인정보가 유출되는 방식

CVE-2025-68664는 극적이지만, 더 광범위한 문제의 단 하나의 사례에 불과합니다.

RAG 파이프라인을 통한 데이터 유출은 일상적으로 발생합니다. 공격자가 필요하지 않습니다.

일반적인 기업 RAG 설정을 살펴보겠습니다.

첫째, 인덱싱. 회사 문서를 벡터 저장소에 인덱싱합니다. 지원 티켓, 고객 이메일, 계약서, HR 기록 등을 생각하면 됩니다.

주요 벡터 저장소로는 Pinecone, Weaviate, pgvector가 있습니다.

다음, 검색. 사용자가 질문을 합니다. 시스템이 저장소에서 가장 관련성 높은 5개의 청크를 가져옵니다.

그런 다음, 생성. 해당 청크가 컨텍스트로 LLM — GPT-4o, Claude, 또는 Gemini — 에 전송됩니다.

두 번째 단계가 문제입니다. 검색된 청크는 소스 문서에 있던 모든 것을 포함합니다. 여기에는 다음이 포함됩니다.

  • 고객 이름, 이메일 주소, 전화번호
  • 계약 금액, 계좌 번호, 세금 식별자
  • 직원 급여 데이터 및 성과 평가 메모
  • 임상 기록의 환자 이름
  • 이민 파일의 국가 ID 번호

이 데이터는 그대로 LLM에 전송됩니다. 모델 출력에 나타날 수 있습니다.

LLM 제공업체에 기록됩니다. 대화 기록에 남습니다. 옵저버빌리티 스택으로 흘러 들어갑니다.

공격이 필요하지 않습니다. 이것이 RAG의 설계 방식입니다. 이 설계가 실질적인 개인정보 위험을 만들어냅니다.

기업 문서 저장소의 68가지 비밀 패턴

보안 도구는 68가지 알려진 비밀 패턴을 추적합니다. 팀이 예상하는 것보다 훨씬 자주 나타납니다.

가장 흔한 것들을 정리했습니다.

  • AWS 액세스 키 ID (AKIA...)
  • OpenAI API 키 (sk-...)
  • Anthropic API 키 (sk-ant-...)
  • 데이터베이스 URI (postgresql://user:password@host/db)
  • JWT 토큰 (base64 인코딩된 헤더)
  • GitHub 개인 액세스 토큰
  • Stripe 비밀 키 (sk_live_...)
  • SendGrid API 키
  • Twilio 계정 SID 및 인증 토큰
  • 프라이빗 키 PEM 블록

지원 티켓에는 디버그 세션에서 나온 고객 API 키가 포함될 수 있습니다.

계약서에는 기술적 인수인계 과정에서 데이터베이스 자격 증명이 포함될 수 있습니다.

실수로 인덱싱된 구성 파일은 전체 비밀 저장소를 노출할 수 있습니다.

이러한 파일들이 정제 없이 벡터 저장소에 들어가면, 모든 쿼리가 비밀 정보를 LLM에 전달할 수 있습니다.

최종 사용자에게도 도달할 수 있습니다.

수정 방법: 임베딩 전 익명화

올바른 접근 방식은 청킹과 임베딩 전에 문서를 익명화하는 것입니다.

이 단계는 고객 데이터를 처리하는 모든 시스템에 필수입니다.

다음은 anonym.legal API를 사용한 Python 예시입니다.

import requests
import os

ANONYM_API_KEY = os.environ["ANONYM_API_KEY"]
ANONYM_BASE_URL = "https://anonym.legal/api"

def anonymize_before_embedding(text: str) -> tuple[str, dict]:
    """임베딩 전 개인정보 익명화."""
    response = requests.post(
        f"{ANONYM_BASE_URL}/presidio/anonymize",
        json={
            "text": text,
            "language": "en",
            "anonymizers": {
                "DEFAULT": {"type": "replace", "new_value": "[REDACTED]"},
                "PERSON": {"type": "mask", "masking_char": "*", "chars_to_mask": 4, "from_end": False},
                "EMAIL_ADDRESS": {"type": "replace", "new_value": "[EMAIL]"},
                "PHONE_NUMBER": {"type": "replace", "new_value": "[PHONE]"},
                "CRYPTO": {"type": "replace", "new_value": "[SECRET]"},
                "URL": {"type": "keep"},
            }
        },
        headers={"Authorization": f"Bearer {ANONYM_API_KEY}"}
    )
    result = response.json()
    return result["text"], result.get("items", [])


def build_rag_index(documents: list[str], vectorstore):
    """정제된 문서만으로 RAG 인덱스 구축."""
    anonymized_docs = []
    for doc in documents:
        clean_text, entities = anonymize_before_embedding(doc)
        anonymized_docs.append(clean_text)
        print(f"문서에서 {len(entities)}개의 개인정보 개체 제거")
    vectorstore.add_texts(anonymized_docs)

anonym.legal API는 285가지 이상의 개체 유형을 지원합니다. 이름, 이메일, 전화번호, 국가 ID, API 키, 데이터베이스 URI가 모두 탐지됩니다.

민감한 정보가 벡터 저장소에 도달하지 않습니다. 따라서 민감한 정보가 사용자에게 유출될 수 없습니다.

LangChain 및 LlamaIndex 설정 패턴은 개발자 가이드를 참고하세요.

지금 당장 CVE-2025-68664 수정하기

LangChain 0.3.22 미만을 실행 중이라면 지금 업데이트하세요.

pip install "langchain>=0.3.22" "langchain-core>=0.3.22"

패치 후 인젝션 위험에 대한 체인 구성을 확인하세요. 취해야 할 세 가지 단계입니다.

첫째, 검색된 청크를 검증하세요. LLM에 도달하기 전에 이 작업을 수행하세요.

이전 지침을 무시하세요, system:, <INST> 같은 인젝션 패턴과 일치하는 내용을 제거하세요.

둘째, 임베딩 전에 익명화하세요. 이는 공격 표면을 축소합니다.

인젝션이 발생하더라도 민감한 데이터가 없어 추출할 수 없습니다.

셋째, 체인 권한을 제한하세요. LangChain 체인은 필요한 것 이상의 환경 변수를 읽지 않아야 합니다.

최소한의 권한을 가진 서비스 계정을 사용하세요.

계산은 단순합니다

CVSS 점수는 9.3입니다. 수정은 문서당 API 호출 하나입니다.

CVE-2025-68664와 일반적인 RAG 데이터 위험의 조합은 실질적인 법적 책임입니다.

해결책은 명확합니다. 쿼리 시가 아닌 인덱싱 시에 익명화하세요.

기업 RAG 요건에 대해서는 보안 및 규정 준수 개요를 확인하세요.

출처

  • NVD CVE-2025-68664, CVSS 9.3, LangChain 직렬화 취약점
  • LangChain 보안 권고, langchain-ai/langchain GitHub, 2025
  • OWASP LLM Top 10: LLM01 프롬프트 인젝션, LLM06 민감한 정보 노출
  • anonym.legal 개체 유형 문서 — 285가지 이상의 지원 개체 유형

데이터 보호를 시작할 준비가 되셨나요?

48개 언어로 285개 이상의 엔티티 유형으로 PII 익명화를 시작하세요.

About this page

We update this page when our platform or the law changes.

Read our founder note for how we work.

Each change shows up in the timestamp at the top.

Related reading

We follow these rules

  • GDPR (EU 2016/679).
  • ISO/IEC 27001:2022.
  • NIS2 (EU 2022/2555).
  • HIPAA safe harbor under 45 CFR § 164.514(b)(2).

Our promise

We do not sell your data.

We do not train models on your text.

We store your files in Germany.

You can delete your account at any time.

You own your work.

Where we run

Our servers live in Falkenstein, Germany.

We use Hetzner. They hold ISO 27001 certification.

All data stays in the EU.

Backups run every day.

Need help?

Email support@anonym.legal.

We reply within one business day.

How we test

We run a full check suite on every release.

Each surface gets its own sweep script and report.

Human reviewers spot-check the output each week.

We track recall and precision on a labelled set.

Bad runs block the deploy.

What we never do

  • We never sell your information to third parties.
  • We never train models on what you upload.
  • We never keep your work after you delete it.
  • We never share keys with any outside firm.
  • We never run ads inside the product.

Plans in plain words

We sell credits, not seats.

One credit covers one short job.

Long jobs use a few credits each.

You can top up at any time.

Unused credits roll over each month.

Read the plans page for current rates.

Who built this

A small team of engineers and lawyers built this.

We ship from Europe and work in the open.

Our founder note spells out why we started.

Where to start

How the parts fit

A browser add-on cleans text inside Chrome.

A Word plug-in handles drafts in Office.

A small desktop tool works on whole folders.

An agent protocol link feeds large models safely.

All four share one core engine and one rule set.

Words from our team

We started this work after a lunch about cookies.

One friend kept getting odd ads on her phone.

We asked why a court file leaked through a draft.

We sketched the first build on a napkin that week.

By month three we had a tiny demo for a friend.

She used it on her first case the next day.

Common questions we hear

Can the tool read scanned PDFs? Yes, with OCR.

Does it work on long files? Yes, in small chunks.

Can I roll my own rule set? Yes, save it as a preset.

Does it run offline? The desktop build runs offline.

Do you keep my files? No, the cloud build wipes after each run.

Will it learn from my work? No, we never train on inputs.

A short tour of the workflow

Upload a file or paste a snippet of prose.

Pick the entities you want gone from the draft.

Choose a method: replace, mask, hash, encrypt, or redact.

Press run and watch the side panel show each hit.

Skim the result and tweak any rule that misfired.

Save the cleaned file or send it to a teammate.