
اكتشاف الثغرات بطريقة Zero shot باستخدام LLMs
أداة لتحديد الثغرات القابلة للاستغلال عن بُعد باستخدام نماذج اللغة الكبيرة (LLMs) وتحليل الشيفرة الثابتة.
أول ثغرات اليوم الصفري (0day) التي اكتشفها الذكاء الاصطناعي بشكل مستقل في العالم
يستفيد Vulnhuntr من قدرات نماذج اللغة الكبيرة (LLMs) لإنشاء وتحليل سلاسل استدعاء كاملة للشيفرة تلقائيًا، بدءًا من المدخلات البعيدة للمستخدم وانتهاءً بمخرجات الخادم، وذلك لاكتشاف ثغرات معقدة ومتعددة الخطوات تتجاوز الحماية الأمنية، والتي تتجاوز بشكل كبير ما تستطيع أدوات تحليل الشيفرة الثابتة التقليدية القيام به. اطلع على جميع التفاصيل بما في ذلك مخرجات 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 3.10 بسبب عدد من الأخطاء في Jedi التي يستخدمها لتحليل شيفرة Python. لن يعمل بشكل موثوق إذا تم تثبيته مع أي إصدار آخر من 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] نوصي باستخدام Claude لـ LLM. من خلال الاختبار، حصلنا على نتائج أفضل معه مقارنة بـ 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+ تعني أنه من المحتمل جدًا أن تكون ثغرة صالحة.
تولد الأداة تقريرًا مفصلاً عن الثغرات المكتشفة في الملفات التي تم تحليلها. يتضمن التقرير:
فيما يلي مثال على تقرير Vulnhuntr يصف ثغرة تنفيذ تعليمات برمجية عن بُعد من نوع اليوم الصفري في Ragflow (تم إصلاحها الآن):
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. يحتوي هذا الملف على معلومات مفصلة حول كل خطوة من خطوات التحليل، بما في ذلك التقييمات الأولية والثانوية.