ProjectDiscovery Nuclei 3 before 3.8.0 allows DSL expression injection. This affects use of -env-vars for multi-step templates against untrusted targets (not the default configuration).
A vulnerability in Nuclei's JavaScript protocol runtime allows JavaScript templates to read local .js and .json files through the require() function, bypassing the default local file access restriction.
Affected Component
The issue is in the JavaScript runtime's module loading system. The goja require() function used a default host filesystem loader without routing through the allow-local-file-access check.
Description
The goja require() function in Nuclei's JavaScript protocol runtime used the default host filesystem loader, which allowed JavaScript templates to import .js and .json files from anywhere on the host filesystem, ignoring the allow-local-file-access (-lfa) option that controls file access outside the template directory.
The impact is limited to .js and .json files, as goja's module loader only resolves those extensions. That said, this is still enough to expose sensitive data stored in JSON configuration files like package.json, credential stores, or cloud configuration files sitting on the host filesystem.
Affected Users
- CLI users running untrusted or third-party JavaScript templates. - SDK users who have integrated Nuclei into platforms where end-users can supply JavaScript templates, especially when relying on the default file access restriction to limit filesystem reads.
[!NOTE] The require() module loader only resolves .js and .json files. Other file types cannot be read through this vector.
Patches
- The vulnerability is fixed in Nuclei v3.8.0. Upgrading is strongly recommended. - Fix reference: #7332
Mitigation
Upgrade to Nuclei v3.8.0, where the require() registry is rebuilt per execution and file-backed module loads are routed through the same allow-local-file-access check as the rest of the filesystem operations.
In the meantime, avoid running JavaScript templates from unverified sources.
Workarounds
If upgrading is not an option, avoid running untrusted JavaScript templates entirely. There is no flag or configuration that mitigates this on affected versions.
Acknowledgments
Nuceli thanks @AkashHamal0x01 for reporting this issue through responsible disclosure via security@projectdiscovery.io
A vulnerability in Nuclei's expression evaluation engine makes it possible for a malicious target server to inject and execute supported DSL expressions. This happens when HTTP response data containing helper/function syntax gets reused by multi-step templates. If the -env-vars / -ev option is explicitly enabled, this can expose host environment variables. That option is off by default, so standard configurations are not affected by the information disclosure risk.
Affected Component
The issue lives in expressions.Evaluate() at pkg/protocols/common/expressions/ and in the unresolved-variable validation path (hasLiteralsOnly()).
Description
expressions.Evaluate() replaces placeholders first, then scans the substituted output for expressions. Because of this two-pass approach, response-derived values (including extractor output and response body content) can be reinterpreted as DSL/helper syntax on the second pass.
When -env-vars (-ev) is enabled, environment variables get merged into the template variable map. A malicious target can return response data containing expressions like {{envvarname}} which, when reused in a subsequent template request, resolve to actual environment variable values. This can expose sensitive host data like API keys, credentials, and tokens.
Without -ev enabled (the default), injected DSL expressions may still trigger helper functions such as {{md5("test")}}, but this has no meaningful security impact beyond unexpected behavior.
There is also a separate issue in hasLiteralsOnly(): it was evaluating helper expressions while deciding whether {{...}} contained unresolved variables, which caused validation logic to run side-effectful helpers even when the final request kept the value as a literal.
[!NOTE] The -env-vars / -ev option is off by default. Users who have not explicitly turned it on are not affected by the information disclosure aspect of this vulnerability.
Affected Users
- CLI users running multi-step templates (with extractors or flow-based request chaining) that reuse response-derived values against untrusted or attacker-controlled targets, with the -ev flag enabled. - SDK users who have integrated Nuclei into platforms where EnvironmentVariables is set to true and scan targets are not fully trusted.
Patches
- The vulnerability is fixed in Nuclei v3.8.0. Upgrading to this version is strongly recommended. - Relevant fix references: #7221, #7321.
Mitigation
Upgrade to Nuclei v3.8.0. The updated evaluation logic now collects expressions from the original template text before placeholder substitution and only evaluates those template-authored expressions.
If you have -ev enabled, disable it when scanning untrusted targets to avoid environment variable disclosure.
Workarounds
If upgrading is not an option right now, make sure -env-vars / -ev is not enabled when running multi-step templates against untrusted targets.
Acknowledgments
Nuclei thanks @gnuletik for reporting this issue through responsible disclosure via security@projectdiscovery.io