
LLM을 활용한 제로 샷 취약점 발견
LLM과 정적 코드 분석을 사용하여 원격으로 악용 가능한 취약점을 식별하는 도구입니다.
세계 최초로 자율 AI가 발견한 0데이 취약점
Vulnhuntr은 LLM의 힘을 활용하여 원격 사용자 입력에서 시작하여 서버 출력으로 끝나는 전체 코드 호출 체인을 자동으로 생성 및 분석함으로써, 기존 정적 코드 분석 도구가 수행할 수 있는 범위를 훨씬 넘어서는 복잡하고 다단계이며 보안을 우회하는 취약점을 탐지합니다. 모든 0데이에 대한 Vulnhuntr 출력을 포함한 모든 세부 사항은 여기에서 확인하세요: Protect AI Vulnhuntr 블로그
[!TIP] Vulnhuntr을 사용하여 취약점을 발견하셨나요? huntr.com에 보고서를 제출하여 보상을 받고 아래 목록에 추가하는 PR을 제출하세요!
[!NOTE] 이 표는 지금까지 발견된 취약점 중 일부입니다. 책임 있는 공개 기간이 종료됨에 따라 점차 공개할 예정입니다.
| 저장소 | 별표 | 취약점 |
|---|---|---|
| gpt_academic | 67k | LFI, XSS |
| ComfyUI | 66k | XSS |
| Langflow | 46k | RCE, IDOR |
| FastChat | 37k | SSRF |
| Ragflow | 31k | RCE |
| LLaVA | 21k | SSRF |
| gpt-researcher | 17k | AFO |
| Letta | 14k | AFO |
[!IMPORTANT] Vulnhuntr은 Python 코드를 구문 분석하는 데 사용하는 Jedi의 여러 버그로 인해 Python 3.10을 엄격히 요구합니다. 다른 버전의 Python으로 설치하면 안정적으로 작동하지 않습니다.
pipx 또는 Docker를 사용하여 Vulnhuntr을 쉽게 설치하고 실행하는 것을 권장합니다.
Docker 사용:
docker build -t vulnhuntr https://github.com/protectai/vulnhuntr.git#main
pipx 사용:
pipx install git+https://github.com/protectai/vulnhuntr.git --python python3.10
또는 소스에서 직접 poetry를 사용하여 설치할 수 있습니다:
git clone https://github.com/protectai/vulnhuntr
cd vulnhuntr && poetry install
이 도구는 GitHub 저장소를 분석하여 잠재적으로 원격으로 악용 가능한 취약점을 찾도록 설계되었습니다. 이 도구는 API 키와 GitHub 저장소의 로컬 경로가 필요합니다. 또한 LLM 서비스의 사용자 정의 엔드포인트를 선택적으로 지정할 수 있습니다.
[!CAUTION] 사용하는 LLM 제공 업체에서 항상 지출 한도를 설정하거나 비용을 면밀히 모니터링하세요. 이 도구는 LLM의 컨텍스트 창에 최대한 많은 코드를 맞추려고 시도하므로 상당한 비용이 발생할 수 있습니다.
[!TIP] LLM으로는 Claude 사용을 권장합니다. 테스트 결과 GPT보다 더 나은 결과를 얻었습니다.
usage: vulnhuntr [-h] -r ROOT [-a ANALYZE] [-l {claude,gpt,ollama}] [-v]
Analyze a GitHub project for vulnerabilities. Export your ANTHROPIC_API_KEY/OPENAI_API_KEY before running.
options:
-h, --help show this help message and exit
-r ROOT, --root ROOT Path to the root directory of the project
-a ANALYZE, --analyze ANALYZE
Specific path or file within the project to analyze
-l {claude,gpt,ollama}, --llm {claude,gpt,ollama}
LLM client to use (default: claude)
-v, --verbosity Increase output verbosity (-v for INFO, -vv for DEBUG)
pipx 설치에서 Claude를 사용하여 전체 저장소 분석:
export ANTHROPIC_API_KEY="sk-1234"
vulnhuntr -r /path/to/target/repo/
[!TIP] Vulnhuntr에 원격 사용자 입력을 처리하는 특정 파일을 지정하고 개별적으로 스캔할 것을 권장합니다.
pipx 설치에서 /path/to/target/repo/server.py 파일을 GPT-4o를 사용하여 분석. 파일 대신 하위 디렉토리를 지정할 수도 있습니다:
export OPENAI_API_KEY="sk-1234"
vulnhuntr -r /path/to/target/repo/ -a server.py -l gpt
Docker 설치에서 Claude와 사용자 정의 엔드포인트를 사용하여 /local/path/to/target/repo/repo-subfolder/target-file.py 분석:
docker run --rm -e ANTHROPIC_API_KEY=sk-1234 -e ANTHROPIC_BASE_URL=https://localhost:1234/api -v /local/path/to/target/repo:/repo vulnhuntr:latest -r /repo -a repo-subfolder/target-file.py
실험적
Ollama도 옵션으로 포함되어 있지만, 오픈 소스 모델이 출력을 올바르게 구조화하는 데는 성공하지 못했습니다.
export OLLAMA_BASE_URL=http://localhost:11434/api/generate
export OLLAMA_MODEL=llama3.2
vulnhuntr -r /path/to/target/repo/ -a server.py -l ollama

[!TIP] 일반적으로 신뢰도 점수가 7 미만이면 취약점이 없을 가능성이 높습니다. 7점은 조사가 필요함을 의미하며, 8점 이상은 유효한 취약점일 가능성이 매우 높습니다.
이 도구는 분석된 파일에서 발견된 취약점에 대한 상세 보고서를 생성합니다. 보고서에는 다음이 포함됩니다:
다음은 Ragflow (현재 수정됨)에서 발견된 0데이 원격 코드 실행 취약점을 설명하는 Vulnhuntr 보고서 예시입니다:
scratchpad:
1. Analyzing the add_llm function in llm_app.py. 2. Identified user input used as keys to access dictionaries: EmbeddingModel, ChatModel, RerankModel,
CvModel, and TTSModel. 3. These dictionaries contain class references, which are instantiated with user-supplied parameters. 4. The factory variable is
directly used from user input (req['llm_factory']) without proper validation. 5. The llm_name is also derived from user input in most cases. 6. The
instantiation of these classes occurs in try-except blocks, but exceptions are only used for error messages, not preventing execution. 7. The api_key
and other sensitive information are passed directly to these instantiated classes. 8. There's no comprehensive input validation or sanitization for the
factory or llm_name variables. 9. The vulnerability is in a route decorated with @login_required, indicating it's accessible to authenticated users. 10.
Reviewing the EmbeddingModel, ChatModel, RerankModel, CvModel, and TTSModel dictionaries to understand their contents and potential for exploitation.
----------------------------------------
analysis:
The add_llm function in llm_app.py contains a critical Remote Code Execution (RCE) vulnerability. The function uses user-supplied input
(req['llm_factory'] and req['llm_name']) to dynamically instantiate classes from the EmbeddingModel, ChatModel, RerankModel, CvModel, and TTSModel
dictionaries. This pattern of using user input as a key to access and instantiate classes is inherently dangerous, as it allows an attacker to
potentially execute arbitrary code. The vulnerability is exacerbated by the lack of comprehensive input validation or sanitization on these
user-supplied values. While there are some checks for specific factory types, they are not exhaustive and can be bypassed. An attacker could potentially
provide a malicious value for 'llm_factory' that, when used as an index to these model dictionaries, results in the execution of arbitrary code. The
vulnerability is particularly severe because it occurs in a route decorated with @login_required, suggesting it's accessible to authenticated users,
which might give a false sense of security.
----------------------------------------
poc:
POST /add_llm HTTP/1.1
Host: target.com
Content-Type: application/json
Authorization: Bearer <valid_token>
{
"llm_factory": "__import__('os').system",
"llm_name": "id",
"model_type": "EMBEDDING",
"api_key": "dummy_key"
}
This payload attempts to exploit the vulnerability by setting 'llm_factory' to a string that, when evaluated, imports the os module and calls system.
The 'llm_name' is set to 'id', which would be executed as a system command if the exploit is successful.
----------------------------------------
confidence_score:
8
----------------------------------------
vulnerability_types:
- RCE
----------------------------------------
이 도구는 분석 과정과 결과를 vulhuntr.log 파일에 기록합니다. 이 파일에는 초기 평가 및 2차 평가를 포함한 분석의 각 단계에 대한 상세 정보가 포함됩니다.