The Math2Visual backend includes optional ClamAV antivirus scanning with graceful fallback. The system works perfectly without ClamAV installed, but you can enable virus scanning for enhanced security.
- ✅ Content-based validation: Always active (XSS protection, malicious script detection)
- ❌ ClamAV antivirus scanning: Not installed (graceful fallback active)
- 🔧 Fallback behavior: System assumes files are clean when ClamAV unavailable
- Enhanced security: Detect known malware patterns in uploaded SVG files
- Compliance: Meet security requirements for file upload systems
- Defense in depth: Additional layer beyond content validation
Ubuntu/Debian:
sudo apt update
sudo apt install clamav clamav-daemonCentOS/RHEL:
sudo yum install clamav clamav-scanner clamav-scanner-systemd
# or on newer versions:
sudo dnf install clamav clamav-scanner clamav-scanner-systemdmacOS (Homebrew):
brew install clamavpip install pyclamdStart and enable the daemon:
sudo systemctl start clamav-daemon
sudo systemctl enable clamav-daemonUpdate virus definitions:
sudo /etc/init.d/clamav-freshclam stop
sudo freshclam
sudo /etc/init.d/clamav-freshclam startCheck if ClamAV is working:
# Test ClamAV directly
echo "This is a test" | clamscan -
# Test via our API
curl http://localhost:5000/api/antivirus/statusExpected response when working:
{
"success": true,
"antivirus": {
"scanner_module_available": true,
"scanner_available": true,
"clamav_version": "ClamAV 0.103.x",
"connection_method": "socket",
"connection_target": "/var/run/clamav/clamd.ctl"
}
}The system automatically tries these socket paths:
/var/run/clamav/clamd.ctl(Debian/Ubuntu)/var/run/clamd.scan/clamd.sock(CentOS/RHEL)/tmp/clamd.socket(Custom/development)
If socket connection fails, it tries network connection to localhost:3310.
1. Permission denied accessing socket:
sudo usermod -a -G clamav your_username
# Then restart your application2. ClamAV daemon not running:
sudo systemctl status clamav-daemon
sudo systemctl start clamav-daemon3. Outdated virus definitions:
sudo freshclam
sudo systemctl restart clamav-daemonCheck system status:
# Via our API
curl http://localhost:5000/api/antivirus/status | python -m json.tool
# Direct ClamAV check
sudo clamdscan --version- Graceful degradation: If ClamAV fails, uploads still work (security through content validation)
- Performance: ClamAV scanning adds ~100-500ms per file
- Updates: Keep virus definitions current with
freshclam - Logs: ClamAV logs to syslog; check
/var/log/clamav/
The system provides robust security without ClamAV through:
- ✅ Filename validation (path traversal prevention)
- ✅ File size and type validation
- ✅ SVG structure validation
- ✅ Malicious content pattern detection
- ✅ XSS and script injection prevention
- ✅ CSS injection protection
ClamAV adds an additional layer for known malware signatures.