]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
bug 4321: ssl_bump terminate does not terminate at step1
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Sun, 7 May 2017 21:53:15 +0000 (00:53 +0300)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Sun, 7 May 2017 21:53:15 +0000 (00:53 +0300)
The following trivial configuration should terminate all connections that
are subject to SslBumping:
  ssl_bump terminate all
but Squid either splices or bumps instead.

This patch fixes Squid to immediately close the connection.

Also this patch:
 - solves wrong use of Ssl::bumpNone in cases where the Ssl::bumpEnd
   (do not bump) or Ssl::bumpSplice (splice after peek/stare at step1)
   must be used.
 - updates %ssl::bump_mode documetation.
 - fixes %ssl::bump_mode formating code to print last bumping action

This is a Measurement Factory project

src/cf.data.pre
src/client_side.cc
src/client_side_request.cc
src/ssl/PeekingPeerConnector.cc

index f72560066b110bd2f28194cbae40f300abb4155c..3ae25a90ecfb48802894030336b55c1e480c7d27 100644 (file)
@@ -4412,13 +4412,14 @@ DOC_START
                                For CONNECT requests that initiated bumping of
                                a connection and for any request received on
                                an already bumped connection, Squid logs the
-                               corresponding SslBump mode ("server-first" or
-                               "client-first"). See the ssl_bump option for
-                               more information about these modes.
+                               corresponding SslBump mode ("splice", "bump",
+                               "peek", "stare", "terminate", "server-first"
+                               or "client-first"). See the ssl_bump option 
+                               for more information about these modes.
 
                                A "none" token is logged for requests that
                                triggered "ssl_bump" ACL evaluation matching
-                               either a "none" rule or no rules at all.
+                               a "none" rule.
 
                                In all other cases, a single dash ("-") is
                                logged.
index 78f96a901e0c89a64be1228140306cfec20933ca..caceb6f99c75fe744e12e25a47d50477d96646a6 100644 (file)
@@ -2728,8 +2728,6 @@ httpsEstablish(ConnStateData *connState, const Security::ContextPointer &ctx)
 
 /**
  * A callback function to use with the ACLFilledChecklist callback.
- * In the case of ACCESS_ALLOWED answer initializes a bumped SSL connection,
- * else reverts the connection to tunnel mode.
  */
 static void
 httpsSslBumpAccessCheckDone(allow_t answer, void *data)
@@ -2740,15 +2738,19 @@ httpsSslBumpAccessCheckDone(allow_t answer, void *data)
     if (!connState->isOpen())
         return;
 
-    // Require both a match and a positive bump mode to work around exceptional
-    // cases where ACL code may return ACCESS_ALLOWED with zero answer.kind.
-    if (answer == ACCESS_ALLOWED && answer.kind != Ssl::bumpNone) {
-        debugs(33, 2, "sslBump needed for " << connState->clientConnection << " method " << answer.kind);
+    if (answer == ACCESS_ALLOWED) {
+        debugs(33, 2, "sslBump action " << Ssl::bumpMode(answer.kind) << "needed for " << connState->clientConnection);
         connState->sslBumpMode = static_cast<Ssl::BumpMode>(answer.kind);
     } else {
-        debugs(33, 2, HERE << "sslBump not needed for " << connState->clientConnection);
-        connState->sslBumpMode = Ssl::bumpNone;
+        debugs(33, 3, "sslBump not needed for " << connState->clientConnection);
+        connState->sslBumpMode = Ssl::bumpSplice;
+    }
+
+    if (connState->sslBumpMode == Ssl::bumpTerminate) {
+        connState->clientConnection->close();
+        return;
     }
+
     if (!connState->fakeAConnectRequest("ssl-bump", connState->inBuf))
         connState->clientConnection->close();
 }
@@ -3169,7 +3171,8 @@ ConnStateData::parseTlsHandshake()
         Must(context && context->http);
         HttpRequest::Pointer request = context->http->request;
         debugs(83, 5, "Got something other than TLS Client Hello. Cannot SslBump.");
-        sslBumpMode = Ssl::bumpNone;
+        sslBumpMode = Ssl::bumpSplice;
+        context->http->al->ssl.bumpMode = Ssl::bumpSplice;
         if (!clientTunnelOnError(this, context, request, HttpRequestMethod(), ERR_PROTOCOL_UNKNOWN))
             clientConnection->close();
         return;
@@ -3205,6 +3208,9 @@ void httpsSslBumpStep2AccessCheckDone(allow_t answer, void *data)
 
     connState->serverBump()->act.step2 = bumpAction;
     connState->sslBumpMode = bumpAction;
+    Http::StreamPointer context = connState->pipeline.front();
+    if (ClientHttpRequest *http = (context ? context->http : nullptr))
+        http->al->ssl.bumpMode = bumpAction;
 
     if (bumpAction == Ssl::bumpTerminate) {
         connState->clientConnection->close();
index b955bd5a90fbe20bde1357081a4e0c87a1eb3883..899c4a18ceebf773f41a73bfa8ac712bdb4b4abd 100644 (file)
@@ -1499,10 +1499,19 @@ ClientRequestContext::sslBumpAccessCheckDone(const allow_t &answer)
         return;
 
     const Ssl::BumpMode bumpMode = answer == ACCESS_ALLOWED ?
-                                   static_cast<Ssl::BumpMode>(answer.kind) : Ssl::bumpNone;
+                                   static_cast<Ssl::BumpMode>(answer.kind) : Ssl::bumpSplice;
     http->sslBumpNeed(bumpMode); // for processRequest() to bump if needed
     http->al->ssl.bumpMode = bumpMode; // for logging
 
+    if (bumpMode == Ssl::bumpTerminate) {
+        const Comm::ConnectionPointer clientConn = http->getConn() ? http->getConn()->clientConnection : nullptr;
+        if (Comm::IsConnOpen(clientConn)) {
+            debugs(85, 3, "closing after Ssl::bumpTerminate ");
+            clientConn->close();
+        }
+        return;
+    }
+
     http->doCallouts();
 }
 #endif
index 645e000b3e67a5bdcecbdd45fe24e8dd171a4659..1fbffd56a92a73a2aa66764d21abd0e03833d35a 100644 (file)
@@ -88,6 +88,7 @@ Ssl::PeekingPeerConnector::checkForPeekAndSpliceMatched(const Ssl::BumpMode acti
         request->clientConnectionManager->sslBumpMode = finalAction;
         request->clientConnectionManager->serverBump()->act.step3 = finalAction;
     }
+    al->ssl.bumpMode = finalAction;
 
     if (finalAction == Ssl::bumpTerminate) {
         serverConn->close();