This document outlines the security measures implemented in the WL-Viz application and areas for potential improvement.
-
Input Validation
- Max iterations parameter validated (1-50 range) to prevent DoS attacks
- Type checking for all user inputs
- Graph structure validation through NetworkX
-
Error Handling
- Generic error messages to prevent information leakage
- Detailed errors only logged server-side
- Proper HTTP status codes (400, 500)
-
Secure Hashing
- SHA-256 used for deterministic color generation in WL algorithm
- Prevents hash collisions and ensures consistency across runs
-
Configuration Security
- Environment variables for debug mode and host configuration
- Default to localhost (127.0.0.1) instead of public (0.0.0.0)
- Debug mode disabled by default
-
CORS Protection
- Flask-CORS configured for controlled cross-origin requests
-
XSS Prevention
- HTML escaping utility function for user-controlled content
- Node IDs and labels escaped before insertion
- Safe DOM manipulation methods used where possible
-
Data Sanitization
- All API responses validated before rendering
- User inputs sanitized before transmission
-
Template Literals in HTML Generation
- Some innerHTML usage with template literals remains
- Mitigation: Data comes from trusted backend API
- Future: Consider migrating to a framework with safer templating (React, Vue)
-
Native prompt() Usage
- Uses browser's prompt() for node label editing
- Mitigation: Input is sanitized before use
- Future: Implement custom modal dialog
-
Graph Size Performance
- Full graph sent in each API request
- Mitigation: Typical use case involves small graphs
- Future: Implement graph caching or delta updates
-
ID Management
- Node IDs increment indefinitely without reset
- Mitigation: Acceptable for typical use cases
- Future: Implement ID recycling or UUID-based system
- SHA-256 Performance
- SHA-256 chosen over MD5 for security, even though non-cryptographic use
- Performance impact negligible for typical graph sizes (< 1000 nodes)
- Deterministic hashing required for consistent WL algorithm results
export FLASK_DEBUG=true
export FLASK_HOST=127.0.0.1
python app.py-
Use a Production WSGI Server
pip install gunicorn gunicorn -w 4 -b 127.0.0.1:5000 app:app
-
Reverse Proxy (Nginx/Apache)
- Place behind a reverse proxy for SSL/TLS
- Configure rate limiting
- Set up proper CORS policies
-
Environment Configuration
export FLASK_DEBUG=false export FLASK_HOST=127.0.0.1 export FLASK_PORT=5000
-
Additional Security Layers
- Enable HTTPS/TLS
- Implement rate limiting
- Add authentication if needed
- Configure CSP headers
- Regular dependency updates
If you discover a security vulnerability, please report it by creating a private security advisory on GitHub rather than opening a public issue.
- Last Review: 2025-11-24
- Tools Used:
- CodeQL Security Scanning
- Manual Code Review
- Flask Security Best Practices
- Status: No critical vulnerabilities identified