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

Fix CVE–2020–15250 #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

debricked-staging[bot]
Copy link

@debricked-staging debricked-staging bot commented Nov 12, 2021

CVE–2020–15250

Vulnerable dependency:     junit:junit (Maven)    4.12

Vulnerability details

Description

Incorrect Permission Assignment for Critical Resource

The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.

GitHub

TemporaryFolder on unix-like systems does not limit access to created files

Vulnerability

The JUnit4 test rule TemporaryFolder contains a local information disclosure vulnerability.

Example of vulnerable code:

public static class HasTempFolder {
    @Rule
    public TemporaryFolder folder = new TemporaryFolder();

    @Test
    public void testUsingTempFolder() throws IOException {
        folder.getRoot(); // Previous file permissions: `drwxr-xr-x`; After fix:`drwx------`
        File createdFile= folder.newFile("myfile.txt"); // unchanged/irrelevant file permissions
        File createdFolder= folder.newFolder("subfolder"); // unchanged/irrelevant file permissions
        // ...
    }
}

Impact

On Unix like systems, the system's temporary directory is shared between all users on that system. Because of this, when files and directories are written into this directory they are, by default, readable by other users on that same system.

This vulnerability does not allow other users to overwrite the contents of these directories or files. This is purely an information disclosure vulnerability.

When analyzing the impact of this vulnerability, here are the important questions to ask:

  1. Do the JUnit tests write sensitive information, like API keys or passwords, into the temporary folder?
    • If yes, this vulnerability impacts you, but only if you also answer 'yes' to question 2.
    • If no, this vulnerability does not impact you.
  2. Do the JUnit tests ever execute in an environment where the OS has other untrusted users.
    This may apply in CI/CD environments but normally won't be 'yes' for personal developer machines.
    • If yes, and you answered 'yes' to question 1, this vulnerability impacts you.
    • If no, this vulnerability does not impact you.

Patches

Because certain JDK file system APIs were only added in JDK 1.7, this this fix is dependent upon the version of the JDK you are using.

  • Java 1.7 and higher users: this vulnerability is fixed in 4.13.1.
  • Java 1.6 and lower users: no patch is available, you must use the workaround below.

Workarounds

If you are unable to patch, or are stuck running on Java 1.6, specifying the java.io.tmpdir system environment variable to a directory that is exclusively owned by the executing user will fix this vulnerability.

References

Similar Vulnerabilities

For more information

If you have any questions or comments about this advisory, please pen an issue in junit-team/junit4.

NVD

In JUnit4 from version 4.7 and before 4.13.1, the test rule TemporaryFolder contains a local information disclosure vulnerability. On Unix like systems, the system's temporary directory is shared between all users on that system. Because of this, when files and directories are written into this directory they are, by default, readable by other users on that same system. This vulnerability does not allow other users to overwrite the contents of these directories or files. This is purely an information disclosure vulnerability. This vulnerability impacts you if the JUnit tests write sensitive information, like API keys or passwords, into the temporary folder, and the JUnit tests execute in an environment where the OS has other untrusted users. Because certain JDK file system APIs were only added in JDK 1.7, this this fix is dependent upon the version of the JDK you are using. For Java 1.7 and higher users: this vulnerability is fixed in 4.13.1. For Java 1.6 and lower users: no patch is available, you must use the workaround below. If you are unable to patch, or are stuck running on Java 1.6, specifying the java.io.tmpdir system environment variable to a directory that is exclusively owned by the executing user will fix this vulnerability. For more information, including an example of vulnerable code, see the referenced GitHub Security Advisory.

CVSS details - 5.5

 

CVSS3 metrics
Attack Vector Local
Attack Complexity Low
Privileges Required None
User interaction Required
Scope Unchanged
Confidentiality High
Integrity None
Availability None
References

    TemporaryFolder on unix-like systems does not limit access to created files · CVE-2020-15250 · GitHub Advisory Database · GitHub
    THIRD PARTY
    junit4/ReleaseNotes4.13.1.md at 7852b90cfe1cea1e0cdaa19d490c83f0d8684b50 · junit-team/junit4 · GitHub
    Merge pull request from GHSA-269g-pwp5-87pp · junit-team/junit4@610155b · GitHub
    TemporaryFolder on unix-like systems does not limit access to created files · Advisory · junit-team/junit4 · GitHub
    TemporaryFolder (JUnit API)
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    CVE-2020-15250 doesn't affect versions prior to 4.7 but claims it did · Issue #1676 · junit-team/junit4 · GitHub
    [SECURITY] [DLA 2426-1] junit4 security update
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    MLIST
    THIRD PARTY
    THIRD PARTY
    THIRD PARTY
    THIRD PARTY
    THIRD PARTY
    THIRD PARTY
    THIRD PARTY
    THIRD PARTY
    THIRD PARTY
    THIRD PARTY

 

Related information

📌 Remember! Check the changes to ensure they don't introduce any breaking changes.
📚 Read more about the CVE

 

@debricked-staging debricked-staging bot force-pushed the debricked-fix-CVE_2020_15250-06cc4bebab31987a branch from b138f3f to 647a72b Compare November 22, 2021 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants