CVE-2017-20160 (published 2022-12-31T20:15Z)

A vulnerability was found in flitto express-param up to 0.x. It has been classified as critical. This affects an unknown part of the file lib/fetchParams.js. The manipulation leads to improper handling of extra parameters. It is possible to initiate the attack remotely. Upgrading to version 1.0.0 is able to address this issue. The identifier of the patch is db94f7391ad0a16dcfcba8b9be1af385b25c42db. It is recommended to upgrade the affected component. The identifier VDB-217149 was assigned to this vulnerability.

CVSS v3 base score: 9.8, CRITICAL (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: NVD-CWE-Other
cwe_name: Other
description: NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
extended_description: Insufficient Information

Fix information:
repo_url: https://github.com/flitto/express-param
commit_details: repo_url: https://github.com/flitto/express-param
author: dahyun
author_date: 2017-03-02 16:47:06+09:00
msg: feat: Improve fetchParams

* Add geo-info to extra options
* protect against HTTP Parameter Pollution attacks
* Add int, float type options for parameters
repository: repo_url: https://github.com/flitto/express-param
repo_name: flitto/express-param
description: fetch express request parameters.
repo_language: JavaScript
owner: flitto
file_changes: filename: fetchParams.js
change_type: ModificationType.MODIFY
diff: @@ -8,15 +8,21 @@ var TYPE_DELIMETER = ':'
   , extraOption;
 
 function getValue(req, keyName) {
+  var value;
+
   if (req.params && req.params[keyName] !== undefined) {
-    return req.params[keyName];
+    value = req.params[keyName];
   } else if (req.body && req.body[keyName] !== undefined) {
-    return req.body[keyName];
+    value = req.body[keyName];
   } else if (req.query && req.query[keyName] !== undefined) {
-    return req.query[keyName];
-  } else {
-    return undefined;
+    value = req.query[keyName];
+  }
+
+  if (Array.isArray(value)) {
+    value = value[value.length - 1];
   }
+
+  return value;
 }
 
 function getPath(req, keyName) {
@@ -117,6 +123,17 @@ function getOptionalParams(req, option_expressions) {
 
     val = getFunc(req, key);
 
+    var typeMap = {
+      int: parseInt,
+      float: parseFloat,
+      number: parseFloat
+    };
+
+    var idx = Object.keys(typeMap).indexOf(keyInfo.type);
+    if (idx >= 0) {
+      options[key] = typeMap[keyInfo.type](val);
+    }
+
     if (keyInfo.type === 'number') {
       if (val !== undefined && val !== '')
         options[key] = parseFloat(val);
@@ -178,7 +195,7 @@ function requiredParameter(req, required_expressions) {
     , key
     , val;
 
-  for (var i = 0, li = required_expressions.length; i <li ; i++) {
+  for (var i = 0, li = required_expressions.length; i < li; i++) {
     var keyInfo;
     try {
       keyInfo = getRequiredKeyInfo(required_expressions[i]);
@@ -196,13 +213,28 @@ function requiredParameter(req, required_expressions) {
       getFunc = getValue;
 
     val = getFunc(req, key);
-    if (keyInfo.type === 'number') {
+
+    var typeMap = {
+      int: parseInt,
+      float: parseFloat,
+      number: parseFloat
+    };
+
+    var idx = Object.keys(typeMap).indexOf(keyInfo.type);
+    if (idx >= 0) {
       if (isNaN(val)) {
         err = new Error('The parameter value is not a number : ' + key);
         err.code = 400;
         break;
       }
-      options[key] = parseFloat(val);
+
+      if (keyInfo.type == 'int' && !_.isSafeInteger(val)) {
+        err = new Error('The parameter value is not a integer : ' + key);
+        err.code = 400;
+        break;
+      }
+
+      options[key] = typeMap[keyInfo.type](val);
     } else {
       options[key] = val;
     }

programming_language: JavaScript