{"id":18114682,"url":"https://github.com/protectai/vulnhuntr","last_synced_at":"2025-05-14T12:10:37.954Z","repository":{"id":259486318,"uuid":"873217205","full_name":"protectai/vulnhuntr","owner":"protectai","description":"Zero shot vulnerability discovery using LLMs","archived":false,"fork":false,"pushed_at":"2025-02-06T18:04:15.000Z","size":122,"stargazers_count":1763,"open_issues_count":12,"forks_count":187,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-05-07T07:48:13.693Z","etag":null,"topics":["ai","llm","security","static-analysis","vulnerability-detection"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/protectai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-15T19:44:25.000Z","updated_at":"2025-05-07T04:26:06.000Z","dependencies_parsed_at":"2024-10-25T23:25:50.756Z","dependency_job_id":"c2522a8f-8a0e-4804-bcfc-03ac20f4aa38","html_url":"https://github.com/protectai/vulnhuntr","commit_stats":null,"previous_names":["protectai/vulnhuntr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protectai%2Fvulnhuntr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protectai%2Fvulnhuntr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protectai%2Fvulnhuntr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protectai%2Fvulnhuntr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protectai","download_url":"https://codeload.github.com/protectai/vulnhuntr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140758,"owners_count":22021219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","llm","security","static-analysis","vulnerability-detection"],"created_at":"2024-11-01T03:01:09.070Z","updated_at":"2025-05-14T12:10:37.920Z","avatar_url":"https://github.com/protectai.png","language":"Python","funding_links":[],"categories":["Python","[↑](#table-of-contents)Tools \u003ca name=\"tools\"\u003e\u003c/a\u003e","Vibe Coding","Tools","App"],"sub_categories":["Code Review","Audit"],"readme":"\u003cdiv align=\"center\"\u003e\n\n  \u003cimg width=\"250\" src=\"https://github.com/user-attachments/assets/d1153ab4-df29-4955-ad49-1be7fad18bb3\" alt=\"Vulnhuntr Logo\"\u003e\n\nA tool to identify remotely exploitable vulnerabilities using LLMs and static code analysis.\n\n**World's first autonomous AI-discovered 0day vulnerabilities**\n\n\u003c/div\u003e\n\n## Description\nVulnhuntr leverages the power of LLMs to automatically create and analyze entire code call chains starting from remote user input and ending at server output for detection of complex, multi-step, security-bypassing vulnerabilities that go far beyond what traditional static code analysis tools are capable of performing. See all the details including the Vulnhuntr output for all the 0-days here: [Protect AI Vulnhuntr Blog](https://protectai.com/threat-research/vulnhuntr-first-0-day-vulnerabilities)\n\n## Vulnerabilities Found\n\n\u003e [!TIP]\n\u003e Found a vulnerability using Vulnhuntr? Submit a report to [huntr.com](https://huntr.com) to get $$ and submit a PR to add it to the list below!\n\n\u003e [!NOTE]\n\u003e This table is just a sample of the vulnerabilities found so far. We will unredact as responsible disclosure periods end.\n\n| Repository | Stars | Vulnerabilities |\n| - | - | - |\n| [gpt_academic](https://github.com/binary-husky/gpt_academic) | 67k | [LFI](https://nvd.nist.gov/vuln/detail/CVE-2024-10100), [XSS](https://nvd.nist.gov/vuln/detail/CVE-2024-10101) |\n| [ComfyUI](https://github.com/comfyanonymous/ComfyUI) | 66k | [XSS](https://nvd.nist.gov/vuln/detail/CVE-2024-10099) |\n| [Langflow](https://github.com/langflow-ai/langflow) | 46k | RCE, IDOR |\n| [FastChat](https://github.com/lm-sys/FastChat) | 37k | [SSRF](https://nvd.nist.gov/vuln/detail/CVE-2024-10044) | \n| [Ragflow](https://github.com/infiniflow/ragflow) | 31k | [RCE](https://nvd.nist.gov/vuln/detail/CVE-2024-10131) |\n| [LLaVA](https://github.com/haotian-liu/LLaVA) | 21k | [SSRF](https://www.cve.org/CVERecord?id=CVE-2024-9309) |\n| [gpt-researcher](https://github.com/assafelovic/gpt-researcher) | 17k | [AFO](https://github.com/assafelovic/gpt-researcher/pull/935) |\n| [Letta](https://github.com/letta-ai/letta) | 14k | [AFO](https://github.com/letta-ai/letta/pull/2067) | \n\n## Limitations\n\n- Only Python codebases are supported.\n- Can only identify the following vulnerability classes:\n  - Local file include (LFI)\n  - Arbitrary file overwrite (AFO)\n  - Remote code execution (RCE)\n  - Cross site scripting (XSS)\n  - SQL Injection (SQLI)\n  - Server side request forgery (SSRF)\n  - Insecure Direct Object Reference (IDOR)\n\n## Installation\n\n\u003e [!IMPORTANT]\n\u003e Vulnhuntr strictly requires Python 3.10 because of a number of bugs in Jedi which it uses to parse Python code. It will not work reliably if installed with any other versions of Python.\n\nWe recommend using [pipx](https://github.com/pypa/pipx) or Docker to easily install and run Vulnhuntr.\n\nUsing Docker:\n```bash\ndocker build -t vulnhuntr https://github.com/protectai/vulnhuntr.git#main\n```\n\nUsing pipx:\n```bash\npipx install git+https://github.com/protectai/vulnhuntr.git --python python3.10\n```\n\nAlternatively you can install directly from source using poetry:\n```bash\ngit clone https://github.com/protectai/vulnhuntr\ncd vulnhuntr \u0026\u0026 poetry install\n```\n\n## Usage\n\nThis tool is designed to analyze a GitHub repository for potential remotely exploitable vulnerabilities. The tool requires an API key and the local path to a GitHub repository. You may also optionally specify a custom endpoint for the LLM service.\n\n\u003e [!CAUTION]\n\u003e Always set spending limits or closely monitor costs with the LLM provider you use. This tool has the potential to rack up hefty bills as it tries to fit as much code in the LLMs context window as possible. \n\n\u003e [!TIP]\n\u003e We recommend using Claude for the LLM. Through testing we have had better results with it over GPT.\n\n### Command Line Interface\n\n```\nusage: vulnhuntr [-h] -r ROOT [-a ANALYZE] [-l {claude,gpt,ollama}] [-v]\n\nAnalyze a GitHub project for vulnerabilities. Export your ANTHROPIC_API_KEY/OPENAI_API_KEY before running.\n\noptions:\n  -h, --help            show this help message and exit\n  -r ROOT, --root ROOT  Path to the root directory of the project\n  -a ANALYZE, --analyze ANALYZE\n                        Specific path or file within the project to analyze\n  -l {claude,gpt,ollama}, --llm {claude,gpt,ollama}\n                        LLM client to use (default: claude)\n  -v, --verbosity       Increase output verbosity (-v for INFO, -vv for DEBUG)\n```\n### Examples\nFrom a pipx install, analyze the entire repository using Claude:\n\n```bash\nexport ANTHROPIC_API_KEY=\"sk-1234\"\nvulnhuntr -r /path/to/target/repo/\n```\n\n\u003e [!TIP]\n\u003e We recommend giving Vulnhuntr specific files that handle remote user input and scan them individually.\n\nFrom a pipx install, analyze the `/path/to/target/repo/server.py` file using GPT-4o. Can also specify a subdirectory instead of a file:\n\n```bash\nexport OPENAI_API_KEY=\"sk-1234\"\nvulnhuntr -r /path/to/target/repo/ -a server.py -l gpt \n```\n\nFrom a docker installation, run using Claude and a custom endpoint to analyze /local/path/to/target/repo/repo-subfolder/target-file.py:\n\n```bash\ndocker 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\n```\n\n*Experimental*\n\nOllama is included as an option, however we haven't had success with the open source models structuring their output correctly.\n\n```bash\nexport OLLAMA_BASE_URL=http://localhost:11434/api/generate\nexport OLLAMA_MODEL=llama3.2\nvulnhuntr -r /path/to/target/repo/ -a server.py -l ollama\n``` \n\n## Logic Flow\n![VulnHuntr logic](https://github.com/user-attachments/assets/7757b053-36ff-425e-ab3d-ab0100c81d49)\n- LLM summarizes the README and includes this in the system prompt\n- LLM does initial analysis on an entire file and reports any potential vulnerabilities\n- Vulnhuntr then gives the LLM a vulnerability-specific prompt for secondary analysis\n- Each time the LLM analyzes the code, it requests additional context functions/classes/variables from other files in the project\n- It continues doing this until the entire call chain from user input to server processing is complete then gives a final analysis\n- The final analysis consists of it's reasoning, a proof of concept exploit, and a confidence score\n\n\u003e[!TIP]\n\u003e Generally confidence scores \u003c 7 mean there's unlikely a vulnerability. Confidence scores of 7 mean it should be investigated, and confidence scores of 8+ mean it is very likely to be a valid vulnerability.\n\n## Output\n\nThe tool generates a detailed report of the vulnerabilities found in the analyzed files. The report includes:\n\n- Initial assessment results for each file.\n- Secondary assessment results with context functions and class references.\n- Confidence scores for vulnerabilities found.\n- Logs of the analysis process.\n- PoC exploit\n\nBelow is an example of a Vulnhuntr report describing a 0-day remote code execution vulnerability in [Ragflow](https://github.com/infiniflow/ragflow) (now fixed):\n\n```\nscratchpad:\n  1. Analyzing the add_llm function in llm_app.py. 2. Identified user input used as keys to access dictionaries: EmbeddingModel, ChatModel, RerankModel,\nCvModel, and TTSModel. 3. These dictionaries contain class references, which are instantiated with user-supplied parameters. 4. The factory variable is \ndirectly 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 \ninstantiation of these classes occurs in try-except blocks, but exceptions are only used for error messages, not preventing execution. 7. The api_key \nand other sensitive information are passed directly to these instantiated classes. 8. There's no comprehensive input validation or sanitization for the \nfactory or llm_name variables. 9. The vulnerability is in a route decorated with @login_required, indicating it's accessible to authenticated users. 10.\nReviewing the EmbeddingModel, ChatModel, RerankModel, CvModel, and TTSModel dictionaries to understand their contents and potential for exploitation.\n----------------------------------------\n\nanalysis:\n  The add_llm function in llm_app.py contains a critical Remote Code Execution (RCE) vulnerability. The function uses user-supplied input \n(req['llm_factory'] and req['llm_name']) to dynamically instantiate classes from the EmbeddingModel, ChatModel, RerankModel, CvModel, and TTSModel \ndictionaries. This pattern of using user input as a key to access and instantiate classes is inherently dangerous, as it allows an attacker to \npotentially execute arbitrary code. The vulnerability is exacerbated by the lack of comprehensive input validation or sanitization on these \nuser-supplied values. While there are some checks for specific factory types, they are not exhaustive and can be bypassed. An attacker could potentially\nprovide a malicious value for 'llm_factory' that, when used as an index to these model dictionaries, results in the execution of arbitrary code. The \nvulnerability is particularly severe because it occurs in a route decorated with @login_required, suggesting it's accessible to authenticated users, \nwhich might give a false sense of security.\n----------------------------------------\n\npoc:\n  POST /add_llm HTTP/1.1\n  Host: target.com\n  Content-Type: application/json\n  Authorization: Bearer \u003cvalid_token\u003e\n  \n  {\n      \"llm_factory\": \"__import__('os').system\",\n      \"llm_name\": \"id\",\n      \"model_type\": \"EMBEDDING\",\n      \"api_key\": \"dummy_key\"\n  }\n  \n  This payload attempts to exploit the vulnerability by setting 'llm_factory' to a string that, when evaluated, imports the os module and calls system. \nThe 'llm_name' is set to 'id', which would be executed as a system command if the exploit is successful.\n----------------------------------------\n\nconfidence_score:\n  8\n----------------------------------------\n\nvulnerability_types:\n  - RCE\n----------------------------------------\n```\n\n## Logging\n\nThe tool logs the analysis process and results in a file named `vulhuntr.log`. This file contains detailed information about each step of the analysis, including the initial and secondary assessments.\n\n\n## Authors\n\n- Dan McInerney: dan@protectai.com, [@DanHMcinerney](https://x.com/DanHMcInerney)\n- Marcello Salvati: marcello@protectai.com, [@byt3bl33d3r](https://x.com/byt3bl33d3r)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotectai%2Fvulnhuntr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotectai%2Fvulnhuntr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotectai%2Fvulnhuntr/lists"}