Skip to content

A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.

9.3 KB
Raw Blame
package opensuite.core;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * The names behind a finding's classification numbers: the CWE entry it is an
 * instance of and the OWASP Top 10 categories it falls under. Each line reads
 * as the standard's own title, with where to read about it.
 */
public final class Classifications {
    private Classifications() {}

    /** One classification: its label and the page that describes it. */
    public record Entry(String label, String link) {}

    private static final Map<Integer, String> CWE = new LinkedHashMap<>();
    private static void c(int id, String name) { CWE.put(id, name); }
    static {
        c(16, "Configuration");
        c(20, "Improper Input Validation");
        c(22, "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')");
        c(78, "Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')");
        c(79, "Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')");
        c(89, "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')");
        c(90, "Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection')");
        c(91, "XML Injection (aka Blind XPath Injection)");
        c(93, "Improper Neutralization of CRLF Sequences ('CRLF Injection')");
        c(94, "Improper Control of Generation of Code ('Code Injection')");
        c(97, "Improper Neutralization of Server-Side Includes (SSI) Within a Web Page");
        c(98, "Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion')");
        c(113, "Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Request/Response Splitting')");
        c(116, "Improper Encoding or Escaping of Output");
        c(119, "Improper Restriction of Operations within the Bounds of a Memory Buffer");
        c(120, "Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')");
        c(134, "Use of Externally-Controlled Format String");
        c(190, "Integer Overflow or Wraparound");
        c(200, "Exposure of Sensitive Information to an Unauthorized Actor");
        c(201, "Insertion of Sensitive Information Into Sent Data");
        c(205, "Observable Behavioral Discrepancy");
        c(209, "Generation of Error Message Containing Sensitive Information");
        c(215, "Insertion of Sensitive Information Into Debugging Code");
        c(264, "Permissions, Privileges, and Access Controls");
        c(284, "Improper Access Control");
        c(285, "Improper Authorization");
        c(287, "Improper Authentication");
        c(295, "Improper Certificate Validation");
        c(311, "Missing Encryption of Sensitive Data");
        c(312, "Cleartext Storage of Sensitive Information");
        c(315, "Cleartext Storage of Sensitive Information in a Cookie");
        c(319, "Cleartext Transmission of Sensitive Information");
        c(326, "Inadequate Encryption Strength");
        c(327, "Use of a Broken or Risky Cryptographic Algorithm");
        c(330, "Use of Insufficiently Random Values");
        c(345, "Insufficient Verification of Data Authenticity");
        c(346, "Origin Validation Error");
        c(352, "Cross-Site Request Forgery (CSRF)");
        c(359, "Exposure of Private Personal Information to an Unauthorized Actor");
        c(384, "Session Fixation");
        c(388, "Error Handling");
        c(400, "Uncontrolled Resource Consumption");
        c(425, "Direct Request ('Forced Browsing')");
        c(434, "Unrestricted Upload of File with Dangerous Type");
        c(436, "Interpretation Conflict");
        c(444, "Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')");
        c(472, "External Control of Assumed-Immutable Web Parameter");
        c(497, "Exposure of Sensitive System Information to an Unauthorized Control Sphere");
        c(502, "Deserialization of Untrusted Data");
        c(523, "Unprotected Transport of Credentials");
        c(524, "Use of Cache Containing Sensitive Information");
        c(525, "Use of Web Browser Cache Containing Sensitive Information");
        c(530, "Exposure of Backup File to an Unauthorized Control Sphere");
        c(538, "Insertion of Sensitive Information into Externally-Accessible File or Directory");
        c(540, "Inclusion of Sensitive Information in Source Code");
        c(541, "Inclusion of Sensitive Information in an Include File");
        c(548, "Exposure of Information Through Directory Listing");
        c(565, "Reliance on Cookies without Validation and Integrity Checking");
        c(598, "Use of GET Request Method With Sensitive Query Strings");
        c(601, "URL Redirection to Untrusted Site ('Open Redirect')");
        c(611, "Improper Restriction of XML External Entity Reference");
        c(613, "Insufficient Session Expiration");
        c(614, "Sensitive Cookie in HTTPS Session Without 'Secure' Attribute");
        c(615, "Inclusion of Sensitive Information in Source Code Comments");
        c(639, "Authorization Bypass Through User-Controlled Key");
        c(642, "External Control of Critical State Data");
        c(643, "Improper Neutralization of Data within XPath Expressions ('XPath Injection')");
        c(644, "Improper Neutralization of HTTP Headers for Scripting Syntax");
        c(693, "Protection Mechanism Failure");
        c(776, "Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion')");
        c(829, "Inclusion of Functionality from Untrusted Control Sphere");
        c(917, "Improper Neutralization of Special Elements used in an Expression Language Statement ('Expression Language Injection')");
        c(918, "Server-Side Request Forgery (SSRF)");
        c(933, "OWASP Top Ten 2013 Category A5 - Security Misconfiguration");
        c(942, "Permissive Cross-domain Policy with Untrusted Domains");
        c(943, "Improper Neutralization of Special Elements in Data Query Logic");
        c(1004, "Sensitive Cookie Without 'HttpOnly' Flag");
        c(1021, "Improper Restriction of Rendered UI Layers or Frames");
        c(1022, "Use of Web Link to Untrusted Target with window.opener Access");
        c(1104, "Use of Unmaintained Third Party Components");
        c(1275, "Sensitive Cookie with Improper SameSite Attribute");
        c(1336, "Improper Neutralization of Special Elements Used in a Template Engine");
        c(1395, "Dependency on Vulnerable Third-Party Component");
    }

    private static final String[][] TOP10 = {
        {"2021_A01", "A01:2021 Broken Access Control", "https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},
        {"2021_A02", "A02:2021 Cryptographic Failures", "https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},
        {"2021_A03", "A03:2021 Injection", "https://owasp.org/Top10/A03_2021-Injection/"},
        {"2021_A04", "A04:2021 Insecure Design", "https://owasp.org/Top10/A04_2021-Insecure_Design/"},
        {"2021_A05", "A05:2021 Security Misconfiguration", "https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},
        {"2021_A06", "A06:2021 Vulnerable and Outdated Components", "https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},
        {"2021_A07", "A07:2021 Identification and Authentication Failures", "https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},
        {"2021_A08", "A08:2021 Software and Data Integrity Failures", "https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},
        {"2021_A09", "A09:2021 Security Logging and Monitoring Failures", "https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},
        {"2021_A10", "A10:2021 Server-Side Request Forgery (SSRF)", "https://owasp.org/Top10/A10_2021-Server-Side_Request_Forgery_%28SSRF%29/"},
    };

    /** The CWE entry's title, or "" when the number is not one this table knows. */
    public static String cweName(int id) { return CWE.getOrDefault(id, ""); }

    /** The classifications of a finding, most specific first: its CWE entry, then its OWASP Top 10 categories. */
    public static List<Entry> of(Issue i) {
        List<Entry> out = new ArrayList<>();
        if (i == null) return out;
        if (i.cwe() > 0) {
            String name = cweName(i.cwe());
            out.add(new Entry("CWE-" + i.cwe() + (name.isEmpty() ? "" : ": " + name),
                    "https://cwe.mitre.org/data/definitions/" + i.cwe() + ".html"));
        }
        if (i.tags() != null) {
            for (String[] t : TOP10) {
                for (String tag : i.tags()) {
                    if (tag != null && tag.toUpperCase(java.util.Locale.ROOT).contains("OWASP_" + t[0])) {
                        out.add(new Entry("OWASP Top 10 " + t[1], t[2]));
                        break;
                    }
                }
            }
        }
        return out;
    }

    /** The lines of a finding's references that are links, in order and without repeats. */
    public static List<String> references(Issue i) {
        List<String> out = new ArrayList<>();
        if (i == null || i.references() == null) return out;
        for (String line : i.references().split("\\R")) {
            String l = line.trim();
            if (!l.isEmpty() && !out.contains(l)) out.add(l);
        }
        return out;
    }
}