Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: QL Query Detector for JHipster Generated CVE-2019-16303 #180

Closed
1 task done
JLLeitschuh opened this issue Sep 21, 2020 · 6 comments
Closed
1 task done

Java: QL Query Detector for JHipster Generated CVE-2019-16303 #180

JLLeitschuh opened this issue Sep 21, 2020 · 6 comments
Labels
All For One Submissions to the All for One, One for All bounty

Comments

@JLLeitschuh
Copy link

JLLeitschuh commented Sep 21, 2020

CVE ID(s)

Report

Last year I found a widespread vulnerability where nearly the same vulnerable file existed in >15k repositories across GitHub. I eventually tracked down the root cause of this vulnerability to the project JHipster. JHipster is a code generator used to generate a basic MVC and microservice java applications. This code-generator contained a generator for creating a class RandomUtil. This class, when generated in it's complete form looked like this:

import org.apache.commons.lang3.RandomStringUtils;

/**
 * Utility class for generating random Strings.
 */
public final class RandomUtil {

    private static final int DEF_COUNT = 20;

    private RandomUtil() {
    }

    /**
     * Generate a password.
     *
     * @return the generated password.
     */
    public static String generatePassword() {
        return RandomStringUtils.randomAlphanumeric(DEF_COUNT);
    }

    /**
     * Generate an activation key.
     *
     * @return the generated activation key.
     */
    public static String generateActivationKey() {
        return RandomStringUtils.randomNumeric(DEF_COUNT);
    }

    /**
     * Generate a reset key.
     *
     * @return the generated reset key.
     */
    public static String generateResetKey() {
        return RandomStringUtils.randomNumeric(DEF_COUNT);
    }

    /**
     * Generate a unique series to validate a persistent token, used in the
     * authentication remember-me mechanism.
     *
     * @return the generated series data.
     */
    public static String generateSeriesData() {
        return RandomStringUtils.randomAlphanumeric(DEF_COUNT);
    }

    /**
     * Generate a persistent token, used in the authentication remember-me mechanism.
     *
     * @return the generated token data.
     */
    public static String generateTokenData() {
        return RandomStringUtils.randomAlphanumeric(DEF_COUNT);
    }
}

You can see that there are ~15k instances of this vulnerability across GitHub here:
https://github.com/search?l=Java&p=2&q=Utility+class+for+generating+random+Strings.+RandomUtil&type=Code

By working with the GitHub staff, we were able to extract 9k repositories from that search and ingest them into LGTM.com.
From there, the query was run against all Java projects on LGTM.com resulting in this query result.

  • Are you planning to discuss this vulnerability submission publicly? (Blog Post, social networks, etc). We would love to have you spread the word about the good work you are doing

Hopefully at GitHub Universe? Maybe?

Result(s)

https://lgtm.com/query/8455949919266029298
The query returned 5,511 vulnerable projects.

CodeQL PR

github/codeql#4312

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status SecLab review.

For information, the evaluation workflow is the following:
CodeQL initial assessment > SecLab review > CodeQL review > SecLab finalize > Pay > Closed

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status CodeQL review.

For information, the evaluation workflow is the following:
CodeQL initial assessment > SecLab review > CodeQL review > SecLab finalize > Pay > Closed

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status SecLab finalize.

For information, the evaluation workflow is the following:
CodeQL initial assessment > SecLab review > CodeQL review > SecLab finalize > Pay > Closed

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status Pay.

For information, the evaluation workflow is the following:
CodeQL initial assessment > SecLab review > CodeQL review > SecLab finalize > Pay > Closed

@xcorail
Copy link
Contributor

xcorail commented Dec 23, 2020

Created Hackerone report 1065403 for bounty 267738 : [180] Java: QL Query Detector for JHipster Generated CVE-2019-16303

@xcorail xcorail closed this as completed Dec 23, 2020
@ghsecuritylab
Copy link
Collaborator

Your submission is now in status Closed.

For information, the evaluation workflow is the following:
CodeQL initial assessment > SecLab review > CodeQL review > SecLab finalize > Pay > Closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
All For One Submissions to the All for One, One for All bounty
Projects
None yet
Development

No branches or pull requests

3 participants