]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
8 years agoDo not forward HTTP requests to dead idle peers.
Eduard Bagdasaryan [Mon, 8 May 2017 07:04:05 +0000 (19:04 +1200)] 
Do not forward HTTP requests to dead idle peers.

Squid does not forward HTTP transactions to dead peers except when a
dead peer was idle for some time (ten peer connect timeouts or longer).
When the idle peer is still dead, this exception leads to transaction
delays (at best) or client disconnects/errors (at worst), depending on
Squid and client configurations/state. I am removing this exception.

The "use dead idle peer" heuristic was introduced as a small part of a
much bigger bug #14 fix (trunk r6631). AFAICT, the stated goal of the
feature was speeding up failure recovery: The heuristic may result in
HTTP transactions sent to a previously dead (but now alive) idle peer
earlier, before the peer is proven to be alive (using peer revival
mechanisms such as TCP probes). However, the negative side effects of
this heuristic outweigh its accidental benefits. If somebody needs Squid
to detect revived idle peers earlier, they need to add a different
probing mechanism that does not jeopardize HTTP transactions.

Nobody has spoken in defense of this feature on Squid mailing lists:
http://lists.squid-cache.org/pipermail/squid-users/2017-March/014785.html
http://lists.squid-cache.org/pipermail/squid-dev/2017-March/008308.html

The removed functionality was not used to detect revived peers. All peer
revival mechanisms (such as TCP probes) remain intact.

8 years agoReduced the chance of using an absent HttpHdrCc directive value.
Eduard Bagdasaryan [Mon, 8 May 2017 06:26:32 +0000 (18:26 +1200)] 
Reduced the chance of using an absent HttpHdrCc directive value.

Also reduced code duplication inside HttpReply::hdrExpirationTime().

8 years agoBug 4711: SubjectAlternativeNames is missing in some generated certificates
Christos Tsantilas [Mon, 8 May 2017 05:58:28 +0000 (17:58 +1200)] 
Bug 4711: SubjectAlternativeNames is missing in some generated certificates

Squid may generate certificates which have a Common Name, but do not have
a subjectAltName extension. For example when squid generated certificates
do not mimic an origin certificate or when the certificate adaptation
algorithm sslproxy_cert_adapt/setCommonName is used.

This is causes problems to some browsers, which validates a certificate using
the SubjectAlternativeNames but ignore the CommonName field.

This patch fixes squid to always add a SubjectAlternativeNames extension in
generated certificates which do not mimic an origin certificate.

Squid still will not add a subjectAltName extension when mimicking an origin
server certificate, even if that origin server certificate does not include
the subjectAltName extension. Such origin server may have problems when
talking directly to browsers, and patched Squid is not trying to fix those
problems.

This is a Measurement Factory project

8 years agoBug 4682: ignoring http_access deny when client-first bumping mode is used
Christos Tsantilas [Mon, 8 May 2017 05:51:20 +0000 (17:51 +1200)] 
Bug 4682: ignoring http_access deny when client-first bumping mode is used

Squid fails to identify HTTP requests which are tunneled inside an already
established client-first bumped tunnel, and this is results in ignoring
http_access denied for these requests.

This is a Measurement Factory project

8 years agoSSL-Bump: Second adaptation missing for CONNECTs
Christos Tsantilas [Mon, 8 May 2017 05:40:15 +0000 (17:40 +1200)] 
SSL-Bump: Second adaptation missing for CONNECTs

Squid does not send CONNECT request to adaptation services
if the "ssl_bump splice" rule matched at step 2. This adaptation
is important because the CONNECT request gains SNI information during
the second SslBump step. This is a regression bug, possibly caused by
the Squid bug 4529 fix (trunk commits r14913 and r14914).

This is a Measurement Factory project.

8 years agoCount failures and use peer-specific connect timeouts when tunneling.
Eduard Bagdasaryan [Sun, 7 May 2017 20:16:59 +0000 (08:16 +1200)] 
Count failures and use peer-specific connect timeouts when tunneling.

Fixed two bugs with tunneling CONNECT requests (or equivalent traffic)
through a cache_peer:

1. Not detecting dead cache_peers due to missing code to count peer
   connect failures. TLS/SSL-level failures were detected (for "tls"
   cache_peers) but TCP/IP connect(2) failures were not (for all peers).

2. Origin server connect_timeout used instead of peer_connect_timeout or
   a peer-specific connect-timeout=N (where configured).

The regular forwarding code path does not have the above bugs. This
change reduces code duplication across the two code paths (that
duplication probably caused these bugs in the first place), but a lot
more work is needed in that direction.

The 5-second forwarding timeout hack has been in Squid since
forward_timeout inception (r6733). It is not without problems (now
marked with an XXX), but I left it as is to avoid opening another
Pandora box. The hack now applies to the tunneling code path as well.

8 years agoBug 4589: ssl_crtd: returning zero on failure
Amos Jeffries [Thu, 4 May 2017 11:10:21 +0000 (23:10 +1200)] 
Bug 4589: ssl_crtd: returning zero on failure

8 years agoBug 4659: sslproxy_foreign_intermediate_certs does not work
Christos Tsantilas [Thu, 4 May 2017 10:59:52 +0000 (22:59 +1200)] 
Bug 4659: sslproxy_foreign_intermediate_certs does not work

The sslproxy_foreign_intermediate_certs directive does not work after r14769.
The bug is caused because of wrong use of X509_check_issued OpenSSL API call.

This is Measurement Factory project

8 years agoext_session_acl: cope with new logformat inputs
Amos Jeffries [Thu, 4 May 2017 10:12:39 +0000 (22:12 +1200)] 
ext_session_acl: cope with new logformat inputs

Now that Squid is sending an explicit '-' for the trailing %DATA parameter
if there were no acl parameters this helper needs to cope with it on
'active mode' session lookups when login/logout are not being performed.

8 years agoBug 4695: squidpurge: GCC 7 build errors
Lubos Uhliarik [Thu, 4 May 2017 10:03:19 +0000 (22:03 +1200)] 
Bug 4695: squidpurge: GCC 7 build errors

8 years agoRevert r15018
Amos Jeffries [Thu, 4 May 2017 10:01:40 +0000 (22:01 +1200)] 
Revert r15018

8 years agoBug 4692: SslBump breaks intercepted IPv6 connections
Trever Adams [Thu, 4 May 2017 09:32:52 +0000 (21:32 +1200)] 
Bug 4692: SslBump breaks intercepted IPv6 connections

8 years agoext_session_acl: cope with new logformat inputs
Amos Jeffries [Thu, 4 May 2017 06:05:54 +0000 (18:05 +1200)] 
ext_session_acl: cope with new logformat inputs

Now that Squid is sending an explicit '-' for the trailing %DATA parameter
if there were no acl parameters this helper needs to cope with it on
'active mode' session lookups when login/logout are not being performed.

8 years agoBug 4682: Fix ssl_bump "bump" action documentation
Christos Tsantilas [Thu, 4 May 2017 05:53:59 +0000 (17:53 +1200)] 
Bug 4682: Fix ssl_bump "bump" action documentation

Fixes squid documentation to correctly describe the squid behavior  when the
"bump" action is selected on step SslBump1. In this case squid selects
the client-first bumping mode.

This is a Measurement Factory project

8 years agoext_time_quota_acl: Add compile test to check dbopen() builds
Amos Jeffries [Thu, 4 May 2017 05:39:46 +0000 (17:39 +1200)] 
ext_time_quota_acl: Add compile test to check dbopen() builds

8 years agoCleanup: make ident parameter for FilledChecklist optional
Amos Jeffries [Thu, 4 May 2017 05:17:05 +0000 (17:17 +1200)] 
Cleanup: make ident parameter for FilledChecklist optional

8 years ago4.0.19 SQUID_4_0_19
Amos Jeffries [Sun, 2 Apr 2017 07:41:32 +0000 (19:41 +1200)] 
4.0.19

8 years agoBug 4610: cleanup of BerkleyDB related checks
Amos Jeffries [Sat, 1 Apr 2017 09:01:23 +0000 (22:01 +1300)] 
Bug 4610: cleanup of BerkleyDB related checks

Most of the logic seems to be hangovers from when session helper was
using the BerkleyDB v1.85 compatibility interface. Some of it is
possibly still necessary for the time_quota helper, but that helper has
not been using it so far and needs an upgrade to match what happened to
session helper.

Changes:

* The helpers needing -ldb will not be built unless the library and
headers are available. So we can drop the Makefile LIB_DB substitutions
and always just link -ldb explicitly to these helpers.

NP: Anyone who needs small minimal binaries, can build with the
--as-needed linker flag, or without these helpers. This change has no
effect on other helpers or the main squid binary.

* Since we no longer need to check if -ldb is necessary, we can drop the
configure.ac and acinclude logic detecting that.

* Remove unused AC_CHECK_DECL(dbopen, ...)
 - resolves one "FIXME"

* Fix the time_quota helper check to only scan db.h header file contents
if that file is existing, and if the db_185.h file is not being used
instead.

* Fix the session helper check to only try compiling with the db.h
header if that header actually exists.

* De-duplicate the library header file detection shared by configure.ac
and the helpers required.m4 files (after the above two changes).

* Remove unused DBLIB variable from configure.ac.

8 years agoAdd move semantics to Security::ServerOptions and Security::PeerOptions
Amos Jeffries [Fri, 31 Mar 2017 23:20:20 +0000 (12:20 +1300)] 
Add move semantics to Security::ServerOptions and Security::PeerOptions

This apparently will make the clear() operators faster as they no longer
have to data-copy.

  Detected by Coverity Scan. Issues 1364734 and 1364737

8 years agoSourceFormat Enforcement
Source Maintenance [Fri, 31 Mar 2017 18:14:13 +0000 (18:14 +0000)] 
SourceFormat Enforcement

8 years agoFix appending Http::HdrType::VIA code duplication
Eduard Bagdasaryan [Fri, 31 Mar 2017 14:45:07 +0000 (03:45 +1300)] 
Fix appending Http::HdrType::VIA code duplication

... resolving Via header truncation at 1024 bytes.

Also fixes the generated Via values for non-HTTP protocols.

8 years agoBug 4671 pt4: refactor Format::assemble()
Amos Jeffries [Fri, 31 Mar 2017 13:52:56 +0000 (02:52 +1300)] 
Bug 4671 pt4: refactor Format::assemble()

* replace the String local with an SBuf to get appendf()

* overdue removal of empty lines and '!= NULL' conditions

* reduce scope redux for many out assignments

* use sizeof(tmp) instead of '1024'

* Fixes many GCC 7 compile errors from snprintf() being called with a
  too-small buffer.

* update the for-loops in Adaptation::History to C++11 and produce output
  in an SBuf. Removing need for iterator typedef's and resolving more GCC 7
  warnings about too-small buffers for snprintf().

8 years agoBug 4671 pt3: remove limit on FTP realm strings
Amos Jeffries [Fri, 31 Mar 2017 12:53:33 +0000 (01:53 +1300)] 
Bug 4671 pt3: remove limit on FTP realm strings

Convert ftpRealm() from generating char* to SBuf. This fixes issues identified
by GCC 7 where the realm string may be longer than the available buffer and
gets truncated.
The size of the buffer was making the occurance rather rare, but it is still
possible.

8 years agoDetail swapfile header inconsistencies.
Eduard Bagdasaryan [Fri, 31 Mar 2017 12:34:45 +0000 (01:34 +1300)] 
Detail swapfile header inconsistencies.

Squid may fail to load cache entry metadata for several very different
reasons, including the following two relatively common ones:

* A cache_dir entry corruption.
* Huge cache_dir entry metadata that does not fit into the I/O buffer
  used for loading entry metadata.

Knowing the exact failure reason may help triage and guide development.
We refactored existing checks to distinguish various error cases,
including the two above. Refactoring also reduced code duplication.

These improvements also uncovered and fixed a null pointer dereference
inside ufsdump.cc (but ufsdump does not even build right now for reasons
unrelated to these changes).

8 years agoSourceFormat Enforcement
Source Maintenance [Fri, 31 Mar 2017 12:14:21 +0000 (12:14 +0000)] 
SourceFormat Enforcement

8 years agoFixed URI scheme case-sensitivity treatment broken since r14802.
Alex Rousskov [Fri, 31 Mar 2017 12:06:22 +0000 (01:06 +1300)] 
Fixed URI scheme case-sensitivity treatment broken since r14802.

A parsed value for the AnyP::UriScheme image constructor parameter was
stored without toLower() canonicalization for known protocols (e.g.,
Squid would store "HTTP" instead of "http" after successfully parsing
"HTTP://EXAMPLE.COM/" in urlParseFinish()). Without that
canonicalization step, Squid violated various HTTP caching rules related
to URI comparison (and served fewer hits) when dealing with absolute
URLs containing non-lowercase HTTP scheme.

According to my limited tests, URL-based ACLs are not affected by this
bug, but I have not investigated how URL-based ACL code differs from
caching code when it comes to stored URL access and whether some ACLs
are actually affected in some environments.

8 years agoFix two read-ahead problems related to delay pools (or lack of thereof).
Eduard Bagdasaryan [Fri, 31 Mar 2017 11:07:18 +0000 (00:07 +1300)] 
Fix two read-ahead problems related to delay pools (or lack of thereof).

1. Honor EOF on Squid-to-server connections with full read ahead buffers
   and no clients when --enable-delay-pools is used without any delay
   pools configured in squid.conf.

Since trunk r6150.

Squid delays reading from the server after buffering read_ahead_gap
bytes that are not yet sent to the client. A delayed read is normally
resumed after Squid sends more buffered bytes to the client. See
readAheadPolicyCanRead() and kickReads().

However, Squid was not resuming the delayed read after all Store clients
were gone. If quick_abort prevents Squid from immediately closing the
corresponding Squid-to-server connection, then the connection gets stuck
until read_timeout (15m), even if the server closes much sooner, --
without reading from the server, Squid cannot detect the connection
closure. The affected connections enter the CLOSE_WAIT state.

Kicking delayed read when the last client leaves fixes the problem. The
removal of any client, including the last one, may change
readAheadPolicyCanRead() answer and, hence, deserves a kickReads() call.

Why "without any delay pools configured in squid.conf"? When classic
(i.e., delay_pool_*) delay pools are configured, Squid kicks all delayed
reads every second. That periodic kicking is an old design bug, but it
resumes stuck reads when all Store clients are gone. Without classic
delay pools, there is no periodic kicking. This fix does not address
that old bug but removes Squid hidden dependence on its side effect.

Note that the Squid-to-server connections with full read-ahead buffers
still remain "stuck" if there are non-reading clients. There is nothing
Squid can do about them because we cannot reliably detect EOF without
reading at least one byte and such reading is not allowed by the read
ahead gap. In other words, non-reading clients still stall server
connections.

While fixing this, I moved all CheckQuickAbort() tests into
CheckQuickAbortIsReasonable() because we need a boolean function to
avoid kicking aborted entries and because the old separation was rather
awkward -- CheckQuickAbort() contained "reasonable" tests that were not
in CheckQuickAbortIsReasonable(). All the aborting tests and their order
were preserved during this move. The moved tests gained debugging.

According to the existing test order in CheckQuickAbortIsReasonable(),
the above problem can be caused by:

* non-private responses with a known content length
* non-private responses with unknown content length, having quick_abort_min
  set to -1 KB.

2. Honor read_ahead_gap with --disable-delay-pools.

Since trunk r13954.

This fix also addresses "Perhaps these two calls should both live
in MemObject" comment and eliminates existing code duplication.

8 years agoBug 4688: various typo error(s) in man page(s)
Lubos Uhliarik [Fri, 31 Mar 2017 08:57:46 +0000 (21:57 +1300)] 
Bug 4688: various typo error(s) in man page(s)

8 years agolibtrie: Fix 'make check' when run before 'make all'
Amos Jeffries [Fri, 31 Mar 2017 08:54:35 +0000 (21:54 +1300)] 
libtrie: Fix 'make check' when run before 'make all'

8 years agoDocs: update refresh_pattern description regarding 'max' option
Garri Djavadyan [Fri, 31 Mar 2017 08:52:06 +0000 (21:52 +1300)] 
Docs: update refresh_pattern description regarding 'max' option

8 years agoBug 4671 pt2: various GCC 7 compile errors
Amos Jeffries [Sun, 12 Mar 2017 12:12:44 +0000 (01:12 +1300)] 
Bug 4671 pt2: various GCC 7 compile errors

8 years agoBug 4657: delay IDENT until after PROXY protocol handling
Amos Jeffries [Sun, 5 Mar 2017 09:39:11 +0000 (22:39 +1300)] 
Bug 4657: delay IDENT until after PROXY protocol handling

8 years agoBug 4674: delay_parameters for class 3 and 4 assertion failed
Amos Jeffries [Thu, 2 Mar 2017 16:02:26 +0000 (05:02 +1300)] 
Bug 4674: delay_parameters for class 3 and 4 assertion failed

8 years agosquidclient: Fix missing error handling on PUT
Amos Jeffries [Thu, 2 Mar 2017 14:44:26 +0000 (03:44 +1300)] 
squidclient: Fix missing error handling on PUT

 Detected by Coverity Scan. Issue 1364710

8 years agoCleanup HttpStateData::peerSupportsConnectionPinning
Amos Jeffries [Thu, 2 Mar 2017 14:09:05 +0000 (03:09 +1300)] 
Cleanup HttpStateData::peerSupportsConnectionPinning

* move local variable lookups and creation as late as possible. This
  speeds up a bunch of cases where those variables are never needed.

* resolve an XXX about checking Proxy-Support header contents in an
  case-insensitive way, while also simplifying the test.

8 years agoRemove some NULL references from adaptation/icap/ModXact.cc
Amos Jeffries [Thu, 2 Mar 2017 11:52:42 +0000 (00:52 +1300)] 
Remove some NULL references from adaptation/icap/ModXact.cc

The issue is that Coverity Scan gets confused by implicit casting of NULL
to a Pointer into thinking that 'true' comparison is possible when NULL
is involved. The != should still compile to the correct checks.

  Coverity Scan issue 1364725.

8 years agoCleanup: convert SBuf to C++11 initialization
Amos Jeffries [Thu, 2 Mar 2017 09:51:51 +0000 (22:51 +1300)] 
Cleanup: convert SBuf to C++11 initialization

 Detected by Coverity Scan.

8 years agoNative FTP relay: NAT and TPROXY interception fixes
Alexander Gozman [Sun, 26 Feb 2017 00:10:42 +0000 (13:10 +1300)] 
Native FTP relay: NAT and TPROXY interception fixes

8 years agoCrypto-NG: initial GnuTLS support for encrypted server connections
Amos Jeffries [Thu, 23 Feb 2017 13:31:16 +0000 (02:31 +1300)] 
Crypto-NG: initial GnuTLS support for encrypted server connections

Make significant changes to how the options= config settings are
handled internally since GnuTLS does not expose the priority_t
implementation details like OpenSSL. They are also applied to the
session object instead of to the context.

The Security::SessionPointer is converted to std::shared_ptr. This is
required because GnuTLS does not expose the locking like OpenSSL. Since
we store the SessionPointer to fde::Table::ssl we can always access it
from there one way or another and there is actually no need for OpenSSL
locking sessions now.

Most of the remaining session lifecycle logic is moved to
security/Session.* and given a generic API. Only some client-connection
and SSL-Bump related setup remains in ssl/.

A fair amount more debug is added along with some text changes doing
s/SSL/TLS/ in code comments and debug outputs.

The Security::ContextPointer is also converted to a std::shared_ptr. As
with SessionPointer these are stored in the long-term global config
objects and referenced from there as needed.

Support for https:// URL outgoing connections is enabled with GnuTLS.

8 years agoext_kerberos_ldap_group_acl: fix unused value warnings
Amos Jeffries [Mon, 20 Feb 2017 05:05:40 +0000 (18:05 +1300)] 
ext_kerberos_ldap_group_acl: fix unused value warnings

 Detected by Coverity Scan. Issues 1364748 and 1364749.

8 years agoCheck that -k argument is provided before trying to use it.
Amos Jeffries [Mon, 20 Feb 2017 05:04:45 +0000 (18:04 +1300)] 
Check that -k argument is provided before trying to use it.

 Detected by Coverity Scan. Issue 1364726.

8 years agoFix missing CRLF on FTP timeout ABORT commands
Amos Jeffries [Mon, 20 Feb 2017 05:02:45 +0000 (18:02 +1300)] 
Fix missing CRLF on FTP timeout ABORT commands

8 years agoBug 4663: GCC compile errors with optimization level -O3
Amos Jeffries [Mon, 20 Feb 2017 04:29:18 +0000 (17:29 +1300)] 
Bug 4663: GCC compile errors with optimization level -O3

8 years agodigest_ldap_auth: Add -r option to clamp the realm to a fixed value
Emmanuel Fuste [Mon, 20 Feb 2017 02:45:32 +0000 (15:45 +1300)] 
digest_ldap_auth: Add -r option to clamp the realm to a fixed value

Some historic Digest Auth implementations do not include the realm in the
digest password attribute. The password is effectively stored as "HA1"
instead of "REALM:HA1".

The realm cannot simply be ignored due to:
 1) the realm is both the salting value used within the hash and the
scope limitation on what inputs from HTTP are used to compare against
the A1, and
 2) Squid does not itself verify the realm received was the one offered
and leaves the comparison to the backend system. There is some
possibility the authentication system is using multiple security realms
and Squids realm string is just an offer.

Not having realm tied to the credentials in the backend storage leaves
this particular helper with no other option but to trust the realm sent
(probably) over clear-text by any client/attacker actually matches the
salting. That allows remote senders to manipulate the realm string they
send to perform a collision attack against the stored password.
 They no longer have to find and prove knowledge of the password. But
just find a collision for its hash vs arbitrary realm strings.

Old Digest systems are not the safest things to begin with. They also
tend to use MD5 hashing which was the only one available for many years
and relatively easy to find collisions for.

To resolve all these problems allow the -l parameter to accept an empty
string ('-l "" ') when the -r option provides a fixed realm.

Also, fix several typos in the help text.

8 years agoGCC7: raise FTP Gateway CTRL channel buffer to 16KB
Amos Jeffries [Thu, 9 Feb 2017 02:41:58 +0000 (15:41 +1300)] 
GCC7: raise FTP Gateway CTRL channel buffer to 16KB

Fixes
 error: %s directive output may be truncated writing up to 8191 bytes
        into a region of size 1019
 note: snprintf output between 8 and 8199 bytes into a destination of
       size 1024

8 years agoFix uninitialized variable in libadaptation
Amos Jeffries [Thu, 9 Feb 2017 02:40:45 +0000 (15:40 +1300)] 
Fix uninitialized variable in libadaptation

The grokBool() parse method does not alter the bool parameter on invalid
inputs. This results in encrypt local variable being used uninitialized.

8 years agoBump SSL client on [more] errors encountered before ssl_bump evaluation
Christos Tsantilas [Tue, 7 Feb 2017 23:11:33 +0000 (12:11 +1300)] 
Bump SSL client on [more] errors encountered before ssl_bump evaluation

... such as ERR_ACCESS_DENIED with HTTP/403 Forbidden triggered by an
http_access deny rule match.

The old code allowed ssl_bump step1 rules to be evaluated in the
presence of an error. An ssl_bump splicing decision would then trigger
the useless "send the error to the client now" processing logic instead
of going down the "to serve an error, bump the client first" path.

Furthermore, the ssl_bump evaluation result itself could be surprising
to the admin because ssl_bump (and most other) rules are not meant to be
evaluated for a transaction in an error state. This complicated triage.

Also polished an important comment to clarify that we want to bump on
error if (and only if) the SslBump feature is applicable to the failed
transaction (i.e., if the ssl_bump rules would have been evaluated if
there were no prior errors). The old comment could have been
misinterpreted that ssl_bump rules must be evaluated to allow an
"ssl_bump splice" match to hide the error.

This is a Measurement Factory project.

8 years ago4.0.18 SQUID_4_0_18
Amos Jeffries [Sun, 5 Feb 2017 21:14:37 +0000 (10:14 +1300)] 
4.0.18

8 years agoFix crash when configuring with invalid delay_parameters restore value.
Alex Rousskov [Sun, 5 Feb 2017 20:56:55 +0000 (09:56 +1300)] 
Fix crash when configuring with invalid delay_parameters restore value.

... like none/none. Introduced in r13701 which fixed another, much
bigger delay_parameters parsing bug.

TODO: Reject all invalid input, including restore/max of "-/100".

TODO: Fix misleading/wrong associated error messages. For example:
  ERROR: invalid delay rate 'none/none'. Expecting restore/max or 'none'
  ERROR: restore rate in '1/none' is not a number.

8 years agoFix Auth::UserRequest::denyMessage() misuse.
Eduard Bagdasaryan [Sun, 5 Feb 2017 20:52:41 +0000 (09:52 +1300)] 
Fix Auth::UserRequest::denyMessage() misuse.

This method was improperly used in contexts where actually
Auth::UserRequest::setDenyMessage() expected. Probably the reason was
that both denyMessage() and getDenyMessage() were not constant,
provoking such 'misuse'.

Also placed some common code into UserRequest::denyMessageFromHelper(),
eliminating code duplication. Though there are still many places
where code is duplicated inside auth/ntlm/UserRequest.cc and
auth/negotiate/UserRequest.cc.

8 years agoBug 4661: compile error 'warning: _XPG4_2 redefined' with GCC on Solaris 10
Amos Jeffries [Sun, 5 Feb 2017 06:15:44 +0000 (19:15 +1300)] 
Bug 4661: compile error 'warning: _XPG4_2 redefined' with GCC on Solaris 10

8 years agoPrep for 3.5.24
Amos Jeffries [Sat, 28 Jan 2017 03:36:52 +0000 (16:36 +1300)] 
Prep for 3.5.24

8 years agoSSLv2 records force SslBump bumping despite a matching step2 peek rule.
Christos Tsantilas [Fri, 27 Jan 2017 14:50:22 +0000 (03:50 +1300)] 
SSLv2 records force SslBump bumping despite a matching step2 peek rule.

If Squid receives a valid TLS Hello encapsulated into ancient SSLv2
records (observed on Solaris 10), the old code ignored the step2 peek
decision and bumped the transaction instead.
Now Squid peeks (or stares) at the origin server as configured, even
after detecting (and parsing) SSLv2 records.

This is a Measurement Factory project.

8 years agoComplain about malformed 64bit header values, not the valid ones.
Alex Rousskov [Fri, 27 Jan 2017 13:28:31 +0000 (02:28 +1300)] 
Complain about malformed 64bit header values, not the valid ones.

Added this regression in r14819, apparently confused by my own
unfortunate "bad is true" httpHeaderNoteParsedEntry(error) API.

8 years agoBug 4636: assertion failed: client_side.cc:1448: 'byteCount > 0 && byteCount <= inBuf...
Amos Jeffries [Fri, 27 Jan 2017 13:24:30 +0000 (02:24 +1300)] 
Bug 4636: assertion failed: client_side.cc:1448: 'byteCount > 0 && byteCount <= inBuf.length()'

8 years agoMitigate DoS attacks that use client-initiated SSL/TLS renegotiation.
Christos Tsantilas [Fri, 27 Jan 2017 13:18:42 +0000 (02:18 +1300)] 
Mitigate DoS attacks that use client-initiated SSL/TLS renegotiation.

There is a well-known DoS attack using client-initiated SSL/TLS
renegotiation. The severety or uniqueness of this attack method
is disputed, but many believe it is serious/real.
There is even a (disputed) CVE 2011-1473:
    https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1473

The old Squid code tried to disable client-initiated renegotiation, but
it did not work reliably (or at all), depending on Squid version, due
to OpenSSL API changes and conflicting SslBump callbacks. That
code is now removed and client-initiated renegotiations are allowed.

With this change, Squid aborts the TLS connection, with a level-1 ERROR
message if the rate of client-initiated renegotiate requests exceeds
5 requests in 10 seconds (approximately). This protection and the rate
limit are currently hard-coded but the rate is not expected to be
exceeded under normal circumstances.

This is a Measurement Factory project.

8 years agoFix some spelling mistakes
Frederic Bourgeois [Fri, 27 Jan 2017 11:23:08 +0000 (00:23 +1300)] 
Fix some spelling mistakes

8 years agoCleanup: convert Delay Pool classes to MEMPROXY
Amos Jeffries [Fri, 27 Jan 2017 11:04:30 +0000 (00:04 +1300)] 
Cleanup: convert Delay Pool classes to MEMPROXY

8 years agoBug 4610: fix 'Assigning a negative value to an implicit unsigned bitfield' on Solaris 11
Stefan Kruger [Fri, 27 Jan 2017 08:38:51 +0000 (21:38 +1300)] 
Bug 4610: fix 'Assigning a negative value to an implicit unsigned bitfield' on Solaris 11

8 years agosquidclient: link GnuTLS library debug to -v level display
Amos Jeffries [Fri, 27 Jan 2017 00:37:07 +0000 (13:37 +1300)] 
squidclient: link GnuTLS library debug to -v level display

8 years agoUpdate External ACL helpers error handling and caching
Christos Tsantilas [Thu, 26 Jan 2017 17:46:17 +0000 (06:46 +1300)] 
Update External ACL helpers error handling and caching

The helper protocol for external ACLs [1] defines three possible return values:
   OK - Success. ACL test matches.
   ERR - Success. ACL test fails to match.
   BH - Failure. The helper encountered a problem.

The external acl helpers distributed with squid currently do not follow this
definition. For example, upon connection error, ERR is returned:

   $ ext_ldap_group_acl ... -d
   ext_ldap_group_acl: WARNING: could not bind to binddn 'Can't contact LDAP server'
   ERR

This does not allow to distinguish "no match" and "error" either and
therefore negative caches "ERR", also in the case of an error.

Moreover there are multiple problems inside squid when trying to handle BH
responses:
  - Squid-5 and Squid-4 retry requests for BH responses but crashes after the
    maximum retry number (currently 2) is reached.
  - If an external acl helper return always BH (eg because the LDAP server is
    down) squid sends infinitely new request to the helper.

This is a Measurement Factory project

8 years agoFix "Source and destination overlap in memcpy" Valgrind errors
Eduard Bagdasaryan [Tue, 24 Jan 2017 11:02:51 +0000 (00:02 +1300)] 
Fix "Source and destination overlap in memcpy" Valgrind errors

Before this patch, source and destination arguments in
log_quoted_string() could point to the same static memory area, causing
multiple Valgrind-reported errors. Fixed by creating another buffer to
store quoted-processed output string.

8 years agoReduce crashes due to unexpected ClientHttpRequest termination.
Christos Tsantilas [Sun, 22 Jan 2017 11:43:44 +0000 (00:43 +1300)] 
Reduce crashes due to unexpected ClientHttpRequest termination.

The underlying problem has been known since r13480: If a
ClientHttpRequest job ends without Http::Stream (and ConnStateData)
knowledge, then Squid is likely to segfault or assert. This patch does
not resolve the underlying issue (a proper fix would require
architectural changes in a consensus-lacking area) but makes an
unexpected ClientHttpRequest job destruction less likely.

BodyPipe and Adaptation-related exceptions are the major causes of
unexpected ClientHttpRequest job destruction. This patch handles them by
closing the client connection. Connection closure should trigger an
orderly top-down cleanup, including Http::Stream, ConnStateData, and
ClientHttpRequest destruction.

If there is no connection to close, then the exception is essentially
ignored with a level-1 error message disclosing the problem. The side
effects of ignoring such exceptions are unknown, but without a client
connection, it is our hope that they would be relatively benign.

This is a Measurement Factory project.

8 years agoAdd several missing copyright blurbs
Amos Jeffries [Sat, 7 Jan 2017 11:02:40 +0000 (00:02 +1300)] 
Add several missing copyright blurbs

8 years agoDetect HTTP header ACL issues
Amos Jeffries [Sat, 7 Jan 2017 11:01:20 +0000 (00:01 +1300)] 
Detect HTTP header ACL issues

rep_header and req_header ACL types cannot match multiple different
headers in one test (unlike Squid-2 appears to have done). Produce
an ERROR and ignore the extra line(s) instead of silently changing
all the previous regex to match the second header name.

Also detect and ERROR when header name is missing entirely. Ignore
these lines instead of asserting.

8 years agoSourceFormat Enforcement
Source Maintenance [Sun, 1 Jan 2017 06:14:00 +0000 (06:14 +0000)] 
SourceFormat Enforcement

8 years agoSourceFormat Enforcement
Source Maintenance [Sun, 1 Jan 2017 00:14:42 +0000 (00:14 +0000)] 
SourceFormat Enforcement

8 years agoBug 4599 pt6: Restrict safe renegotiation disable to OpenSSL 1.0 and older
Christos Tsantilas [Sat, 31 Dec 2016 02:46:50 +0000 (15:46 +1300)] 
Bug 4599 pt6: Restrict safe renegotiation disable to OpenSSL 1.0 and older

From OpenSSL 1.1.0 documentation:
 "OpenSSL always attempts to use secure renegotiation as described in RFC5746.
  This counters the prefix attack described in CVE-2009-3555 and elsewhere."

8 years agoBug 4599 pt5: various OpenSSL-1.x API compatibility fixes
Christos Tsantilas [Sat, 31 Dec 2016 02:45:59 +0000 (15:45 +1300)] 
Bug 4599 pt5: various OpenSSL-1.x API compatibility fixes

8 years agoBug 4599 pt4: Disable RSA weak ephemeral key exchange for OpenSSL-1.1
Christos Tsantilas [Sat, 31 Dec 2016 02:44:41 +0000 (15:44 +1300)] 
Bug 4599 pt4: Disable RSA weak ephemeral key exchange for OpenSSL-1.1

From OpenSSL  changeLog:
     Remove support for all 40 and 56 bit ciphers.  This includes all the export
     ciphers who are no longer supported and drops support the ephemeral RSA key
     exchange. The LOW ciphers currently doesn't have any ciphers in it.
     [Kurt Roeckx]

OpenSSL 1.1.0  drops EXPORT ciphers and ephemeral RSA. The ssl_temp_rsa_cb used
here. The OpenSSL manual for this function is:
  https://wiki.openssl.org/index.php/Manual:SSL_CTX_set_tmp_rsa_callback(3)

8 years agobasic_sasl_auth: Add copyright blurb to SASL config file
Amos Jeffries [Mon, 26 Dec 2016 02:29:24 +0000 (15:29 +1300)] 
basic_sasl_auth: Add copyright blurb to SASL config file

8 years agoFix GCC6: unused local variable 'weInitiatedThisClosure'
Amos Jeffries [Mon, 26 Dec 2016 02:28:24 +0000 (15:28 +1300)] 
Fix GCC6: unused local variable 'weInitiatedThisClosure'

8 years agoBug 3940 pt2: Make 'cache deny' do what is documented
Amos Jeffries [Mon, 26 Dec 2016 02:15:22 +0000 (15:15 +1300)] 
Bug 3940 pt2: Make 'cache deny' do what is documented

Instead of overriding whatever cacheability was previously set to
(including changing non-cacheables to be cacheable) actually
prevent both cache read and write.

This 'regression' appears after initial bug 3940 fix.

8 years ago4.0.17 SQUID_4_0_17
Amos Jeffries [Fri, 16 Dec 2016 04:14:12 +0000 (17:14 +1300)] 
4.0.17

8 years agoDo not share private responses with collapsed client(s).
Eduard Bagdasaryan [Fri, 16 Dec 2016 02:43:39 +0000 (15:43 +1300)] 
Do not share private responses with collapsed client(s).

This excessive sharing problem with collapsed forwarding code has
several layers. In most cases, the core CF code does not share
uncachable or private response with collapsed clients because of the
refreshCheckHTTP() check. However, some responses might not be subject
to that (or equivalent) check. More importantly, collapsed revalidation
code does not check its responses at all and, hence, easily shares
private responses.

This short-term fix incorrectly assumes that an entry may become private
(KEY_PRIVATE) only when it cannot be shared among multiple clients
(e.g., because of a Cache-Control:private response header). However,
there are a few other cases when an entry becomes private. One of them
is a DISK_NO_SPACE_LEFT error inside storeSwapOutFileClosed() where
StoreEntry::releaseRequest() sets KEY_PRIVATE for a sharable entry [that
may still be perfectly preserved in the memory cache]. Consequently, the
short-term fix reduces CF effectiveness. The extent of this reduction is
probably environment-dependent.

Also: do not re-use SET_COOKIE headers for collapsed revalidation slaves,
i.e., adhere to the same requirement as for regular response HITs.

8 years agoBug 2258 pt2: bypassing cache but not destroying cache entry
Garri Djavadyan [Thu, 15 Dec 2016 07:54:42 +0000 (20:54 +1300)] 
Bug 2258 pt2: bypassing cache but not destroying cache entry

8 years agoCleanup: Refactor custom ACL-controlled actions configuration code.
Eduard Bagdasaryan [Sun, 11 Dec 2016 18:23:23 +0000 (07:23 +1300)] 
Cleanup: Refactor custom ACL-controlled actions configuration code.

* Reduced parsing code duplication by adding ParseAclWithAction().

* Used functors for generic action-to-string conversions. It is possible
  now to perform such conversions providing lambda expressions.

* Used vectors of strings instead of C-style arrays for storing
  conversion tables and check against bounds with vector::at().

8 years agoBug 4169: HIT marked as MISS when If-None-Match does not match
Garri Djavadyan [Sun, 11 Dec 2016 09:46:22 +0000 (22:46 +1300)] 
Bug 4169: HIT marked as MISS when If-None-Match does not match

8 years agoHTTP/1.1: Add registered codes entry for new 103 (Early Hints) status code
Amos Jeffries [Sat, 10 Dec 2016 22:36:57 +0000 (11:36 +1300)] 
HTTP/1.1: Add registered codes entry for new 103 (Early Hints) status code

8 years agoBug 3940 (partial): hostHeaderVerify failures MISS when they should be HIT
Garri Djavadyan [Fri, 9 Dec 2016 04:42:34 +0000 (17:42 +1300)] 
Bug 3940 (partial): hostHeaderVerify failures MISS when they should be HIT

This fixes the critical condition leading to the HIT. However not all
code is correctly setting flags.noCache and flags.cacheable (see bugzilla).
So there may be other fixes needed after this.

8 years agoBug 2258: bypassing cache but not destroying cache entry
Garri Djavadyan [Fri, 9 Dec 2016 03:01:51 +0000 (16:01 +1300)] 
Bug 2258: bypassing cache but not destroying cache entry

8 years agoBug 4406: SIGSEV in TunnelStateData::handleConnectResponse() during reconfigure and...
Michael Buchau [Fri, 9 Dec 2016 01:44:19 +0000 (14:44 +1300)] 
Bug 4406: SIGSEV in TunnelStateData::handleConnectResponse() during reconfigure and restart

8 years agoSupport IPv6 NAT with PF for NetBSD and FreeBSD
Egervary Gergely [Fri, 9 Dec 2016 00:49:36 +0000 (13:49 +1300)] 
Support IPv6 NAT with PF for NetBSD and FreeBSD

8 years agoCleanup: remove raw-pointer SSL* from ServerBump class API
Amos Jeffries [Thu, 8 Dec 2016 14:36:30 +0000 (03:36 +1300)] 
Cleanup: remove raw-pointer SSL* from ServerBump class API

8 years agoBug 3290: authenticate_ttl not working for digest authentication
Garri Djavadyan [Tue, 29 Nov 2016 18:49:22 +0000 (07:49 +1300)] 
Bug 3290: authenticate_ttl not working for digest authentication

8 years agoBug 4007: Hang on DNS query with dead-end CNAME
Stephen Baynes [Tue, 29 Nov 2016 17:27:42 +0000 (06:27 +1300)] 
Bug 4007: Hang on DNS query with dead-end CNAME

DNS lookup recursion no longer occurs. ipcacheParse() return values are no
longer useful.

Also, cleanup the debugging output.

8 years agoCleanup: use return after self_destruct() to make Coverity happier
Amos Jeffries [Tue, 29 Nov 2016 16:38:45 +0000 (05:38 +1300)] 
Cleanup: use return after self_destruct() to make Coverity happier

 Detected by Coverity Scan. Issue 1154218.

8 years agoCleanup: replace HTTP Request bitmap flags with boolean
Amos Jeffries [Tue, 29 Nov 2016 04:50:02 +0000 (17:50 +1300)] 
Cleanup: replace HTTP Request bitmap flags with boolean

8 years agoBug 4174 partial: fix Write.cc:41 "!ccb->active()" assertion.
Christos Tsantilas [Mon, 28 Nov 2016 10:08:16 +0000 (23:08 +1300)] 
Bug 4174 partial: fix Write.cc:41 "!ccb->active()" assertion.

The following sequence of events triggers this assertion:
  - The server sends an 1xx control message.
  - http.cc schedules ConnStateData::sendControlMsg call.
  - Before sendControlMsg is fired, http.cc detects an error (e.g., I/O
    error or timeout) and starts writing the reply to the user.
  - The ConnStateData::sendControlMsg is fired, starts writing 1xx, and
    hits the "no concurrent writes" assertion.

We could only reproduce this sequence in the lab after changing Squid
code to trigger a timeout at the right moment, but the sequence looks
plausible. Other event sequences might result in the same outcome.

To avoid concurrent writes, Squid now drops the control message if
Http::One::Server detects that a reply is already being written. Also,
ConnStateData delays reply writing until a pending control message write
has been completed.

This is a Measurement Factory project.

8 years agoFix Null pointer dereferences after rev.14913
Amos Jeffries [Sat, 19 Nov 2016 16:06:10 +0000 (05:06 +1300)] 
Fix Null pointer dereferences after rev.14913

on_unsupported_protocol with non-HTTP requests occurs without
an HTTP request object. Some ACLs will not be possible to check
but that is not a reason to crash.

 Detected by Coverity Scan. Issue 1394291.

8 years agoBug 4599 pt3: use wrapper functions to access BIO object internals
Christos Tsantilas [Sat, 19 Nov 2016 15:53:46 +0000 (04:53 +1300)] 
Bug 4599 pt3: use wrapper functions to access BIO object internals

8 years agoTLS: Add ErrorString() function to libsecurity API
Amos Jeffries [Sat, 19 Nov 2016 15:46:24 +0000 (04:46 +1300)] 
TLS: Add ErrorString() function to libsecurity API

To convert library error codes to strings in a library agnostic way.

8 years agoBug 4630: user credentials cache cleanup not re-scheduled
Garri Djavadyan [Sat, 19 Nov 2016 06:52:34 +0000 (19:52 +1300)] 
Bug 4630: user credentials cache cleanup not re-scheduled

8 years agoBug 4599 pt2: use functor for locking in libsecurity Pointers
Amos Jeffries [Fri, 18 Nov 2016 20:21:39 +0000 (09:21 +1300)] 
Bug 4599 pt2: use functor for locking in libsecurity Pointers

8 years agoBug 3533: Cache still valid after HTTP/1.1 303 See Other
Garri Djavadyan [Fri, 18 Nov 2016 12:59:09 +0000 (01:59 +1300)] 
Bug 3533: Cache still valid after HTTP/1.1 303 See Other

RFC7231 does not mention 303 response as non-cacheable.
So, assuming that means it *is* cacheable.

8 years agoFix segfault via Ftp::Client::readControlReply
Christos Tsantilas [Fri, 18 Nov 2016 12:57:25 +0000 (01:57 +1300)] 
Fix segfault via Ftp::Client::readControlReply

Added nil dereference checks for Ftp::Client::ctrl.conn, including:
- Ftp::Client::handlePasvReply() and handleEpsvReply() that dereference
  ctrl.conn in DBG_IMPORTANT messages.
- Many functions inside FtpClient.cc and FtpGateway.cc files.

TODO: We need to find a better way to handle nil ctrl.conn. It is only
a matter of time when we forget to add another dereference check or
discover a place we missed during this change.

Also disabled forwarding of EPRT and PORT commands to origin servers.
Squid support for those commands is broken and their forwarding may
cause segfaults (bug #4004). Active FTP is still supported, of course.

This is a Measurement Factory project

8 years agoFix some missing returns after rev.14933
Amos Jeffries [Fri, 11 Nov 2016 04:29:21 +0000 (17:29 +1300)] 
Fix some missing returns after rev.14933

8 years agoBug 3379: Combination of If-Match and a Cache Hit result in TCP Connection Failure
Garri Djavadyan [Fri, 11 Nov 2016 02:08:24 +0000 (15:08 +1300)] 
Bug 3379: Combination of If-Match and a Cache Hit result in TCP Connection Failure

8 years agoBranch 5.0.0
Source Maintenance [Wed, 9 Nov 2016 13:33:41 +0000 (13:33 +0000)] 
Branch 5.0.0

8 years agoTLS: use Security::SessionPointer for helper state maintenance
Amos Jeffries [Tue, 8 Nov 2016 06:37:32 +0000 (19:37 +1300)] 
TLS: use Security::SessionPointer for helper state maintenance