""" Banner / version-to-vulnerability mapping module. Analyses software version strings extracted during reconnaissance and maps them to known CVEs, end-of-life status, and security advisories. Every CVE entry in KNOWN_VULNS references a real, publicly-documented vulnerability. """ from dataclasses import dataclass, field from typing import Dict, List, Optional, Tuple # --------------------------------------------------------------------------- # Data classes # --------------------------------------------------------------------------- @dataclass class BannerFinding: """A single vulnerability or advisory derived from a version string.""" software: str version: str cve: str vuln_type: str severity: str # critical | high | medium | low description: str source: str # e.g. "banner_analyzer:known_vulns" # --------------------------------------------------------------------------- # Severity ordering (lower index == more severe) # --------------------------------------------------------------------------- _SEVERITY_ORDER = {"critical": 0, "high": 1, "medium": 2, "low": 3} # --------------------------------------------------------------------------- # BannerAnalyzer # --------------------------------------------------------------------------- class BannerAnalyzer: """Map detected software versions to known vulnerabilities.""" # Each key is "software/version" (lowercase). Prefix matching is also # attempted so "apache/2.4.49" matches entries keyed as "apache/2.4.49". KNOWN_VULNS: Dict[str, Dict] = { # ---- Apache HTTPD ------------------------------------------------ "apache/2.4.49": { "cve": "CVE-2021-41773", "type": "path_traversal", "severity": "critical", "description": "Path traversal and file disclosure via crafted URI in Apache 2.4.49.", }, "apache/2.4.50": { "cve": "CVE-2021-42013", "type": "rce", "severity": "critical", "description": "Remote code execution via path traversal bypass in Apache 2.4.50 (incomplete fix for CVE-2021-41773).", }, "apache/2.4.51": { "cve": "CVE-2021-44790", "type": "buffer_overflow", "severity": "critical", "description": "Buffer overflow in mod_lua multipart parser in Apache <= 2.4.51.", }, "apache/2.4.48": { "cve": "CVE-2021-33193", "type": "http_request_smuggling", "severity": "high", "description": "HTTP/2 request smuggling via crafted method in Apache 2.4.48.", }, "apache/2.4.46": { "cve": "CVE-2020-35452", "type": "stack_overflow", "severity": "high", "description": "Stack overflow via crafted Digest nonce in mod_auth_digest (Apache <= 2.4.46).", }, "apache/2.4.43": { "cve": "CVE-2020-9490", "type": "dos", "severity": "high", "description": "Push Diary crash via crafted Cache-Digest header in Apache 2.4.43.", }, "apache/2.4.41": { "cve": "CVE-2020-1927", "type": "open_redirect", "severity": "medium", "description": "Open redirect in mod_rewrite when the URL starts with multiple slashes.", }, "apache/2.4.39": { "cve": "CVE-2019-10098", "type": "open_redirect", "severity": "medium", "description": "mod_rewrite self-referential redirect causing open redirect.", }, # ---- Nginx ------------------------------------------------------- "nginx/1.17.9": { "cve": "CVE-2021-23017", "type": "dns_resolver_rce", "severity": "critical", "description": "Off-by-one error in nginx DNS resolver allows RCE via crafted DNS response.", }, "nginx/1.18.0": { "cve": "CVE-2021-23017", "type": "dns_resolver_rce", "severity": "critical", "description": "Nginx <= 1.20.0 DNS resolver off-by-one heap write (requires resolver directive).", }, "nginx/1.14.0": { "cve": "CVE-2019-9511", "type": "dos", "severity": "high", "description": "HTTP/2 Data Dribble DoS in nginx < 1.16.1 / 1.17.3.", }, "nginx/1.16.0": { "cve": "CVE-2019-9513", "type": "dos", "severity": "high", "description": "HTTP/2 Resource Loop DoS in nginx < 1.16.1 / 1.17.3.", }, "nginx/1.13.2": { "cve": "CVE-2017-7529", "type": "information_disclosure", "severity": "medium", "description": "Integer overflow in range filter allows memory disclosure in nginx < 1.13.3.", }, # ---- PHP --------------------------------------------------------- "php/7.4.21": { "cve": "CVE-2021-21706", "type": "path_traversal", "severity": "medium", "description": "ZipArchive::extractTo path traversal on Windows in PHP < 7.4.27.", }, "php/7.4.29": { "cve": "CVE-2022-31625", "type": "use_after_free", "severity": "critical", "description": "Use-after-free in pg_query_params() in PHP < 7.4.30.", }, "php/8.0.0": { "cve": "CVE-2021-21702", "type": "dos", "severity": "high", "description": "Null pointer dereference in SoapClient in PHP 8.0.0.", }, "php/8.0.12": { "cve": "CVE-2021-21707", "type": "information_disclosure", "severity": "medium", "description": "URL validation bypass via null bytes in PHP < 8.0.14.", }, "php/8.1.0": { "cve": "CVE-2022-31626", "type": "buffer_overflow", "severity": "critical", "description": "Buffer overflow in mysqlnd/pdo_mysql password handling in PHP < 8.1.8.", }, "php/8.1.2": { "cve": "CVE-2022-31628", "type": "dos", "severity": "medium", "description": "phar archive infinite loop denial-of-service in PHP < 8.1.10.", }, "php/8.1.12": { "cve": "CVE-2022-37454", "type": "buffer_overflow", "severity": "critical", "description": "SHA-3 buffer overflow (XKCP) in PHP < 8.1.13.", }, "php/7.4.3": { "cve": "CVE-2020-7068", "type": "use_after_free", "severity": "high", "description": "Use-after-free in PHAR parsing in PHP < 7.4.10.", }, # ---- WordPress --------------------------------------------------- "wordpress/5.6": { "cve": "CVE-2021-29447", "type": "xxe", "severity": "high", "description": "XXE via media file upload (iXML) in WordPress 5.6-5.7.", }, "wordpress/5.7": { "cve": "CVE-2021-29447", "type": "xxe", "severity": "high", "description": "XXE via media file upload (iXML) in WordPress 5.6-5.7.", }, "wordpress/5.0": { "cve": "CVE-2019-8942", "type": "rce", "severity": "critical", "description": "Authenticated RCE via crafted post meta in WordPress < 5.0.1.", }, "wordpress/5.4": { "cve": "CVE-2020-28032", "type": "object_injection", "severity": "critical", "description": "PHP Object Injection via SimpleXML deserialization in WordPress < 5.5.2.", }, "wordpress/6.0": { "cve": "CVE-2022-43504", "type": "csrf", "severity": "medium", "description": "CSRF token verification bypass in WordPress < 6.0.3.", }, "wordpress/6.1": { "cve": "CVE-2023-22622", "type": "information_disclosure", "severity": "medium", "description": "Unauthenticated blind SSRF via DNS rebinding in wp-cron (WordPress < 6.1.1).", }, "wordpress/6.2": { "cve": "CVE-2023-38000", "type": "xss", "severity": "medium", "description": "Stored XSS via block editor in WordPress < 6.3.2.", }, # ---- jQuery ------------------------------------------------------ "jquery/1.12.4": { "cve": "CVE-2020-11022", "type": "xss", "severity": "medium", "description": "XSS via passing HTML from untrusted source to jQuery DOM manipulation in jQuery < 3.5.0.", }, "jquery/2.2.4": { "cve": "CVE-2020-11022", "type": "xss", "severity": "medium", "description": "XSS via passing HTML from untrusted source to jQuery DOM manipulation in jQuery < 3.5.0.", }, "jquery/3.4.1": { "cve": "CVE-2020-11022", "type": "xss", "severity": "medium", "description": "XSS in htmlPrefilter regex in jQuery < 3.5.0.", }, "jquery/3.5.0": { "cve": "CVE-2020-11023", "type": "xss", "severity": "medium", "description": "XSS when passing