{"url":"http://public2.vulnerablecode.io/api/vulnerabilities/30481?format=json","vulnerability_id":"VCID-496c-t8zy-m3g2","summary":"Deserialization Code Execution\nThe JS-YAML module for Node.js contained a code execution vulnerability prior to version 2.0.5. The maintainers of JS-YAML have patched this vulnerability and, beginning in version 2.1.0, have provided a safeLoad method for parsing YAML. Developers that use this module should make sure they have upgraded and should strongly consider porting their code to use the new safeLoad method.\n\n### Details\nThe module allowed code execution due to a custom data-type that it defined and parsed called !!js/function. The way it would parse the data was to create a new Function object in JavaScript based on the input, which is equivalent to calling eval on the input:\n\n```\nfunction resolveJavascriptFunction(object /*, explicit*/) {\n  /*jslint evil:true*/\n  var func;\n\n  try {\n    func = new Function('return ' + object);\n    return func();\n  } catch (error) {\n    return NIL;\n  }\n}\n```\nThat meant the code snippet below, when run, would execute code instead of simply defining a function:\n\n```\nvar yaml = require('js-yaml');\n\nx = \"test: !!js/function > \\n  \\\nfunction f() { \\n    \\\nconsole.log(1); \\n  \\\n}();\"\n\nyaml.load(x);\n```","aliases":[{"alias":"CVE-2013-4660"}],"fixed_packages":[{"url":"http://public2.vulnerablecode.io/api/packages/6509?format=json","purl":"pkg:npm/js-yaml@2.0.5","is_vulnerable":false,"affected_by_vulnerabilities":[],"resource_url":"http://public2.vulnerablecode.io/packages/pkg:npm/js-yaml@2.0.5"}],"affected_packages":[],"references":[{"reference_url":"https://nealpoole.com/blog/2013/06/code-execution-via-yaml-in-js-yaml-nodejs-module/","reference_id":"","reference_type":"","scores":[],"url":"https://nealpoole.com/blog/2013/06/code-execution-via-yaml-in-js-yaml-nodejs-module/"},{"reference_url":"https://nealpoole.com/blog/2013/06/code-execution-via-yaml-in-js-yaml-nodejs-module/)","reference_id":"","reference_type":"","scores":[{"value":"6.5","scoring_system":"cvssv3","scoring_elements":""}],"url":"https://nealpoole.com/blog/2013/06/code-execution-via-yaml-in-js-yaml-nodejs-module/)"},{"reference_url":"https://github.com/nodejs/security-wg/blob/main/vuln/npm/16.json","reference_id":"16","reference_type":"","scores":[{"value":"6.5","scoring_system":"cvssv3","scoring_elements":""}],"url":"https://github.com/nodejs/security-wg/blob/main/vuln/npm/16.json"}],"weaknesses":[{"cwe_id":1035,"name":"OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities","description":"Weaknesses in this category are related to the A9 category in the OWASP Top Ten 2017."},{"cwe_id":20,"name":"Improper Input Validation","description":"The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly."},{"cwe_id":937,"name":"OWASP Top Ten 2013 Category A9 - Using Components with Known Vulnerabilities","description":"Weaknesses in this category are related to the A9 category in the OWASP Top Ten 2013."}],"exploits":[],"severity_range_score":"6.5 - 6.5","exploitability":null,"weighted_severity":null,"risk_score":null,"resource_url":"http://public2.vulnerablecode.io/vulnerabilities/VCID-496c-t8zy-m3g2"}