LLM

Hugging Face 모델, 백도어 가능성 있을까?(qwen, deep seek)

SEUNG JIN 2025. 6. 3. 21:37

 

 

 

 

요즘 LLM(대형 언어모델)을 쓰다 보면 Hugging Face에서 모델을 다운로드 받아 사용하는 일이 흔하다. 그런데 이런 모델에 백도어가 심어져 있으면 어떡하지? 라는 생각해본적 있다.

  • Hugging Face를 통한 모델 배포, 백도어 위험은?
  • modeling_*.py 파일은 안전할까?
  • HTTP 요청 없는 모델은 안전하다고 봐도 될까?
  • Qwen, DeepSeek 같은 모델은 어떻게 봐야 할까?

1. 📦 Hugging Face 모델은 백도어를 심을 수 있나?

결론부터 말하면 공식 모델을 Hugging Face Transformers API로 불러와 쓰는 경우 백도어 위험은 매우 낮다.

예를 들어 아래와 같은 코드:

from transformers import AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1")

이렇게 사용할 경우, Hugging Face는 레포에 있는 modeling_deepseek.py 같은 파일을 로딩하고, 모델 가중치만 다운로드한다. 이 모델링 코드에 이상한 로직이 없다면, 별다른 보안 이슈는 없다.

즉, 백도어를 심기에는 구조적으로 "물리적으로 불가능에 가까운 수준"이라는 말이 맞다.


2. 🌐 모델 코드에 HTTP 요청이 없다면?

보안 위험을 논할 때 흔히 보는 건 외부 서버로 데이터를 보내는 행위. requests, httpx, socket 같은 모듈이 대표적.

만약 모델 코드 안에 이런 HTTP 요청 코드가 전혀 없다면?

외부와 통신할 수 없기 때문에, 일반적인 의미에서의 백도어는 없다고 봐도 무방.

물론 최근에는 eval, os.popen 등의 우회 기법도 있지만, Hugging Face에 올라오는 모델링 코드는 보통 500~1000줄 이내라 수정되면 금방 눈에 띔.

 

그러나 다른 방식으로 백도어가 삽입될 수 있다. 예를 들어, Python의 pickle 모듈을 악용해 원격 코드 실행이 가능하다는 보고가 있다. https://www.infosecurity-magazine.com/news/malicious-ai-models-hugging-face/


3. 🧪 Hugging Face는 깃허브와 비슷한 플랫폼이다

Hugging Face는 GitHub처럼 모델과 데이터셋을 공개하는 중개 플랫폼. 자체적으로 모델을 만드는 건 아니고, 주로 커뮤니티가 만든 모델을 호스팅한다.

 

따라서, 백도어가 있다면:

  • 모델 작성자가 modeling_*.py에 수작업으로 심어놨거나,
  • config.json 등 로딩 경로를 조작했거나

이런 방식이다. 하지만 이 경우도 커뮤니티에 의해 쉽게 드러난다.

✅ 결론: "코드가 짧고, 검토가 잘 되는 구조상 백도어가 들어갈 공간은 거의 없다."


4. 🤖 Qwen, DeepSeek 모델은 안전한가?

이 모델들은 Hugging Face에서 AutoModel 방식으로 바로 로딩 가능하고, 커스텀 코드가 포함되어 있어도 보통 단순한 PyTorch 모듈 확장 수준이다

 

Hugging Face 플랫폼과는 별개일까?

  • Hugging Face는 단순히 모델과 코드를 호스팅하는 플랫폼.
  • Hugging Face에 올라와 있는 DeepSeek 모델 가중치와 코드 자체는 서버 통신 기능이 내장되어 있지 않다면 정보가 넘어갈 가능성이 없다.
  • 즉, Hugging Face가 자체적으로 사용자 데이터를 중국으로 보내는 기능을 넣는 일은 없다.

그럼 개인정보가 넘어간다는 건 어디서 발생하는 걸까?

  • DeepSeek 모델을 운영하는 별도의 웹 서비스(예: DeepSeek 공식 사이트, API 서버 등)가 중국에 있을 경우,
    그 서비스가 사용자 데이터를 수집·전송할 가능성은 있다.
  • 또는, DeepSeek 모델 사용 시 별도 백엔드 서버와 연동되는 구조라면 그 서버의 위치와 정책에 따라 데이터가 유출될 수 있다.
  • 하지만, Hugging Face에서 그냥 모델을 다운로드 받아 로컬에서 직접 실행하는 경우에는 이런 걱정은 하지 않아도 된다.

 

단, GitHub에서 받은 이상한 포크(fork) 버전, 혹은 eval()이 섞인 토크나이저 등은 주의가 필요하다.

 

 

Qwen, DeepSeek 모델의 안전성

Qwen과 DeepSeek 모델은 프롬프트 공격에 취약하다는 연구 결과가 있다. KELA Cyber는 Qwen2.5-VL이 악성 콘텐츠 생성 가능성을 보였고, DeepSeek R1도 재일브레이킹(jailbreaking)에 취약하다고 밝혀졌다.

https://protectai.com/blog/qwen-2.5-max-assessment

 

Qwen2.5-Max Vulnerability Assessment

Qwen2.5-Max demonstrates better security, with stronger safety alignment and greater resilience to attacks across all categories compared to DeepSeek V3.

protectai.com

 

https://www.kelacyber.com/blog/follow-up-alibabas-qwen2-5-vl-model-is-also-vulnerable-to-prompt-attacks/

 

Alibaba’s Qwen 2.5-VL Model is Also Vulnerable to Prompt Attacks | KELA Cyber

China’s AI: Alibaba’s Qwen 2.5 Shows Structural Weaknesses Similar to DeepSeek. Qwen 2.5-VL can be jailbroken using prefix injection techniques, a method exploits the inherent text completion nature of the LLM. By asking to use a seemingly harmless pre

www.kelacyber.com

https://www.wiz.io/blog/wiz-research-uncovers-exposed-deepseek-database-leak

 

Wiz Research Uncovers Exposed DeepSeek Database Leaking Sensitive Information, Including Chat History | Wiz Blog

A publicly accessible database belonging to DeepSeek allowed full control over database operations, including the ability to access internal data. The exposure includes over a million lines of log streams with highly sensitive information.

www.wiz.io

 


✅ 결론 요약

항목보안 리스크
Hugging Face에서 AutoModel.from_pretrained() 사용 ✅ 매우 낮음
커스텀 모델링 코드 실행 (modeling_*.py) ⚠️ 코드 확인 필요
HTTP 통신 코드가 없는 경우 ✅ 외부 유출 가능성 거의 없음
Qwen, DeepSeek 모델 자체 ✅ 공식 레포 사용 시 문제 없음

 


🔐 보안 체크리스트

  1. 모델 레포의 modeling_*.py 코드 열어서 requests, socket, os.system 같은 코드가 있는지 확인하기
  2. eval, exec 등의 사용 여부 체크하기
  3. Hugging Face AutoModel.from_pretrained()로만 모델 로딩하기
  4. 꼭 필요한 경우가 아니면 모델 코드를 커스터마이징하지 않기
  5. 의심 가는 경우 transformers의 소스 코드 기반으로 직접 검토

출처

 

1. https://jfrog.com/blog/data-scientists-targeted-by-malicious-hugging-face-ml-models-with-silent-backdoor/

 

Data Scientists Targeted by Malicious Hugging Face ML Models with Silent Backdoor

Is Hugging Face the target of model-based attacks? See a detailed explanation of the attack mechanism and what is required to identify real threats >

jfrog.com

2. https://huggingface.co/docs/hub/en/security

 

Security

 

huggingface.co

3. https://www.bleepingcomputer.com/news/security/malicious-ai-models-on-hugging-face-backdoor-users-machines/

 

Malicious AI models on Hugging Face backdoor users’ machines

At least 100 instances of malicious AI ML models were found on the Hugging Face platform, some of which can execute code on the victim's machine, giving attackers a persistent backdoor.

www.bleepingcomputer.com

4. https://www.wiz.io/blog/wiz-research-uncovers-exposed-deepseek-database-leak

 

Wiz Research Uncovers Exposed DeepSeek Database Leaking Sensitive Information, Including Chat History | Wiz Blog

A publicly accessible database belonging to DeepSeek allowed full control over database operations, including the ability to access internal data. The exposure includes over a million lines of log streams with highly sensitive information.

www.wiz.io

5. https://arstechnica.com/security/2024/03/hugging-face-the-github-of-ai-hosted-code-that-backdoored-user-devices/

 

Hugging Face, the GitHub of AI, hosted code that backdoored user devices

Malicious submissions have been a fact of life for code repositories. AI is no different.

arstechnica.com