1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
Commit Graph

219 Commits

Author SHA1 Message Date
reyk
dbb03cc582 Disable client-initiated TLS renegotiation by default.
It is rarely needed and imposes a light DoS risk.  LibreSSL's libssl
allows to turn it off with a simple SSL_OP_NO_CLIENT_RENEGOTIATION
option instead of the complicated implementation that was used before.
It now turns it off completely instead of allowing one initial
client-initiated renegotiation.

It can still be enabled with "tls client-renegotiation".

ok benno@ beck@ jsing@
2017-02-02 08:24:16 +00:00
reyk
871fc12c55 Stop accessing verbose and debug variables from log.c directly.
This replaces log_verbose() and "extern int verbose" with the two functions
log_setverbose() and log_getverbose().

Pointed out by benno@
OK krw@ eric@ gilles@ (OK gilles@ for the snmpd bits as well)
2017-01-09 14:49:21 +00:00
jca
829b794569 Fix tcp ip ttl / minttl on IPv6 sockets.
ok florian@
2016-11-10 13:21:58 +00:00
benno
27b47d921a fix DEBUG build after ps->ps_instance change
ok reyk@ bluhm@
2016-09-29 22:04:28 +00:00
reyk
2166201edd spacing 2016-09-26 16:25:16 +00:00
jsg
ebf5acd417 use sizeof instead of constant 16 in function calls
suggested by and ok reyk@
2016-09-23 12:06:15 +00:00
jsg
aad4fa7e1a Change function arguments from "unsigned char keyname[16]" to
"unsigned char *keyname" to make it clear that an array size can not
be inferred.  Suggested by millert@
2016-09-22 07:56:48 +00:00
jsg
50e62dd32f correct invalid use of sizeof
ok krw@ millert@ claudio@
2016-09-22 06:18:58 +00:00
reyk
586b5f8a93 Split "struct relayd" into two structs: "struct relayd" and "struct
relayd_config".  This way we can send all the relevant global
configuration to the children, not just the flags and the opts.

With input from and
OK claudio@ benno@
2016-09-02 14:45:51 +00:00
reyk
325f6e14c7 proc_id has been replaced by ps->ps_instance.
OK claudio@
2016-09-02 14:31:47 +00:00
reyk
c28c61cc15 As done in httpd, remove ps_ninstances and p_instance.
OK benno@ rzalamena@
2016-09-02 12:12:51 +00:00
reyk
f910ac1129 Terminate relayd using the socket status instead of watching SIGCHLD
or killing child processes. - Based on rzalamena@'s diff for httpd.

OK deraadt@ rzalamena@
2016-09-02 11:51:49 +00:00
claudio
9c9085255d Switch from the not really working session cache (because of the multiprocess
nature of relayd) to tls session tickets to do TLS session resumption.
TLS session tickets do not need to store SSL session data in the server but
instead send an encrypted ticket to the clients that allows to resume the
session. This is mostly stateless (apart from the encryption keys).
relayd now ensures that all relay processes use the same key to encrypt
the tickets. Keys are rotated every 2h and there is a primary and backup key.
The tls session timeout is set to 2h to hint to the clients how long the
session tickets is supposed to be alive.
Input and OK benno@, reyk@
2016-09-01 10:49:48 +00:00
benno
630a37364e SSL_CTX_free() and SSL_free() check for null so dont do it in relayd
ok jung@ tedu@ deraadt@
2015-12-30 16:00:57 +00:00
mmcc
e17f2f8ffe completly -> completely 2015-12-24 05:06:24 +00:00
mmcc
c3ec3cb15c Remove NULL-checks before free(). No functional change. 2015-12-07 04:03:27 +00:00
benno
dfe4ee48d6 initialize host, to get rid of gcc warning, the conditions are correct.
ok henning@
2015-12-05 20:58:32 +00:00
benno
43d3c4ca7c pledge the relay (layer 7 proxy) children, they can do with "stdio
recvfd inet"
ok reyk@
2015-12-04 15:28:55 +00:00
benno
bfcf47ad49 relayd (when running relays) can distribute client sessions over hosts
with a hash generated from different data and calculate modulo
rlt->rlt_nhosts to find the host the session should go to. If this
host is down, the current algorithm simply selects the next host that
is up, obviously not ideal, because this puts heavier load on this
next host.

this changes the algorithm: if the chosen host is not available, the
hash value is recalculated and and retried until a host that is usable
is found or a maximum of retires is reached (in that case the old
method is used).

ok and nice input on my original idea bluhm@
2015-12-02 22:12:29 +00:00
reyk
c2c37c5d20 In most cases we don't need all arguments of proc_compose*_imsg(),
so add a shortcut proc_compose*() that skips all of them.  Only use the
full argument list if needed.  The functions with full argument lists can
eventually be replaced with a nicer transaction-based approach later.

OK benno@
2015-12-02 13:41:27 +00:00
reyk
b045ffee65 Use SOCK_NONBLOCK in relayd as well.
OK benno@
2015-11-28 09:52:07 +00:00
reyk
d2d7e42497 spacing 2015-07-28 10:24:26 +00:00
benno
807a0a4623 Fix unbounded buffer growth. In the case of a slow client reading large files,
we would consume large ammounts of memory.
Found by Matthew Martin <matt DOT a DOT martin AT gmail DOT com> in
httpd, fixed in httpd by florian@
feedback from florian, reyk and bluhm, ok bluhm, reyk
2015-07-18 16:01:28 +00:00
reyk
b40fcd2f22 To match relayd's style, use an explicit enum with prefixed names for
the states that Claudio introduced.  No functional change.

OK claudio@ benno@
2015-06-12 14:40:55 +00:00
claudio
f20bb366e3 Introduce a state on the ctl_relay_event struct. This makes it possible
to better track the connection state of a session and stops doing double
opens in certain situations using http relays. Using a state field to
simplify the logic since relay_connect() is called multiple times.
OK benno@, bluhm@ and running in production for more than a week
2015-06-08 15:47:51 +00:00
bluhm
70d03dad87 Fix a crash reported and analyzed by Bertrand PROVOST. When a HTTP
client or server writes multiple requests or chunks in a single
transfer, relayd invokes the libevent callback manually for the
next data.  If the callback closes the session, this resulted in
an use after free.
Instead of the more complicated fix suggested by Bertrand PROVOST,
just move the invocation of the callback to the end of the function.
So in case the callback frees any structures, they are not accessed.
OK benno@ reyk@
2015-05-18 16:57:20 +00:00
bluhm
24d4a724de When the HTTP client did close the connection while relayd was still
parsig the HTTP header, the session was never destroyed.  This
resulted in a file descriptor leak.
Add a check wether the protocol knows how much data to expect.  If
relayd is reading unlimited data or is expecting nothing to read,
ignore the end-of-file.  Otherwise it is a protocol violation, so
close the session immediately.
While there, make relayd compile with DEBUG defined.
Based on a diff from claudio@; tested by claudio@; OK claudio@ benno@
2015-04-29 08:41:24 +00:00
florian
f89c49669a We cannot log errors with relay_close() before allocating
se_log evbuffer.
(Same problem as the one just fixed in httpd(8))
OK benno
2015-04-23 17:03:01 +00:00
reyk
642f72f1c1 Rename SSL_CTX_use_certificate_chain() to SSL_CTX_use_certificate_chain_mem().
As discussed with beck@ jsing@ and others
OK beck@
2015-02-06 01:37:11 +00:00
reyk
f04ff968bd Clean up the relayd headers with help of include-what-you-use and some
manual review.  Based on common practice, relayd.h now includes the
necessary headers for itself.

OK benno@
2015-01-22 17:42:09 +00:00
reyk
1ab70d2179 spacing 2015-01-22 15:21:28 +00:00
reyk
1afa0f7ffb LibreSSL now supports loading of CA certificates from memory, replace
the internal and long-serving ssl_ctx_load_verify_memory() function
with a call to the SSL_CTX_load_verify_mem() API function.  The
ssl_privsep.c file with hacks for using OpenSSL in privsep'ed
processes can now go away; portable versions of smtpd and relayd
should start depending on LibreSSL or they have to carry ssl_privsep.c
in openbsd-compat to work with legacy OpenSSL.  No functional change.

Based on previous discussions with gilles@ bluhm@ and many others
OK bluhm@ (as part of the libcrypto/libssl/libtls diff)
2015-01-22 09:26:05 +00:00
reyk
5e98f9ba84 SSL_CTX_use_certificate_chain() has been added to LibreSSL and there
is no need to keep a local copy in ssl_privsep.c.  This adds a little
burden on OpenSMTPD-portable because it will have to put it in
openbsd-compat for compatibility with legacy OpenSSL.

OK gilles@
2015-01-16 15:08:52 +00:00
deraadt
e2318a5207 Adapt to <limits.h> universe.
ok millert
2015-01-16 15:06:40 +00:00
reyk
31413d7e14 The SSL/TLS session Id context is limited to 32 bytes. Instead of
using the name of relayd relay or smtpd pki, use a 32 byte arc4random
buffer that should be unique for the context.  This fixes an issue in
OpenSMTPD when a long pki name could break the configuration.

OK gilles@ benno@
2015-01-16 14:34:51 +00:00
guenther
395002a2ec Stop pulling in <arpa/inet.h> or <arpa/nameser.h> when unnecessary.
*Do* pull it in when in_{port,addr}_h is needed and <netinet/in.h> isn't.

ok reyk@
2014-12-21 00:54:49 +00:00
reyk
acb89df41a Update relayd to use siphash instead of sys/hash. The source-hash,
loadbalance and hash modes use a random key by default that can be
forced to be a static key with a new configuration argument.

With input from Max Fillinger.

ok tedu@
2014-12-18 20:55:01 +00:00
reyk
7bb522285f Change the keyword "ssl" to "tls" to reflect reality since we
effectively disabled support for the SSL protocols.  SSL remains a
common term describing SSL/TLS, there is some controvery about this
change, and the name really doesn't matter, but I feel confident about
it now.

(btw., sthen@ pointed out some historical context:
http://tim.dierks.org/2014/05/security-standards-and-name-changes-in.html)

OK benno@, with input from tedu@
2014-12-12 10:05:09 +00:00
blambert
6e07057bf7 Support exporting relayd statistics via AgentX/snmpd
This should be equivalent to the statistics available
via the various relaydctl show commands

okay benno@ reyk@
2014-11-19 10:24:39 +00:00
jsing
b820fe85b1 Remove the sslv2 option since LibreSSL has no SSLv2 support (however retain
SSL_OP_NO_SSLv2 in case you happen to be running relayd on another platform
with another SSL library). Also fix the SSLv3 handling so that 'no sslv3'
actually works as intended.

ok reyk@
2014-11-07 13:48:06 +00:00
lteo
1543e3f792 Remove unnecessary netinet/in_systm.h include.
ok millert@
2014-10-25 03:23:49 +00:00
reyk
7462166be6 Disable SSLv3 by default.
OK sthen@ jsing@
2014-10-15 11:06:16 +00:00
blambert
ae15eb0ae6 revert previous; was based on a work-in-progress, as well
as being an incomplete and therefore incorrect adaptation

apologies to anybody who got bitten by this mistake

ok reyk@
2014-09-05 10:19:26 +00:00
blambert
d4264a38a8 Implement consistent host hashing for relayd, based on
work done by andre@

Re-add a randomized hash seed (which had apparently
gotten inadvertently removed in the past).

Allows for multiple relayd instances to be configured
to forward traffic to the same host, falling back to
the random seed when not explicitly configured to do so.

ok reyk@
2014-08-29 09:03:36 +00:00
bluhm
30791b7995 When a connection was spliced in one direction and in copy mode in
the other direction, the timeouts did not work.  They were longer
than specified.  Link the splicing and non-splicing timeouts.
Found by make run-regress-args-timeout-http.pl
OK reyk@
2014-07-14 00:11:12 +00:00
benno
c84d609969 improve log output for relays. adjust regress tests
ok reyk
2014-07-13 00:32:08 +00:00
reyk
3675f6daac Add support for EDH to provide perfect forward secrecy for older SSL
clients.  Additionally, add options for disallowing client-initiated
renegotiations and to prefer the server's cipher list over the
client's preferences.

This work is based on a diff by Markus Gebert at hostpoint.ch, and was
discussed with jsing@ resulting in a few different defaults.

ok benno@
2014-07-11 16:59:38 +00:00
reyk
cb8b0e5645 Replace the protocol directives for HTTP with a new generic filtering
language.  The grammar is inspired by pf and allows to write versatile
last-matching filter rules in protocol sections starting with the
"pass", "block" or "match" keywords.  This work was started almost two
years ago and replaces large parts of relayd(8)'s HTTP and filtering
code.  The initial version reimplements and extends HTTP filtering,
but will be improved to support generic TCP and other protocols later.

With some testing, feedback, and help from benno@ and andre@.

OK benno@
2014-07-09 16:42:05 +00:00
andre
4bfdeee067 knf, no functional change.
ok reyk
2014-06-27 07:49:08 +00:00
reyk
d5cc82f924 Unify the SSL privsep key loading functions.
ok eric@
2014-05-20 17:33:36 +00:00