OS Command Injection Affecting github.com/projectdiscovery/nuclei/pkg/templates/signer package, versions >=3.0.0 <3.3.2


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.05% (23rd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about OS Command Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-GOLANG-GITHUBCOMPROJECTDISCOVERYNUCLEIPKGTEMPLATESSIGNER-7897405
  • published5 Sept 2024
  • disclosed4 Sept 2024
  • creditGuy Goldenberg

Introduced: 4 Sep 2024

CVE-2024-43405  (opens in a new tab)
CWE-78  (opens in a new tab)

How to fix?

Upgrade github.com/projectdiscovery/nuclei/pkg/templates/signer to version 3.3.2 or higher.

Overview

Affected versions of this package are vulnerable to OS Command Injection due to an improper template signature verification process in the tmpl_signer.go component. An attacker can inject malicious content into a template while maintaining a valid signature for the benign part of the template by exploiting discrepancies between the signature verification process and the YAML parser's handling of newline characters, combined with the processing of multiple signatures.

Note: This is only exploitable if CLI users execute custom code templates from unverified sources, including templates authored by third parties or obtained from unverified repositories. SDK users are also at risk if they allow end-users to execute custom code templates.

Code templates are disabled as default; users have to explicitly enable them with the -code option.

Workaround

This vulnerability can be mitigated by refraining from using custom templates if unable to upgrade immediately and by ensuring only trusted, verified templates are executed. Those who are unable to upgrade Nuclei should disable running custom code templates.

PoC


id: example-template
info:
  name: Example Template
# Other benign content...
# digest: <valid_signature_for_benign_content>
# digest: <another_signature>\r
code:\r
  - engine:\r
      - sh\r
      - bash\r
    source: |\r
      id\r

References

CVSS Scores

version 4.0
version 3.1