CVE-2024-36361

6.8 MEDIUM

📋 TL;DR

CVE-2024-36361 allows remote code execution in Pug template engine when untrusted input is passed to specific compilation functions. Applications using Pug's compileClient, compileFileClient, or compileClientWithDependenciesTracked functions with user-controlled input are vulnerable. This primarily affects developers who misuse these compilation functions in production applications.

💻 Affected Systems

Products:
  • Pug (formerly Jade) template engine
Versions: All versions through 3.0.2
Operating Systems: All platforms running Node.js
Default Config Vulnerable: ✅ No
Notes: Only vulnerable when applications pass untrusted input to compileClient, compileFileClient, or compileClientWithDependenciesTracked functions

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full server compromise with arbitrary code execution, data theft, and lateral movement within the network

🟠

Likely Case

Limited code execution within the application context, potentially leading to data exposure or service disruption

🟢

If Mitigated

No impact if proper input validation prevents untrusted data from reaching vulnerable functions

🌐 Internet-Facing: MEDIUM - Requires specific misuse of compilation functions which are typically not exposed to untrusted users
🏢 Internal Only: LOW - Same requirements as internet-facing, but reduced attack surface

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires understanding of Pug's compilation functions and ability to inject into specific parameters

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.0.3 and later

Vendor Advisory: https://github.com/pugjs/pug/pull/3428

Restart Required: Yes

Instructions:

1. Update package.json to specify pug version 3.0.3 or higher. 2. Run 'npm update pug' or 'yarn upgrade pug'. 3. Restart your Node.js application.

🔧 Temporary Workarounds

Input validation and sanitization

all

Validate and sanitize all input passed to Pug compilation functions

Function restriction

all

Avoid using compileClient, compileFileClient, or compileClientWithDependenciesTracked with any user-controlled input

🧯 If You Can't Patch

  • Implement strict input validation to ensure no untrusted data reaches vulnerable compilation functions
  • Use application-level firewalls or WAF rules to detect and block suspicious template compilation patterns

🔍 How to Verify

Check if Vulnerable:

Check if your application uses compileClient, compileFileClient, or compileClientWithDependenciesTracked with any user input

Check Version:

npm list pug | grep pug

Verify Fix Applied:

Verify pug version is 3.0.3 or higher using 'npm list pug' or check package.json

📡 Detection & Monitoring

Log Indicators:

  • Unusual template compilation errors
  • Suspicious JavaScript execution in template contexts

Network Indicators:

  • Unexpected template compilation requests
  • Abnormal payloads in template-related API calls

SIEM Query:

source="application.log" AND ("compileClient" OR "compileFileClient" OR "compileClientWithDependenciesTracked") AND user_input=*

🔗 References

📤 Share & Export