Go to file
Soner Tari ca959ca391 Do not call topmost callback functions directly, use them in bufferevent setup only, otherwise can possibly cause double free of ctx
Run preexec and postexec logging and/or stats code when calling interface callback functions directly, they are mostly called in edge cases, but otherwise we would miss related logs and/or stats
2018-10-28 23:51:22 +03:00
.github Update with SSLsplit 0.5.1 changes, fix LibreSSL version issues 2018-01-18 03:18:53 +03:00
extra Improve messages for omitted tests 2018-10-26 18:13:17 +03:00
Mk Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
xnu Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
.gitattributes Add .gitattributes and cleanup .gitignore 2014-01-14 17:14:23 +01:00
.gitignore Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
.travis.yml Rename to sslproxy 2017-08-11 15:01:51 +03:00
attrib.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
AUTHORS.md Merge sslsplit develop changes 2018-08-03 23:36:51 +03:00
base64.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
base64.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
base64.t.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
BSDmakefile Fix BSDmakefile for recent versions of BSD make 2016-03-27 15:36:13 +02:00
build.c Update with sslsplit develop changes 2018-03-26 18:14:54 +03:00
build.h Update with sslsplit develop changes 2018-03-26 18:14:54 +03:00
cache.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cache.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachedsess.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachedsess.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachedsess.t.c Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
cachefkcrt.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachefkcrt.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachefkcrt.t.c Improve messages for omitted tests 2018-10-26 18:13:17 +03:00
cachemgr.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachemgr.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachemgr.t.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachessess.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachessess.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachessess.t.c Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
cachetgcrt.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachetgcrt.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cachetgcrt.t.c Improve messages for omitted tests 2018-10-26 18:13:17 +03:00
cert.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cert.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
cert.t.c Improve messages for omitted tests 2018-10-26 18:13:17 +03:00
defaults.h Merge sslsplit develop changes 2018-08-03 23:36:51 +03:00
defaults.t.c Merge sslsplit develop changes 2018-08-03 23:36:51 +03:00
dynbuf.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
dynbuf.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
dynbuf.t.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
GNUmakefile Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
khash.h Update khash.h to latest version 2016-03-25 16:49:27 +01:00
LICENSE Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
LICENSE.contrib Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
LICENSE.third Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
log.c Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
log.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
logbuf.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
logbuf.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
logger.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
logger.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
main.c Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
main.t.c Merge sslsplit develop changes 2018-08-03 23:36:51 +03:00
nat.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
nat.h Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
NEWS.md Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
opts.c Fix autossl, but Evolution client sometimes does not send ehlo, especially after user rejects self-signed cert, which needs further investigation 2018-10-21 22:01:46 +03:00
opts.h Add conn context and is_child fields to proxy context struct to get rid of extra function params and to simplify conditionals 2018-09-23 02:02:15 +03:00
opts.t.c Fix the broken unit tests for proxyspec_parse() due to up:utmport in the sslproxy proxspec format 2018-05-09 21:22:40 +03:00
privsep.c Add fall through comment for missing break in case statement, as gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0 complains about it now 2018-08-01 21:38:12 +03:00
privsep.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
proc.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
proc.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
protoautossl.c Do not call topmost callback functions directly, use them in bufferevent setup only, otherwise can possibly cause double free of ctx 2018-10-28 23:51:22 +03:00
protoautossl.h Move proto specific structs from h to c files 2018-10-18 02:43:27 +03:00
protohttp.c Avoid redundant void to ctx type casts by passing ctx explicitly 2018-10-23 00:18:48 +03:00
protohttp.h Move proto specific structs from h to c files 2018-10-18 02:43:27 +03:00
protopassthrough.c Do not call topmost callback functions directly, use them in bufferevent setup only, otherwise can possibly cause double free of ctx 2018-10-28 23:51:22 +03:00
protopassthrough.h Add static and NONNULL attrib 2018-10-18 02:00:49 +03:00
protossl.c Fix build warning with LibreSSL 2.8.2, id is const now 2018-10-27 00:30:09 +03:00
protossl.h Rename srv_dst to srvdst 2018-10-22 16:12:07 +03:00
prototcp.c Do not call topmost callback functions directly, use them in bufferevent setup only, otherwise can possibly cause double free of ctx 2018-10-28 23:51:22 +03:00
prototcp.h Avoid redundant void to ctx type casts by passing ctx explicitly 2018-10-23 00:18:48 +03:00
proxy.c Decouple ssl from tcp and other protocols 2018-10-17 16:28:21 +03:00
proxy.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
pxyconn.c Do not call topmost callback functions directly, use them in bufferevent setup only, otherwise can possibly cause double free of ctx 2018-10-28 23:51:22 +03:00
pxyconn.h Do not call topmost callback functions directly, use them in bufferevent setup only, otherwise can possibly cause double free of ctx 2018-10-28 23:51:22 +03:00
pxysslshut.c Improve debug logging, log proto name on connect/disconnect 2018-10-21 00:25:01 +03:00
pxysslshut.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
pxythrmgr.c Rename srv_dst to srvdst 2018-10-22 16:12:07 +03:00
pxythrmgr.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
pxythrmgr.t.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
README.md Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
SECURITY.md Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
ssl.c Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
ssl.h Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
ssl.t.c Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
sslproxy.1 Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
sslproxy.conf Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
sslproxy.conf.5 Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
sys.c Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
sys.h Merge sslsplit-develop changes 2018-09-15 02:51:26 +03:00
sys.t.c Update with sslsplit develop changes 2018-03-26 18:14:54 +03:00
thrqueue.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
thrqueue.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
url.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
url.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
url.t.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
util.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
util.h Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00
util.t.c Update with SSLsplit 0.5.2 and develop branch changes as of 270218 2018-02-27 22:20:58 +03:00

SSLproxy - transparent SSL/TLS proxy for decrypting and diverting network traffic to other programs for deep SSL inspection Build Status

Copyright (C) 2017-2018, Soner Tari.
https://github.com/sonertari/SSLproxy

Copyright (C) 2009-2018, Daniel Roethlisberger.
https://www.roe.ch/SSLsplit

Overview

SSLproxy is a proxy for SSL/TLS encrypted network connections. It is intended to be used for decrypting and diverting network traffic to other programs, such as UTM services, for deep SSL inspection. See this presentation for a summary.

SSLproxy is designed to transparently terminate connections that are redirected to it using a network address translation engine. SSLproxy then terminates SSL/TLS and initiates a new SSL/TLS connection to the original destination address. Packets received on the client side are decrypted and sent to the program listening on a port given in the proxy specification. SSLproxy inserts in the first packet the address and port it is expecting to receive the packets back from the program. Upon receiving the packets back, SSLproxy re-encrypts and sends them to their original destination. The return traffic follows the same path back to the client in reverse order.

Mode of Operation
Diagram

This is similar in principle to divert sockets, where the packet filter diverts the packets to a program listening on a divert socket, and after processing the packets the program reinjects them into the kernel. If there is no program listening on that divert socket or the program does not reinject the packets into the kernel, the connection is effectively blocked. In the case of SSLproxy, SSLproxy acts as both the packet filter and the kernel, and the communication occurs over networking sockets.

For example, given the following proxy specification:

https 127.0.0.1 8443 up:8080

The SSLproxy listens for HTTPS connections on 127.0.0.1:8443. Upon receiving a connection from the Client, it decrypts and diverts the packets to a Program listening on 127.0.0.1:8080. After processing the packets, the Program gives them back to the SSLproxy listening on a dynamically assigned address, which the Program obtains from the first packet in the connection. Then the SSLproxy re-encrypts and sends the packets to the Server. The response from the Server follows the same path to the Client in reverse order.

The program that packets are diverted to should support this mode of operation. Specifically, it should be able to recognize the SSLproxy address in the first packet, and give the first and subsequent packets back to the SSLproxy listening on that address, instead of sending them to the original destination as it normally would.

A sample line SSLproxy inserts into the first packet in the connection is the following:

SSLproxy: [127.0.0.1]:34649,[192.168.3.24]:47286,[192.168.111.130]:443,s

The first IP:port pair is a dynamically assigned address that the SSLproxy expects the program send the packets back to it. The second and third IP:port pairs are the actual source and destination addresses of the connection respectively. Since the program receives the packets from the SSLproxy, it cannot determine the source and destination addresses of the packets by itself, hence must rely on the information in this SSLproxy line. The last letter is either s or p, for SSL/TLS encrypted or plain traffic respectively. This information is also important for the program, because it cannot reliably determine if the actual network traffic it is processing was encrypted or not.

SSLproxy supports plain TCP, plain SSL, HTTP, HTTPS, POP3, POP3S, SMTP, and SMTPS connections over both IPv4 and IPv6. It also has the ability to dynamically upgrade plain TCP to SSL in order to generically support SMTP STARTTLS and similar upgrade mechanisms. SSLproxy fully supports Server Name Indication (SNI) and is able to work with RSA, DSA and ECDSA keys and DHE and ECDHE cipher suites. Depending on the version of OpenSSL, SSLproxy supports SSL 3.0, TLS 1.0, TLS 1.1 and TLS 1.2, and optionally SSL 2.0 as well.

For SSL and HTTPS connections, SSLproxy generates and signs forged X509v3 certificates on-the-fly, mimicking the original server certificate's subject DN, subjectAltName extension and other characteristics. SSLproxy has the ability to use existing certificates of which the private key is available, instead of generating forged ones. SSLproxy supports NULL-prefix CN certificates but otherwise does not implement exploits against specific certificate verification vulnerabilities in SSL/TLS stacks.

SSLproxy implements a number of defenses against mechanisms which would normally prevent MitM attacks or make them more difficult. SSLproxy can deny OCSP requests in a generic way. For HTTP and HTTPS connections, SSLproxy mangles headers to prevent server-instructed public key pinning (HPKP), avoid strict transport security restrictions (HSTS), avoid Certificate Transparency enforcement (Expect-CT) and prevent switching to QUIC/SPDY, HTTP/2 or WebSockets (Upgrade, Alternate Protocols). HTTP compression, encodings and keep-alive are disabled to make the logs more readable.

Another reason to disable persistent connections is to reduce file descriptor usage. Accordingly, connections are closed if they remain idle for a certain period of time. The default timeout is 120 seconds, which can be changed in a configuration file.

SSLproxy verifies upstream certificates by default. If the verification fails, the connection is terminated immediately. This is in contrast to SSLsplit, because in order to maximize the chances that a connection can be successfully split, SSLsplit accepts all certificates including self-signed ones. See The Risks of SSL Inspection for the reasons of this difference.

As SSLproxy is based on SSLsplit, this is a modified SSLsplit README file. See the manual page sslproxy(1) for details on using SSLproxy and setting up the various NAT engines.

Requirements

SSLproxy depends on the OpenSSL and libevent 2.x libraries. The build depends on GNU make and a POSIX.2 environment in PATH. If available, pkg-config is used to locate and configure the dependencies. The optional unit tests depend on the check library.

SSLproxy currently supports the following operating systems and NAT mechanisms:

  • FreeBSD: pf rdr and divert-to, ipfw fwd, ipfilter rdr
  • OpenBSD: pf rdr-to and divert-to
  • Linux: netfilter REDIRECT and TPROXY
  • Mac OS X: pf rdr and ipfw fwd

Support for local process information (-i) is currently available on Mac OS X and FreeBSD.

SSL/TLS features and compatibility greatly depend on the version of OpenSSL linked against; for optimal results, use a recent release of OpenSSL proper. OpenSSL forks like BoringSSL may or may not work.

Installation

With OpenSSL, libevent 2.x, pkg-config and check available, run:

make
make test       # optional unit tests
make sudotest   # optional unit tests requiring privileges
make install    # optional install

Dependencies are autoconfigured using pkg-config. If dependencies are not picked up and fixing PKG_CONFIG_PATH does not help, you can specify their respective locations manually by setting OPENSSL_BASE, LIBEVENT_BASE and/or CHECK_BASE to the respective prefixes.

You can override the default install prefix (/usr/local) by setting PREFIX. For more build options see GNUmakefile and defaults.h.

Documentation

See the manual page sslproxy.1 for user documentation. See NEWS.md for release notes listing significant changes between releases.

License

SSLsplit is provided under a 2-clause BSD license. SSLsplit contains components licensed under the MIT and APSL licenses. See LICENSE, LICENSE.contrib and LICENSE.third as well as the respective source file headers for details. The modifications for SSLproxy are licensed under the same terms as SSLsplit.

Credits

See AUTHORS.md for the list of contributors.

SSLsplit was inspired by mitm-ssl by Claes M. Nyberg and sslsniff by Moxie Marlinspike, but shares no source code with them.