CWE
378 379 552 362 377
Advisory Published
CVE Published
Advisory Published
Updated

CVE-2020-27216: Race Condition

First published: Thu Oct 22 2020(Updated: )

### Impact On Unix like systems, the system's temporary directory is shared between all users on that system. A collocated user can observe the process of creating a temporary sub directory in the shared temporary directory and race to complete the creation of the temporary subdirectory. If the attacker wins the race then they will have read and write permission to the subdirectory used to unpack web applications, including their WEB-INF/lib jar files and JSP files. If any code is ever executed out of this temporary directory, this can lead to a local privilege escalation vulnerability. Additionally, any user code uses of [WebAppContext::getTempDirectory](https://www.eclipse.org/jetty/javadoc/9.4.31.v20200723/org/eclipse/jetty/webapp/WebAppContext.html#getTempDirectory()) would similarly be vulnerable. Additionally, any user application code using the `ServletContext` attribute for the tempdir will also be impacted. See: https://javaee.github.io/javaee-spec/javadocs/javax/servlet/ServletContext.html#TEMPDIR For example: ```java import java.io.File; import java.io.IOException; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ExampleServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { File tempDir = (File)getServletContext().getAttribute(ServletContext.TEMPDIR); // Potentially compromised // do something with that temp dir } } ``` Example: The JSP library itself will use the container temp directory for compiling the JSP source into Java classes before executing them. ### CVSSv3.1 Evaluation This vulnerability has been calculated to have a [CVSSv3.1 score of 7.8/10 (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H&version=3.1) ### Patches Fixes were applied to the 9.4.x branch with: - https://github.com/eclipse/jetty.project/commit/53e0e0e9b25a6309bf24ee3b10984f4145701edb - https://github.com/eclipse/jetty.project/commit/9ad6beb80543b392c91653f6bfce233fc75b9d5f These will be included in releases: 9.4.33, 10.0.0.beta3, 11.0.0.beta3 ### Workarounds A work around is to set a temporary directory, either for the server or the context, to a directory outside of the shared temporary file system. For recent releases, a temporary directory can be created simple by creating a directory called `work` in the ${jetty.base} directory (the parent directory of the `webapps` directory). Alternately the java temporary directory can be set with the System Property `java.io.tmpdir`. A more detailed description of how jetty selects a temporary directory is below. The Jetty search order for finding a temporary directory is as follows: 1. If the [`WebAppContext` has a temp directory specified](https://www.eclipse.org/jetty/javadoc/current/org/eclipse/jetty/webapp/WebAppContext.html#setTempDirectory(java.io.File)), use it. 2. If the `ServletContext` has the `javax.servlet.context.tempdir` attribute set, and if directory exists, use it. 3. If a `${jetty.base}/work` directory exists, use it (since Jetty 9.1) 4. If a `ServletContext` has the `org.eclipse.jetty.webapp.basetempdir` attribute set, and if the directory exists, use it. 5. Use `System.getProperty("java.io.tmpdir")` and use it. Jetty will end traversal at the first successful step. To mitigate this vulnerability the directory must be set to one that is not writable by an attacker. To avoid information leakage, the directory should also not be readable by an attacker. #### Setting a Jetty server temporary directory. Choices 3 and 5 apply to the server level, and will impact all deployed webapps on the server. For choice 3 just create that work directory underneath your `${jetty.base}` and restart Jetty. For choice 5, just specify your own `java.io.tmpdir` when you start the JVM for Jetty. ``` shell [jetty-distribution]$ java -Djava.io.tmpdir=/var/web/work -jar start.jar ``` #### Setting a Context specific temporary directory. The rest of the choices require you to configure the context for that deployed webapp (seen as `${jetty.base}/webapps/<context>.xml`) Example (excluding the DTD which is version specific): ``` xml <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="contextPath"><Property name="foo"/></Set> <Set name="war">/var/web/webapps/foo.war</Set> <Set name="tempDirectory">/var/web/work/foo</Set> </Configure> ``` ### References - https://github.com/eclipse/jetty.project/issues/5451 - [CWE-378: Creation of Temporary File With Insecure Permissions](https://cwe.mitre.org/data/definitions/378.html) - [CWE-379: Creation of Temporary File in Directory with Insecure Permissions](https://cwe.mitre.org/data/definitions/379.html) - [CodeQL Query PR To Detect Similar Vulnerabilities](https://github.com/github/codeql/pull/4473) ### Similar Vulnerabilities Similar, but not the same. - JUnit 4 - https://github.com/junit-team/junit4/security/advisories/GHSA-269g-pwp5-87pp - Google Guava - https://github.com/google/guava/issues/4011 - Apache Ant - https://nvd.nist.gov/vuln/detail/CVE-2020-1945 - JetBrains Kotlin Compiler - https://nvd.nist.gov/vuln/detail/CVE-2020-15824 ### For more information The original report of this vulnerability is below: > On Thu, 15 Oct 2020 at 21:14, Jonathan Leitschuh <jonathan.leitschuh@gmail.com> wrote: > Hi WebTide Security Team, > > I'm a security researcher writing some custom CodeQL queries to find Local Temporary Directory Hijacking Vulnerabilities. One of my queries flagged an issue in Jetty. > > https://lgtm.com/query/5615014766184643449/ > > I've recently been looking into security vulnerabilities involving the temporary directory because on unix-like systems, the system temporary directory is shared between all users. > There exists a race condition between the deletion of the temporary file and the creation of the directory. > > ```java > // ensure file will always be unique by appending random digits > tmpDir = File.createTempFile(temp, ".dir", parent); // Attacker knows the full path of the file that will be generated > // delete the file that was created > tmpDir.delete(); // Attacker sees file is deleted and begins a race to create their own directory before Jetty. > // and make a directory of the same name > // SECURITY VULNERABILITY: Race Condition! - Attacker beats Jetty and now owns this directory > tmpDir.mkdirs(); > ``` > > https://github.com/eclipse/jetty.project/blob/1b59672b7f668b8a421690154b98b4b2b03f254b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java#L511-L518 > > In several cases the `parent` parameter will not be the system temporary directory. However, there is one case where it will be, as the last fallback. > > > https://github.com/eclipse/jetty.project/blob/1b59672b7f668b8a421690154b98b4b2b03f254b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java#L467-L468 > > If any code is ever executed out of this temporary directory, this can lead to a local privilege escalation vulnerability. > > Would your team be willing to open a GitHub security advisory to continue the discussion and disclosure there? https://github.com/eclipse/jetty.project/security/advisories > > **This vulnerability disclosure follows Google's [90-day vulnerability disclosure policy](https://www.google.com/about/appsecurity/) (I'm not an employee of Google, I just like their policy). Full disclosure will occur either at the end of the 90-day deadline or whenever a patch is made widely available, whichever occurs first.** > > Cheers, > Jonathan Leitschuh

Credit: emo@eclipse.org emo@eclipse.org

Affected SoftwareAffected VersionHow to fix
redhat/rh-eclipse<1:4.17-6.el7_9
1:4.17-6.el7_9
redhat/rh-eclipse-ant<0:1.10.9-1.2.el7
0:1.10.9-1.2.el7
redhat/rh-eclipse-antlr32<0:3.2-28.1.el7
0:3.2-28.1.el7
redhat/rh-eclipse-apache-sshd<1:2.4.0-5.1.el7
1:2.4.0-5.1.el7
redhat/rh-eclipse-apiguardian<0:1.1.0-6.1.el7
0:1.1.0-6.1.el7
redhat/rh-eclipse-args4j<0:2.33-12.2.el7
0:2.33-12.2.el7
redhat/rh-eclipse-batik<0:1.13-1.1.el7
0:1.13-1.1.el7
redhat/rh-eclipse-bouncycastle<0:1.67-1.1.el7
0:1.67-1.1.el7
redhat/rh-eclipse-cbi-plugins<0:1.1.7-8.1.el7
0:1.1.7-8.1.el7
redhat/rh-eclipse-decentxml<0:1.4-24.1.el7
0:1.4-24.1.el7
redhat/rh-eclipse-ecj<1:4.17-1.1.el7
1:4.17-1.1.el7
redhat/rh-eclipse-eclipse<1:4.17-2.2.el7_9
1:4.17-2.2.el7_9
redhat/rh-eclipse-eclipse-ecf<0:3.14.17-1.1.el7
0:3.14.17-1.1.el7
redhat/rh-eclipse-eclipse-egit<0:5.9.0-1.1.el7_9
0:5.9.0-1.1.el7_9
redhat/rh-eclipse-eclipse-emf<1:2.23.0-1.1.el7
1:2.23.0-1.1.el7
redhat/rh-eclipse-eclipse-gef<0:3.11.0-14.1.el7
0:3.11.0-14.1.el7
redhat/rh-eclipse-eclipse-jgit<0:5.9.0-1.1.el7_9
0:5.9.0-1.1.el7_9
redhat/rh-eclipse-eclipse-license<0:2.0.2-2.1.el7_9
0:2.0.2-2.1.el7_9
redhat/rh-eclipse-eclipse-m2e-core<0:1.16.2-3.1.el7_9
0:1.16.2-3.1.el7_9
redhat/rh-eclipse-eclipse-m2e-workspace<0:0.4.0-16.1.el7
0:0.4.0-16.1.el7
redhat/rh-eclipse-eclipse-mpc<0:1.8.4-1.1.el7
0:1.8.4-1.1.el7
redhat/rh-eclipse-eclipse-pydev<1:8.0.0-1.1.el7_9
1:8.0.0-1.1.el7_9
redhat/rh-eclipse-eclipse-subclipse<0:4.3.0-8.1.el7_9
0:4.3.0-8.1.el7_9
redhat/rh-eclipse-eclipse-webtools<0:3.19.0-1.1.el7_9
0:3.19.0-1.1.el7_9
redhat/rh-eclipse-ed25519-java<0:0.3.0-8.2.el7
0:0.3.0-8.2.el7
redhat/rh-eclipse-felix-gogo-command<0:1.0.2-12.1.el7
0:1.0.2-12.1.el7
redhat/rh-eclipse-felix-gogo-parent<0:4-6.1.el7
0:4-6.1.el7
redhat/rh-eclipse-felix-gogo-runtime<0:1.1.0-8.1.el7
0:1.1.0-8.1.el7
redhat/rh-eclipse-felix-gogo-shell<0:1.1.0-6.1.el7
0:1.1.0-6.1.el7
redhat/rh-eclipse-felix-scr<0:2.1.16-7.2.el7
0:2.1.16-7.2.el7
redhat/rh-eclipse-javaewah<0:1.1.6-10.1.el7
0:1.1.6-10.1.el7
redhat/rh-eclipse-javaparser<0:3.14.16-1.2.el7
0:3.14.16-1.2.el7
redhat/rh-eclipse-jchardet<0:1.1-23.1.el7
0:1.1-23.1.el7
redhat/rh-eclipse-jctools<0:3.1.0-1.1.el7
0:3.1.0-1.1.el7
redhat/rh-eclipse-jetty<0:9.4.33-1.1.el7
0:9.4.33-1.1.el7
redhat/rh-eclipse-jffi<0:1.2.23-2.1.el7
0:1.2.23-2.1.el7
redhat/rh-eclipse-jgit<0:5.9.0-1.2.el7
0:5.9.0-1.2.el7
redhat/rh-eclipse-jna<0:5.4.0-7.1.el7
0:5.4.0-7.1.el7
redhat/rh-eclipse-jnr-constants<0:0.9.12-7.1.el7
0:0.9.12-7.1.el7
redhat/rh-eclipse-jnr-ffi<0:2.1.8-9.1.el7
0:2.1.8-9.1.el7
redhat/rh-eclipse-jnr-netdb<0:1.1.6-11.1.el7
0:1.1.6-11.1.el7
redhat/rh-eclipse-jnr-posix<0:3.0.47-7.1.el7
0:3.0.47-7.1.el7
redhat/rh-eclipse-jnr-x86asm<0:1.0.2-22.1.el7
0:1.0.2-22.1.el7
redhat/rh-eclipse-jsch-agent-proxy<0:0.0.8-14.1.el7
0:0.0.8-14.1.el7
redhat/rh-eclipse-junit5<0:5.7.0-1.2.el7
0:5.7.0-1.2.el7
redhat/rh-eclipse-jython<0:2.7.1-14.1.el7_9
0:2.7.1-14.1.el7_9
redhat/rh-eclipse-jzlib<0:1.1.3-15.1.el7
0:1.1.3-15.1.el7
redhat/rh-eclipse-lucene<0:8.6.3-1.1.el7
0:8.6.3-1.1.el7
redhat/rh-eclipse-maven-archetype<0:3.2.0-1.1.el7_9
0:3.2.0-1.1.el7_9
redhat/rh-eclipse-maven-indexer<0:6.0.0-5.1.el7
0:6.0.0-5.1.el7
redhat/rh-eclipse-netty<0:4.1.51-1.2.el7
0:4.1.51-1.2.el7
redhat/rh-eclipse-objectweb-asm<0:8.0.1-1.2.el7
0:8.0.1-1.2.el7
redhat/rh-eclipse-opentest4j<0:1.2.0-4.1.el7
0:1.2.0-4.1.el7
redhat/rh-eclipse-os-maven-plugin<0:1.6.2-2.1.el7
0:1.6.2-2.1.el7
redhat/rh-eclipse-sac<0:1.3-34.1.el7
0:1.3-34.1.el7
redhat/rh-eclipse-sat4j<0:2.3.5-20.1.el7
0:2.3.5-20.1.el7
redhat/rh-eclipse-sequence-library<0:1.0.3-8.1.el7
0:1.0.3-8.1.el7
redhat/rh-eclipse-sqljet<0:1.1.10-18.1.el7
0:1.1.10-18.1.el7
redhat/rh-eclipse-stringtemplate<0:3.2.1-24.1.el7
0:3.2.1-24.1.el7
redhat/rh-eclipse-svnkit<1:1.8.12-9.1.el7
1:1.8.12-9.1.el7
redhat/rh-eclipse-takari-polyglot<0:0.4.5-2.1.el7_9
0:0.4.5-2.1.el7_9
redhat/rh-eclipse-trilead-ssh2<0:217.21-3.1.el7
0:217.21-3.1.el7
redhat/rh-eclipse-tycho<0:1.7.0-2.5.el7_9
0:1.7.0-2.5.el7_9
redhat/rh-eclipse-univocity-parsers<0:2.9.0-1.1.el7
0:2.9.0-1.1.el7
redhat/rh-eclipse-ws-commons-util<0:1.0.2-14.1.el7
0:1.0.2-14.1.el7
redhat/rh-eclipse-xmlgraphics-commons<0:2.4-1.1.el7
0:2.4-1.1.el7
redhat/rh-eclipse-xml-maven-plugin<0:1.0.2-7.1.el7
0:1.0.2-7.1.el7
redhat/rh-eclipse-xmlrpc<1:3.1.3-27.1.el7
1:3.1.3-27.1.el7
redhat/jenkins<0:2.289.1.1624365627-1.el7
0:2.289.1.1624365627-1.el7
redhat/jenkins<0:2.277.3.1623846768-1.el7
0:2.277.3.1623846768-1.el7
redhat/jenkins<0:2.277.3.1623853726-1.el8
0:2.277.3.1623853726-1.el8
maven/org.eclipse.jetty:jetty-webapp<9.4.33.v20201020
9.4.33.v20201020
maven/org.mortbay.jetty:jetty-webapp>=11.0.0.beta1<=11.0.0.beta2
11.0.0.beta3
maven/org.eclipse.jetty:jetty-webapp>=11.0.0.beta1<=11.0.0.beta2
11.0.0.beta3
maven/org.mortbay.jetty:jetty-webapp>=10.0.0.beta1<=10.0.0.beta2
10.0.0.beta3
maven/org.eclipse.jetty:jetty-webapp>=10.0.0.beta1<=10.0.0.beta2
10.0.0.beta3
maven/org.mortbay.jetty:jetty-webapp<9.4.33
9.4.33
debian/jetty9
9.4.16-0+deb10u1
9.4.50-4+deb10u1
9.4.39-3+deb11u2
9.4.50-4+deb11u1
9.4.50-4+deb12u2
9.4.53-1
redhat/jetty<9.4.33.
9.4.33.
redhat/jetty<10.0.0.
10.0.0.
redhat/jetty<11.0.0.
11.0.0.
Eclipse Jetty>=1.0<9.3.29
Eclipse Jetty>=9.4.0<=9.4.32
Eclipse Jetty=10.0.0-alpha1
Eclipse Jetty=10.0.0-beta0
Eclipse Jetty=10.0.0-beta1
Eclipse Jetty=10.0.0-beta2
Eclipse Jetty=11.0.0-alpha1
Eclipse Jetty=11.0.0-beta1
Eclipse Jetty=11.0.0-beta2
NetApp Snap Creator Framework
Netapp Snapcenter
Netapp Vasa Provider Clustered Data Ontap>=7.2
Netapp Virtual Storage Console Vmware Vsphere>=7.2
Netapp Storage Replication Adapter Clustered Data Ontap>=7.2
VMware vSphere
Oracle Communications Application Session Controller=3.9m0p2
Oracle Communications Converged Application Server - Service Controller=6.2
Oracle Communications Element Manager>=8.2.1<=8.2.2.1
Oracle Communications Offline Mediation Controller=12.0.0.3.0
Oracle Communications Pricing Design Center=12.0.0.3.0
Oracle Communications Services Gatekeeper=7.0
Oracle FLEXCUBE Core Banking>=11.5.0<=11.9.0
Oracle FLEXCUBE Private Banking=12.0.0
Oracle FLEXCUBE Private Banking=12.1.0
Oracle Jd Edwards Enterpriseone Tools<9.2.6.0
Oracle Siebel Core - Automation<=21.5
Apache Beam=2.21.0
Apache Beam=2.22.0
Apache Beam=2.23.0
Apache Beam=2.24.0
Apache Beam=2.25.0
Debian Debian Linux=9.0
Debian Debian Linux=10.0
IBM Cognos Analytics<=12.0.0-12.0.3
IBM Cognos Analytics<=11.2.0-11.2.4 FP3

Remedy

Jetty users should create temp folders outside the normal /tmp structure, and ensure that their permissions are set so as not to be accessible by an attacker.

Never miss a vulnerability like this again

Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.

Reference Links

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2024 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203