We have identified a bug in Node.js error handling where "Maximum call stack size exceeded" errors become uncatchable when `async_hooks.createHook()` is enabled. Instead of reaching `process.on('uncaughtException')`, the process terminates, making the crash unrecoverable. Applications that rely on `AsyncLocalStorage` (v22, v20) or `async_hooks.createHook()` (v24, v22, v20) become vulnerable to denial-of-service crashes triggered by deep recursion under specific conditions.
CVE-2025-59466 is a denial-of-service vulnerability in Node.js affecting versions 20, 22, and 24 when async_hooks or AsyncLocalStorage are enabled. The vulnerability causes uncatchable stack overflow errors that terminate the process instead of triggering exception handlers, making applications unrecoverable. This impacts any Node.js application using async context tracking, which is increasingly common in modern Saudi enterprise applications.
IMMEDIATE ACTIONS:
1. Identify all Node.js applications using async_hooks.createHook() or AsyncLocalStorage (check package.json dependencies and code for these APIs)
2. Implement process monitoring and auto-restart mechanisms (PM2, systemd, Docker health checks) as temporary mitigation
3. Add request depth/recursion limits in application code to prevent stack exhaustion
PATCHING GUIDANCE:
1. Upgrade Node.js to patched versions: v20.x (20.13.0+), v22.x (22.3.0+), v24.x (24.1.0+)
2. Test patches in staging environment before production deployment
3. Coordinate with development teams to validate async_hooks functionality post-patch
COMPENSATING CONTROLS (if immediate patching not possible):
1. Disable async_hooks.createHook() and AsyncLocalStorage if not critical to application logic
2. Implement request timeout and recursion depth limits at application level
3. Deploy WAF rules to detect and block requests with excessive nesting/recursion patterns
4. Use reverse proxy (nginx) to limit request complexity and depth
DETECTION RULES:
1. Monitor for unexpected Node.js process crashes with 'Maximum call stack size exceeded' in logs
2. Alert on rapid process restarts (>5 restarts in 5 minutes)
3. Track error logs for uncaught exceptions that bypass process.on('uncaughtException')
4. Monitor CPU and memory spikes preceding process termination
الإجراءات الفورية:
1. تحديد جميع تطبيقات Node.js التي تستخدم async_hooks.createHook() أو AsyncLocalStorage (تحقق من package.json والكود)
2. تنفيذ آليات مراقبة العمليات وإعادة التشغيل التلقائي (PM2، systemd، Docker health checks) كتخفيف مؤقت
3. إضافة حدود عمق الطلب/التكرار في كود التطبيق لمنع استنزاف المكدس
إرشادات التصحيح:
1. ترقية Node.js إلى الإصدارات المصححة: v20.x (20.13.0+)، v22.x (22.3.0+)، v24.x (24.1.0+)
2. اختبار التصحيحات في بيئة التجريب قبل نشرها في الإنتاج
3. التنسيق مع فرق التطوير للتحقق من وظائف async_hooks بعد التصحيح
الضوابط البديلة (إذا لم يكن التصحيح الفوري ممكناً):
1. تعطيل async_hooks.createHook() و AsyncLocalStorage إذا لم تكن حرجة
2. تنفيذ حدود انتظار الطلب وحدود عمق التكرار على مستوى التطبيق
3. نشر قواعد WAF للكشف عن طلبات التكرار المفرط
4. استخدام reverse proxy (nginx) لتحديد تعقيد الطلب
قواعد الكشف:
1. مراقبة أعطال عمليات Node.js غير المتوقعة مع 'Maximum call stack size exceeded'
2. تنبيهات إعادة التشغيل السريعة (>5 مرات في 5 دقائق)
3. تتبع سجلات الأخطاء للاستثناءات غير المعالجة
4. مراقبة ارتفاعات CPU والذاكرة قبل إنهاء العملية