FastNetMon Community Edition through 1.2.9 contains an OS command injection vulnerability in the MikroTik router integration plugin. The _log() function in src/mikrotik_plugin/fastnetmon_mikrotik.php (lines 107-108) constructs shell commands by concatenating the $msg parameter directly into exec() calls: exec("echo `date` \"- {FASTNETMON] - " . $msg . " \" >> " . $FILE_LOG_TMP). This is identical in pattern to the Juniper plugin vulnerability. The $msg variable contains unsanitized attack data from command-line arguments. An attacker who can influence argv[] values can inject arbitrary shell commands. The fix is to replace exec() with file_put_contents() or use escapeshellarg().
FastNetMon Community Edition versions through 1.2.9 contain a critical OS command injection vulnerability in the MikroTik router integration plugin. The _log() function unsafely concatenates user-controlled input directly into shell commands via exec(), allowing attackers to execute arbitrary commands. This vulnerability mirrors a previously disclosed Juniper plugin flaw and poses significant risk to network monitoring infrastructure in Saudi organizations.
IMMEDIATE ACTIONS:
1. Identify all FastNetMon Community Edition deployments with MikroTik plugin enabled (check /etc/fastnetmon/fastnetmon.conf for mikrotik_plugin setting)
2. Disable MikroTik plugin immediately: comment out 'mikrotik_plugin = on' in configuration
3. Review FastNetMon process logs for suspicious command patterns or unexpected process execution
4. Audit MikroTik router access logs for unauthorized commands executed during vulnerability window
PATCHING GUIDANCE:
1. Monitor Pavel Odintsov's FastNetMon GitHub repository for patched version (upgrade to 1.3.0 or later when available)
2. No official patch currently available; implement compensating controls immediately
3. Subscribe to FastNetMon security advisories at https://github.com/pavel-odintsov/fastnetmon/security
COMPENSATING CONTROLS:
1. Replace exec() calls with file_put_contents() for logging: file_put_contents($FILE_LOG_TMP, date('Y-m-d H:i:s') . ' - [FASTNETMON] - ' . escapeshellarg($msg) . PHP_EOL, FILE_APPEND)
2. If patching unavailable, use escapeshellarg() on all $msg variables: exec('echo `date` "- [FASTNETMON] - ' . escapeshellarg($msg) . '" >> ' . escapeshellarg($FILE_LOG_TMP))
3. Implement strict input validation on command-line arguments before passing to FastNetMon
4. Run FastNetMon with minimal privileges (dedicated non-root user)
5. Implement Web Application Firewall (WAF) rules to block command injection patterns in FastNetMon API calls
DETECTION RULES:
1. Monitor for exec() calls with unsanitized variables in /src/mikrotik_plugin/fastnetmon_mikrotik.php
2. Alert on FastNetMon process spawning unexpected child processes (bash, sh, cmd.exe)
3. Monitor system logs for commands executed by FastNetMon user containing shell metacharacters (|, ;, &, $(), `)
4. IDS/IPS signature: detect patterns like 'echo.*date.*FASTNETMON.*exec' in FastNetMon configuration or logs
5. File integrity monitoring on fastnetmon_mikrotik.php to detect unauthorized modifications
الإجراءات الفورية:
1. تحديد جميع نشرات FastNetMon Community Edition مع تفعيل مكون MikroTik (تحقق من /etc/fastnetmon/fastnetmon.conf)
2. تعطيل مكون MikroTik فوراً: علّق 'mikrotik_plugin = on' في الإعدادات
3. مراجعة سجلات عملية FastNetMon للبحث عن أنماط أوامر مريبة
4. تدقيق سجلات وصول جهاز MikroTik للأوامر غير المصرح بها
إرشادات التصحيح:
1. راقب مستودع FastNetMon على GitHub للإصدار المصحح (ترقية إلى 1.3.0 أو أحدث عند توفره)
2. لا يوجد تصحيح رسمي حالياً؛ طبّق الضوابط البديلة فوراً
3. اشترك في تنبيهات أمان FastNetMon
الضوابط البديلة:
1. استبدل استدعاءات exec() بـ file_put_contents() للتسجيل
2. استخدم escapeshellarg() على جميع متغيرات $msg
3. طبّق التحقق الصارم من صحة المدخلات على معاملات سطر الأوامر
4. قم بتشغيل FastNetMon بامتيازات محدودة (مستخدم غير جذر)
5. طبّق قواعد جدار الحماية لحجب أنماط حقن الأوامر
قواعد الكشف:
1. راقب استدعاءات exec() بمتغيرات غير معقمة في ملف MikroTik plugin
2. تنبيه عند توليد عملية FastNetMon لعمليات فرعية غير متوقعة
3. راقب سجلات النظام للأوامر التي تحتوي على أحرف shell metacharacters
4. قواعس IDS/IPS للكشف عن أنماط حقن الأوامر
5. مراقبة سلامة الملفات على fastnetmon_mikrotik.php