OS Command Injection Affecting github.com/projectdiscovery/nuclei/v3/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

    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 ID SNYK-GOLANG-GITHUBCOMPROJECTDISCOVERYNUCLEIV3PKGTEMPLATESSIGNER-7897406
  • published 8 Sep 2024
  • disclosed 4 Sep 2024
  • credit Guy Goldenberg

How to fix?

Upgrade github.com/projectdiscovery/nuclei/v3/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
Expand this section

Snyk

Recommended
4.5 medium
  • Attack Vector (AV)
    Local
  • Attack Complexity (AC)
    High
  • Attack Requirements (AT)
    None
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    Active
  • Confidentiality (VC)
    None
  • Integrity (VI)
    None
  • Availability (VA)
    None
  • Confidentiality (SC)
    High
  • Integrity (SI)
    High
  • Availability (SA)
    None