CVE-2019-16303: Generator jhipster kotlin Remote Code Execution Vulnerability
CRITICALCVE-2019-16303 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)) affecting Generator jhipster kotlin libraries in the npm ecosystem. The issue involves jhipster kotlin using insecure source of randomness `randomstringutils` before v1.2.0. Remediation is available by upgrading affected packages to version 1.2.0.
CVE-2019-16303 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2019-16303
To remediate this vulnerability, upgrade all affected Generator jhipster kotlin dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install generator-jhipster-kotlin@1.2.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls generator-jhipster-kotlin
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2019-16303, inspect your project dependencies using npm:
npm ls generator-jhipster-kotlin
Analyze the terminal output to locate any version of Generator jhipster kotlin in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.2.0), your application is affected.
Note: The npm ls generator-jhipster-kotlin command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG), where the product uses a pseudo-random number generator (prng) in a security context, but the prng's algorithm is not cryptographically strong. In Generator jhipster kotlin, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2019-16303 Affected Generator jhipster kotlin Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
generator-jhipster-kotlin
|
npm |
< 1.2.0
|
1.2.0
|
References
Frequently Asked Questions
What is CVE-2019-16303?
Which Generator jhipster kotlin versions are affected?
What version fixes CVE-2019-16303?
Is generator-jhipster-kotlin affected?
What is the CVSS score of CVE-2019-16303?
What CWE is associated with CVE-2019-16303?
How can I check npm dependencies for CVE-2019-16303?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-j3rh-8vwq-wh84",
"modified" : "2023-01-20T18:53:25Z",
"published" : "2020-06-26T16:48:13Z",
"aliases" : [ "CVE-2019-16303" ],
"summary" : "JHipster Kotlin using insecure source of randomness `RandomStringUtils` before v1.2.0",
"details" : "JHipster Kotlin is using an insecure source of randomness to generate all of its random values. JHipster Kotlin relies upon apache commons lang3 `RandomStringUtils`.\n\nFrom the documentation:\n\n> Caveat: Instances of Random, upon which the implementation of this class relies, are not cryptographically secure.\n> \\- https://commons.apache.org/proper/commons-lang/javadocs/api-3.9/org/apache/commons/lang3/RandomStringUtils.html\n\nHere are the examples of JHipster Kotlin's use of an insecure PRNG:\n\nhttps://github.com/jhipster/jhipster-kotlin/blob/193ae8f13c0be686f9687e78bacfedb144c47d8c/generators/server/templates/src/main/kotlin/package/service/util/RandomUtil.kt.ejs#L32\n\n## Proof Of Concepts Already Exist\n\nThere has been a POC of taking one RNG value generated `RandomStringUtils` and reversing it to generate all of the past/future RNG values public since March 3rd, 2018.\n\nhttps://medium.com/@alex91ar/the-java-soothsayer-a-practical-application-for-insecure-randomness-c67b0cd148cd\n\nPOC Repository: https://github.com/alex91ar/randomstringutils\n\n\n## Potential Impact Technical\n\nAll that is required is to get one password reset token from a JHipster Kotlin generated service and using the POC above, you can reverse what all future password reset tokens to be generated by this server. This allows an attacker to pick and choose what account they would like to takeover by sending account password reset requests for targeted accounts.\n\n## Potential Impact Scale\n\nNot as large as for the original jhipster project as the kotlin blueprint is not that widely used.\n\n### Patches\n\nUpdate your generated applications to > 1.2.0\n\n### Workarounds\n\nChange the content of `RandomUtil.kt` like this:\n\n```kotlin\nimport java.security.SecureRandom\nimport org.apache.commons.lang3.RandomStringUtils\n\nprivate const val DEF_COUNT = 20\n\nobject RandomUtil {\n private val secureRandom: SecureRandom = SecureRandom()\n\n init {\n secureRandom.nextBytes(byteArrayOf(64.toByte()))\n }\n\n private fun generateRandomAlphanumericString(): String {\n return RandomStringUtils.random(DEF_COUNT, 0, 0, true, true, null, secureRandom)\n }\n\n /**\n * Generate a password.\n *\n * @return the generated password.\n */\n fun generatePassword(): String = generateRandomAlphanumericString()\n}\n```\n\nImportant is to exchange **every** call of `RandomStringUtils.randomAlphaNumeric`.\n\n\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in [JHipster Kotlin](https://github.com/jhipster/jhipster-kotlin)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "generator-jhipster-kotlin"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/jhipster/generator-jhipster/security/advisories/GHSA-mwp6-j9wf-968c"
}, {
"type" : "WEB",
"url" : "https://github.com/jhipster/jhipster-kotlin/security/advisories/GHSA-j3rh-8vwq-wh84"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-16303"
}, {
"type" : "WEB",
"url" : "https://github.com/jhipster/generator-jhipster/issues/10401"
}, {
"type" : "WEB",
"url" : "https://github.com/jhipster/jhipster-kotlin/issues/183"
}, {
"type" : "WEB",
"url" : "https://github.com/jhipster/generator-jhipster/commit/88448b85fd3e8e49df103f0061359037c2c68ea7"
}, {
"type" : "WEB",
"url" : "https://github.com/jhipster/jhipster-kotlin/commit/deec3587ef7721cf5de5b960d43e9b68beff6193"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/jhipster/generator-jhipster"
}, {
"type" : "WEB",
"url" : "https://lists.apache.org/thread.html/r6d243e7e3f25daeb242dacf3def411fba32a9388d3ff84918cb28ddd@%3Cissues.commons.apache.org%3E"
}, {
"type" : "WEB",
"url" : "https://lists.apache.org/thread.html/rc3f00f5d3d2ec0e2381a3b9096d5f5b4d46ec1587ee7e251a3dbb897@%3Cissues.commons.apache.org%3E"
}, {
"type" : "WEB",
"url" : "https://lists.apache.org/thread.html/rc87fa35a48b5d70b06af6fb81785ed82e82686eb83307aae6d250dc9@%3Cissues.commons.apache.org%3E"
}, {
"type" : "WEB",
"url" : "https://snyk.io/vuln/SNYK-JS-GENERATORJHIPSTER-466980"
}, {
"type" : "WEB",
"url" : "https://www.jhipster.tech/2019/09/13/jhipster-release-6.3.0.html"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/advisories/1187"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/advisories/1188"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-338" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2020-06-26T16:47:54Z",
"nvd_published_at" : "2019-09-14T00:15:00Z"
}
}