Overview
The Risk Analysis System provides automated security risk assessment based on audit findings. TheRiskAnalyzer evaluates vulnerabilities, exposed services, and network configuration to calculate an overall risk score and classify targets into four severity levels.
RiskAnalyzer Class
The risk analyzer is implemented as a static utility class inservices/risk_analyzer.py:
services/risk_analyzer.py
Scoring Algorithm
The risk score is calculated using a weighted multi-factor algorithm that considers three primary dimensions:1. Critical Vulnerabilities (Weight: 30 points each)
The most significant risk factor is the presence of critical vulnerabilities.- 0 critical vulns: +0 points
- 1 critical vuln: +30 points (immediately elevates to HIGH risk minimum)
- 2 critical vulns: +60 points (immediately CRITICAL risk)
- 3+ critical vulns: +90+ points (maximum CRITICAL risk)
- SQL injection with database access
- Remote code execution vulnerabilities
- Authentication bypass
- Exposed credentials in plaintext
- Unpatched vulnerabilities with known exploits
2. Dangerous Port Exposure (Weight: 8 points each)
Exposed network services increase the attack surface.| Port | Service | Risk Reason |
|---|---|---|
| 21 | FTP | Unencrypted file transfer, often misconfigured |
| 22 | SSH | Brute-force target, lateral movement vector |
| 23 | Telnet | Unencrypted remote access (extreme risk) |
| 25 | SMTP | Email relay abuse, spam vector |
| 53 | DNS | DNS amplification attacks, zone transfer leaks |
| 80 | HTTP | Web vulnerabilities, unencrypted communication |
| 110 | POP3 | Unencrypted email access |
| 143 | IMAP | Unencrypted email access |
| 443 | HTTPS | Web application vulnerabilities |
| 993 | IMAPS | Encrypted email (lower risk but still attack surface) |
| 995 | POP3S | Encrypted email (lower risk but still attack surface) |
| 3306 | MySQL | Direct database access, data exfiltration |
| 5432 | PostgreSQL | Direct database access, data exfiltration |
| 5900 | VNC | Remote desktop access, often weak passwords |
- 1 dangerous port (e.g., only HTTPS): +8 points
- 3 dangerous ports (SSH, HTTP, MySQL): +24 points
- 6 dangerous ports (SSH, HTTP, HTTPS, MySQL, FTP, Telnet): +48 points
3. HTTP Service Exposure (Weight: 10 points each)
Web services represent high-value attack targets.http(port 80)https(port 443)http-proxy(ports 8080, 3128)http-alt(port 8008)- Any service containing “http” in its name
- 1 HTTP service: +10 points
- 2 HTTP services (HTTP + HTTPS): +20 points
- 3+ HTTP services: +30+ points
HTTP services receive additional weight beyond the dangerous ports score because web applications are the most common attack vector in modern networks.
Risk Level Classification
The final risk level is determined by score thresholds:Risk Level Definitions
🔴 CRITICAL
Score: 60-100+Immediate action required. System is highly vulnerable with multiple critical issues or excessive exposure.Typical conditions:
- 2+ critical vulnerabilities
- 1 critical vuln + 4+ dangerous ports
- 8+ dangerous ports exposed
- Database + web + SSH all exposed with vulns
🟠 HIGH
Score: 30-59Significant security concerns requiring prompt remediation. Single critical vulnerability or multiple high-severity issues.Typical conditions:
- 1 critical vulnerability
- 4-7 dangerous ports exposed
- Multiple HIGH severity vulnerabilities
- Database directly accessible from network
🟡 MEDIUM
Score: 10-29Moderate risk with some security gaps. Should be addressed in next security sprint.Typical conditions:
- 2-3 dangerous ports exposed
- Web services without critical vulnerabilities
- MEDIUM severity vulnerabilities present
- Standard web server configuration
🟢 LOW
Score: 0-9Minimal security concerns. System follows security best practices.Typical conditions:
- 0-1 dangerous ports exposed
- No exploitable vulnerabilities found
- Services properly configured
- Only encrypted protocols used
Real Scoring Examples
Example 1: Vulnerable Web Server
Configuration:- Ports: 22 (SSH), 80 (HTTP), 443 (HTTPS), 3306 (MySQL)
- Vulnerabilities: SQL injection (CRITICAL)
Example 2: Hardened Server
Configuration:- Ports: 443 (HTTPS) only
- Vulnerabilities: None
Example 3: DVWA Lab Environment
Configuration:- Ports: 22 (SSH), 80 (HTTP), 3306 (MySQL)
- Vulnerabilities:
- SQL injection (CRITICAL)
- WordPress weak passwords (HIGH)
- Outdated Apache (MEDIUM)
Example 4: Minimal Exposure
Configuration:- Ports: None (firewall blocking all)
- Vulnerabilities: None
Integration with Audit Engine
The risk analyzer runs as Phase 6 of the audit workflow:audit_engine.py
- Phases 1-4 populate
host.vulnerabilitiesandhost.ports_open - Phase 6 analyzes accumulated data
host.risk_levelis set- PDF report uses risk level for color coding and recommendations
Usage in Risk-Based Decision Making
The risk level drives automated decision-making throughout the framework:Report Color Coding
reporter/pdf_generator.py
Prioritized Recommendations
CRITICAL and HIGH risk systems receive more urgent recommendations in the PDF report.Automated Alerting
Extend the analyzer for automated notifications:Customizing the Risk Algorithm
Modifyservices/risk_analyzer.py to adjust weights and thresholds:
Adjusting Weights
Custom Dangerous Ports
Modified Thresholds
Vulnerability Risk Classification
Vulnerabilities are classified during discovery:services/sqlmap_inject.py
| Vulnerability Type | Typical Risk Level |
|---|---|
| SQL Injection | CRITICAL |
| Remote Code Execution | CRITICAL |
| Authentication Bypass | CRITICAL |
| Weak Credentials (brute-forced) | HIGH |
| Outdated Software with Known Exploits | HIGH |
| Information Disclosure | MEDIUM |
| Missing Security Headers | LOW |
Limitations and Considerations
Best Practices
- Combine with manual review: Use automated risk scores as input, not final decision
- Context matters: CRITICAL risk on a test server differs from production database
- Trend analysis: Track risk scores over time to measure security posture improvement
- Validate findings: Confirm vulnerabilities before taking drastic action
- Customize weights: Adjust algorithm to match your organization’s risk tolerance
Future Enhancements
Potential improvements to the risk analysis system:- CVSS integration: Use standard CVSS scores for vulnerability weighting
- Asset tagging: Multiply risk scores based on asset criticality
- Exploitability assessment: Weight by availability of public exploits
- Compensating controls: Reduce score if WAF, IDS, or other defenses detected
- Compliance mapping: Flag specific compliance violations (PCI-DSS, HIPAA)
- Machine learning: Train models on historical audit data for improved accuracy