CVE-2025-5352

9.6 CRITICAL

📋 TL;DR

A critical stored XSS vulnerability in lunary-ai/lunary Analytics component allows arbitrary JavaScript execution in all users' browsers when attackers control the NEXT_PUBLIC_CUSTOM_SCRIPT environment variable. This affects all users of versions up to 1.9.23 and can lead to complete account takeover and data theft. The vulnerability persists until the environment variable is cleaned or the system is patched.

💻 Affected Systems

Products:
  • lunary-ai/lunary
Versions: Up to and including version 1.9.23
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability exists when NEXT_PUBLIC_CUSTOM_SCRIPT environment variable is set, regardless of deployment environment.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete compromise of all user accounts, exfiltration of sensitive data, malware distribution to all users, and persistent control over the application until environment variable cleanup.

🟠

Likely Case

Session hijacking, credential theft, and data exfiltration from authenticated users, leading to account compromise and potential lateral movement.

🟢

If Mitigated

Limited impact with proper environment variable access controls and monitoring, though XSS payload could still execute if variable is compromised.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires control of environment variable through deployment process or server compromise, but payload execution affects all users without authentication.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.9.25

Vendor Advisory: https://github.com/lunary-ai/lunary/commit/e2e43e88cecf742bacb639ab880507bbfdfd065c

Restart Required: Yes

Instructions:

1. Update lunary to version 1.9.25 or later. 2. Restart the application. 3. Verify the fix by checking that dangerouslySetInnerHTML is no longer used for NEXT_PUBLIC_CUSTOM_SCRIPT injection.

🔧 Temporary Workarounds

Remove or Sanitize Environment Variable

all

Remove the NEXT_PUBLIC_CUSTOM_SCRIPT environment variable or implement server-side sanitization before injection.

unset NEXT_PUBLIC_CUSTOM_SCRIPT
export NEXT_PUBLIC_CUSTOM_SCRIPT=''

Implement Content Security Policy

all

Add strict CSP headers to prevent inline script execution and limit script sources.

Content-Security-Policy: script-src 'self'

🧯 If You Can't Patch

  • Implement strict access controls on environment variable management and deployment processes.
  • Monitor and audit all changes to environment variables, especially NEXT_PUBLIC_CUSTOM_SCRIPT.

🔍 How to Verify

Check if Vulnerable:

Check if version is ≤1.9.23 and inspect source code for dangerouslySetInnerHTML usage with NEXT_PUBLIC_CUSTOM_SCRIPT.

Check Version:

npm list lunary-ai/lunary or check package.json version

Verify Fix Applied:

Verify version is ≥1.9.25 and check commit e2e43e88cecf742bacb639ab880507bbfdfd065c is applied.

📡 Detection & Monitoring

Log Indicators:

  • Unexpected changes to environment variables
  • Deployment logs showing environment variable modifications
  • Application errors related to script execution

Network Indicators:

  • Unusual outbound connections from user browsers
  • Requests to unexpected domains from application pages

SIEM Query:

source="application_logs" AND ("NEXT_PUBLIC_CUSTOM_SCRIPT" OR "dangerouslySetInnerHTML")

🔗 References

📤 Share & Export