{"id":"GHSA-j3rh-8vwq-wh84","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\u003e Caveat: Instances of Random, upon which the implementation of this class relies, are not cryptographically secure.\n\u003e \\- 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 \u003e 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)","aliases":["CVE-2019-16303"],"modified":"2026-03-13T22:11:32.726890Z","published":"2020-06-26T16:48:13Z","database_specific":{"severity":"CRITICAL","github_reviewed":true,"cwe_ids":["CWE-338"],"github_reviewed_at":"2020-06-26T16:47:54Z","nvd_published_at":"2019-09-14T00:15:00Z"},"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"}],"affected":[{"package":{"name":"generator-jhipster-kotlin","ecosystem":"npm","purl":"pkg:npm/generator-jhipster-kotlin"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.2.0"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2020/06/GHSA-j3rh-8vwq-wh84/GHSA-j3rh-8vwq-wh84.json"}}],"schema_version":"1.7.5","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}]}