[Git][java-team/tomcat9][buster] 2 commits: Fix CVE-2021-43980, CVE-2022-23181, CVE-2022-29885
Markus Koschany (@apo)
gitlab at salsa.debian.org
Sat Oct 29 15:42:00 BST 2022
Markus Koschany pushed to branch buster at Debian Java Maintainers / tomcat9
Commits:
5ef955bb by Markus Koschany at 2022-10-25T17:43:14+02:00
Fix CVE-2021-43980, CVE-2022-23181, CVE-2022-29885
- - - - -
25fbc3e1 by Markus Koschany at 2022-10-25T17:46:47+02:00
Update changelog
- - - - -
5 changed files:
- debian/changelog
- + debian/patches/CVE-2021-43980.patch
- + debian/patches/CVE-2022-23181.patch
- + debian/patches/CVE-2022-29885.patch
- debian/patches/series
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,27 @@
+tomcat9 (9.0.31-1~deb10u7) buster-security; urgency=high
+
+ * Team upload.
+ * Fix CVE-2021-43980:
+ The simplified implementation of blocking reads and writes introduced in
+ Tomcat 10 and back-ported to Tomcat 9.0.47 onwards exposed a long standing
+ (but extremely hard to trigger) concurrency bug that could cause client
+ connections to share an Http11Processor instance resulting in responses, or
+ part responses, to be received by the wrong client.
+ * Fix CVE-2022-23181:
+ The fix for bug CVE-2020-9484 introduced a time of check, time of use
+ vulnerability into Apache Tomcat that allowed a local attacker to perform
+ actions with the privileges of the user that the Tomcat process is using.
+ This issue is only exploitable when Tomcat is configured to persist sessions
+ using the FileStore.
+ * Fix CVE-2022-29885:
+ The documentation of Apache Tomcat for the EncryptInterceptor incorrectly
+ stated it enabled Tomcat clustering to run over an untrusted network. This
+ was not correct. While the EncryptInterceptor does provide confidentiality
+ and integrity protection, it does not protect against all risks associated
+ with running over any untrusted network, particularly DoS risks.
+
+ -- Markus Koschany <apo at debian.org> Tue, 25 Oct 2022 17:43:18 +0200
+
tomcat9 (9.0.31-1~deb10u6) buster-security; urgency=high
* Team upload.
=====================================
debian/patches/CVE-2021-43980.patch
=====================================
@@ -0,0 +1,164 @@
+From: Markus Koschany <apo at debian.org>
+Date: Tue, 25 Oct 2022 17:31:46 +0200
+Subject: CVE-2021-43980
+
+Origin: https://github.com/apache/tomcat/commit/170e0f792bd18ff031677890ba2fe50eb7a376c1
+---
+ java/org/apache/coyote/AbstractProtocol.java | 32 ++++++++++++----------
+ .../apache/tomcat/util/net/SocketWrapperBase.java | 17 ++++++++----
+ 2 files changed, 29 insertions(+), 20 deletions(-)
+
+diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java
+index f85b67d..eda7289 100644
+--- a/java/org/apache/coyote/AbstractProtocol.java
++++ b/java/org/apache/coyote/AbstractProtocol.java
+@@ -775,7 +775,11 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+
+ S socket = wrapper.getSocket();
+
+- Processor processor = (Processor) wrapper.getCurrentProcessor();
++ // We take complete ownership of the Processor inside of this method to ensure
++ // no other thread can release it while we're using it. Whatever processor is
++ // held by this variable will be associated with the SocketWrapper before this
++ // method returns.
++ Processor processor = (Processor) wrapper.takeCurrentProcessor();
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(sm.getString("abstractConnectionHandler.connectionsGet",
+ processor, socket));
+@@ -860,9 +864,6 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+ processor.setSslSupport(
+ wrapper.getSslSupport(getProtocol().getClientCertProvider()));
+
+- // Associate the processor with the connection
+- wrapper.setCurrentProcessor(processor);
+-
+ SocketState state = SocketState.CLOSED;
+ do {
+ state = processor.process(wrapper, status);
+@@ -882,8 +883,6 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+ release(processor);
+ // Create the upgrade processor
+ processor = upgradeProtocol.getProcessor(wrapper, getProtocol().getAdapter());
+- // Associate with the processor with the connection
+- wrapper.setCurrentProcessor(processor);
+ } else {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(sm.getString(
+@@ -905,8 +904,6 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+ }
+ // Mark the connection as upgraded
+ wrapper.setUpgraded(true);
+- // Associate with the processor with the connection
+- wrapper.setCurrentProcessor(processor);
+ // Initialise the upgrade handler (which may trigger
+ // some IO using the new protocol which is why the lines
+ // above are necessary)
+@@ -944,8 +941,8 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+ } else if (state == SocketState.OPEN) {
+ // In keep-alive but between requests. OK to recycle
+ // processor. Continue to poll for the next request.
+- wrapper.setCurrentProcessor(null);
+ release(processor);
++ processor = null;
+ wrapper.registerReadInterest();
+ } else if (state == SocketState.SENDFILE) {
+ // Sendfile in progress. If it fails, the socket will be
+@@ -970,8 +967,7 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+ // Connection closed. OK to recycle the processor.
+ // Processors handling upgrades require additional clean-up
+ // before release.
+- wrapper.setCurrentProcessor(null);
+- if (processor.isUpgrade()) {
++ if (processor != null && processor.isUpgrade()) {
+ UpgradeToken upgradeToken = processor.getUpgradeToken();
+ HttpUpgradeHandler httpUpgradeHandler = upgradeToken.getHttpUpgradeHandler();
+ InstanceManager instanceManager = upgradeToken.getInstanceManager();
+@@ -992,7 +988,13 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+ }
+ }
+ }
++
+ release(processor);
++ processor = null;
++ }
++
++ if (processor != null) {
++ wrapper.setCurrentProcessor(processor);
+ }
+ return state;
+ } catch(java.net.SocketException e) {
+@@ -1030,7 +1032,6 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+
+ // Make sure socket/processor is removed from the list of current
+ // connections
+- wrapper.setCurrentProcessor(null);
+ release(processor);
+ return SocketState.CLOSED;
+ }
+@@ -1064,7 +1065,9 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+
+ /**
+ * Expected to be used by the handler once the processor is no longer
+- * required.
++ * required. Care must be taken to ensure that this method is only
++ * called once per processor, after the request processing has
++ * completed.
+ *
+ * @param processor Processor being released (that was associated with
+ * the socket)
+@@ -1103,8 +1106,7 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
+ */
+ @Override
+ public void release(SocketWrapperBase<S> socketWrapper) {
+- Processor processor = (Processor) socketWrapper.getCurrentProcessor();
+- socketWrapper.setCurrentProcessor(null);
++ Processor processor = (Processor) socketWrapper.takeCurrentProcessor();
+ release(processor);
+ }
+
+diff --git a/java/org/apache/tomcat/util/net/SocketWrapperBase.java b/java/org/apache/tomcat/util/net/SocketWrapperBase.java
+index f205725..fe30626 100644
+--- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java
++++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java
+@@ -29,6 +29,7 @@ import java.util.concurrent.RejectedExecutionException;
+ import java.util.concurrent.Semaphore;
+ import java.util.concurrent.TimeUnit;
+ import java.util.concurrent.atomic.AtomicBoolean;
++import java.util.concurrent.atomic.AtomicReference;
+
+ import org.apache.juli.logging.Log;
+ import org.apache.juli.logging.LogFactory;
+@@ -104,10 +105,12 @@ public abstract class SocketWrapperBase<E> {
+ protected volatile OperationState<?> writeOperation = null;
+
+ /**
+- * The org.apache.coyote.Processor instance currently associated
+- * with the wrapper.
++ * The org.apache.coyote.Processor instance currently associated with the
++ * wrapper. Only populated when required to maintain wrapper<->Processor
++ * mapping between calls to
++ * {@link AbstractEndpoint.Handler#process(SocketWrapperBase, SocketEvent)}.
+ */
+- protected Object currentProcessor = null;
++ private final AtomicReference<Object> currentProcessor = new AtomicReference<>();
+
+ public SocketWrapperBase(E socket, AbstractEndpoint<E,?> endpoint) {
+ this.socket = socket;
+@@ -134,11 +137,15 @@ public abstract class SocketWrapperBase<E> {
+ }
+
+ public Object getCurrentProcessor() {
+- return currentProcessor;
++ return currentProcessor.get();
+ }
+
+ public void setCurrentProcessor(Object currentProcessor) {
+- this.currentProcessor = currentProcessor;
++ this.currentProcessor.set(currentProcessor);
++ }
++
++ public Object takeCurrentProcessor() {
++ return currentProcessor.getAndSet(null);
+ }
+
+ /**
=====================================
debian/patches/CVE-2022-23181.patch
=====================================
@@ -0,0 +1,30 @@
+From: Markus Koschany <apo at debian.org>
+Date: Tue, 25 Oct 2022 17:35:53 +0200
+Subject: CVE-2022-23181
+
+Origin: https://github.com/apache/tomcat/commit/1385c624b4a1e994426e810075c850edc38a700e
+---
+ java/org/apache/catalina/session/FileStore.java | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/java/org/apache/catalina/session/FileStore.java b/java/org/apache/catalina/session/FileStore.java
+index e461f21..f7c6cc7 100644
+--- a/java/org/apache/catalina/session/FileStore.java
++++ b/java/org/apache/catalina/session/FileStore.java
+@@ -349,13 +349,14 @@ public final class FileStore extends StoreBase {
+
+ String filename = id + FILE_EXT;
+ File file = new File(storageDir, filename);
++ File canonicalFile = file.getCanonicalFile();
+
+ // Check the file is within the storage directory
+- if (!file.getCanonicalFile().toPath().startsWith(storageDir.getCanonicalFile().toPath())) {
++ if (!canonicalFile.toPath().startsWith(storageDir.getCanonicalFile().toPath())) {
+ log.warn(sm.getString("fileStore.invalid", file.getPath(), id));
+ return null;
+ }
+
+- return file;
++ return canonicalFile;
+ }
+ }
=====================================
debian/patches/CVE-2022-29885.patch
=====================================
@@ -0,0 +1,72 @@
+From: Markus Koschany <apo at debian.org>
+Date: Tue, 25 Oct 2022 17:36:52 +0200
+Subject: CVE-2022-29885
+
+Origin: https://github.com/apache/tomcat/commit/eaafd28296c54d983e28a47953c1f5cb2c334f48
+---
+ webapps/docs/cluster-howto.xml | 6 +++++-
+ webapps/docs/config/cluster.xml | 6 +++++-
+ webapps/docs/security-howto.xml | 8 +++++---
+ 3 files changed, 15 insertions(+), 5 deletions(-)
+
+diff --git a/webapps/docs/cluster-howto.xml b/webapps/docs/cluster-howto.xml
+index cfbfc2f..2a9244d 100644
+--- a/webapps/docs/cluster-howto.xml
++++ b/webapps/docs/cluster-howto.xml
+@@ -127,9 +127,13 @@ Tomcat cluster. These include:</p>
+ <li>private LAN</li>
+ <li>a Virtual Private Network (VPN)</li>
+ <li>IPSEC</li>
+- <li>Encrypt cluster traffic using the <a href="config/cluster-interceptor.html#org.apache.catalina.tribes.group.interceptors.EncryptInterceptor_Attributes">EncryptInterceptor</a></li>
+ </ul>
+
++<p>The <a href="cluster-interceptor.html#org.apache.catalina.tribes.group.interceptors.EncryptInterceptor_Attributes">EncryptInterceptor</a>
++provides confidentiality and integrity protection but it does not protect
++against all risks associated with running a Tomcat cluster on an untrusted
++network, particularly DoS attacks.</p>
++
+ </section>
+
+ <section name="Cluster Basics">
+diff --git a/webapps/docs/config/cluster.xml b/webapps/docs/config/cluster.xml
+index 91e8328..dc747f2 100644
+--- a/webapps/docs/config/cluster.xml
++++ b/webapps/docs/config/cluster.xml
+@@ -52,12 +52,16 @@ to run a cluster on a insecure, untrusted network.</p>
+ <p>There are many options for providing a secure, trusted network for use by a
+ Tomcat cluster. These include:</p>
+ <ul>
+- <li><a href="cluster-interceptor.html#org.apache.catalina.tribes.group.interceptors.EncryptInterceptor_Attributes">EncryptInterceptor</a></li>
+ <li>private LAN</li>
+ <li>a Virtual Private Network (VPN)</li>
+ <li>IPSEC</li>
+ </ul>
+
++<p>The <a href="cluster-interceptor.html#org.apache.catalina.tribes.group.interceptors.EncryptInterceptor_Attributes">EncryptInterceptor</a>
++provides confidentiality and integrity protection but it does not protect
++against all risks associated with running a Tomcat cluster on an untrusted
++network, particularly DoS attacks.</p>
++
+ </section>
+ <section name="Engine vs Host placement">
+ <p>
+diff --git a/webapps/docs/security-howto.xml b/webapps/docs/security-howto.xml
+index 3396e36..3486539 100644
+--- a/webapps/docs/security-howto.xml
++++ b/webapps/docs/security-howto.xml
+@@ -454,10 +454,12 @@
+ trusted network is used for all of the cluster related network traffic. It
+ is not safe to run a cluster on a insecure, untrusted network.</p>
+
+- <p>If you are operating on an untrusted network or would prefer to
+- exercise an over-abundance of caution, you can use the
++ <p>If you require confidentiality and/or integrity protection then you can
++ use the
+ <a href="config/cluster-interceptor.html#org.apache.catalina.tribes.group.interceptors.EncryptInterceptor_Attributes">EncryptInterceptor</a>
+- to encrypt traffic between nodes.</p>
++ to encrypt traffic between nodes. This interceptor does not protect
++ against all the risks of running on an untrusted network, particularly
++ DoS attacks.</p>
+ </subsection>
+ </section>
+
=====================================
debian/patches/series
=====================================
@@ -24,3 +24,6 @@ CVE-2021-25329.patch
CVE-2021-30640.patch
CVE-2021-33037.patch
CVE-2021-41079.patch
+CVE-2021-43980.patch
+CVE-2022-23181.patch
+CVE-2022-29885.patch
View it on GitLab: https://salsa.debian.org/java-team/tomcat9/-/compare/3cb22204fbe0a69f1466ecf43dc3a8563660f094...25fbc3e1cac27ccf4ea319b8b93e4171e246757d
--
View it on GitLab: https://salsa.debian.org/java-team/tomcat9/-/compare/3cb22204fbe0a69f1466ecf43dc3a8563660f094...25fbc3e1cac27ccf4ea319b8b93e4171e246757d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20221029/e63ecb42/attachment.htm>
More information about the pkg-java-commits
mailing list