SlideShare a Scribd company logo
1 of 45
Download to read offline
Linux Kernel
TLS & HTTPS
Alexander Krizhanovsky
Tempesta Technologies, Inc.
ak@tempesta-tech.com
HTTPS challenges
HTTP(S) is a core protocol for the Internet
(IoT, SaaS, Social networks etc.)
HTTP(S) DDoS is tricky
● Asymmetric DDoS (compression, TLS handshake etc.)
● A lot of IP addresses with low traffic (IoT)
● Machine learning is used for clustering
● How to filter out all HTTP requests with
“Host: www.example.com:80”?
● "Lessons From Defending The Indefensible":
https://www.youtube.com/watch?v=pCVTEx1ouyk
TCP stream filter
IPtables strings, BPF, XDP, NIC filters
● HTTP headers can cross packet bounds
● Scan large URI or Cookie for Host value?
Web accelerator
● aren’t designed (suitable) for HTTP filtering
IPS vs HTTP DDoS
e.g. Suricata, has powerful rules syntax at L3-L7
Not a TCP end point => evasions are possible
SSL/TLS
● SSL terminator is required => many data copies & context switches
● or double SSL processing (at IDS & at Web server)
Double HTTP parsing
Doesn’t improve Web server peroformance (mitigation != prevention)
Interbreed an HTTP accelerator and a firewall
TCP & TLS end point
Very fast HTTP parser to process HTTP floods
Network I/O optimized for massive ingress traffic
Advanced filtering abilities at all network layers
Very fast Web cache to mitigate DDoS which we can’t filter out
● ML takes some time for bots clusterization
● False negatives are unavoidable
Application Delivery Controller (ADC)
WAF accelerator
Just like Web accelerator
Advanced load balancing:
● Server groups by any HTTP field
● Rendezvous hashing
● Ratio
● Adaptive & predictive
Some DDoS attacks can be just
normally serviced
Web-accelerator capabilities
Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc.
● cache static Web-content
● load balancing
● rewrite URLs, ACL, Geo, filtering etc.
● C10K
Web-accelerator capabilities
Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc.
● cache static Web-content
● load balancing
● rewrite URLs, ACL, Geo, filtering? etc.
● C10K – is it a problem for bot-net? SSL?
●
what about tons of 'GET / HTTP/1.0nn'? (CORNER CASES!)
Web-accelerator capabilities
Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc.
● cache static Web-content
● load balancing
● rewrite URLs, ACL, Geo, filtering? etc.
● C10K – is it a problem for bot-net? SSL?
●
what about tons of 'GET / HTTP/1.0nn'? (CORNER CASES!)
Kernel-mode Web-accelerators: TUX, kHTTPd
● basically the same sockets and threads
● zero-copy → sendfile(), lazy TLB
Web-accelerator capabilities
Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc.
● cache static Web-content
● load balancing
● rewrite URLs, ACL, Geo, filtering? etc.
● C10K – is it a problem for bot-net? SSL?
●
what about tons of 'GET / HTTP/1.0nn'? (CORNER CASES!)
Kernel-mode Web-accelerators: TUX, kHTTPd
● basically the same sockets and threads
● zero-copy → sendfile(), lazy TLB => not needed
Web-accelerator capabilities
Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc.
● cache static Web-content
● load balancing
● rewrite URLs, ACL, Geo, filtering? etc.
● C10K – is it a problem for bot-net? SSL?
●
what about tons of 'GET / HTTP/1.0nn'? (CORNER CASES!)
Kernel-mode Web-accelerators: TUX, kHTTPd NEED AGAIN
● basically the same sockets and threads TO MITIGATE
● zero-copy → sendfile(), lazy TLB => not needed HTTPS DDOS!
Web-accelerators are slow
Slow & non-scalable network I/O (queues are bad for CPU caches)
Data copyings & syscalls
Dummy HTTP FSMs
HTTP strings are special: LIBC functions don’t work well
Don’t care about the corner cases
Sometimes request blocking is slower than serving it
https://www.netdevconf.org/2.1/session.html?krizhanovsky
Web-accelerators are slow: HTTP parser
Web-accelerators are slow: strings
We have AVX2, but GLIBC doesn’t still use it
HTTP strings are special:
● No ‘0’-termination (if you’re zero-copy)
● Special delimiters (‘:’ or CRLF)
●
strcasecmp(): no need case conversion for one string
●
strspn(): limited number of accepted alphabets
switch()-driven FSM is even worse
Fast HTTP parser
http://natsys-lab.blogspot.ru/2014/11/the-fast-finite-state-machine-for-
http.html
● 1.6-1.8 times faster than Nginx’s
HTTP optimized AVX2 strings processing:
http://natsys-lab.blogspot.ru/2016/10/http-strings-processing-using-c-
sse42.html
● ~1KB strings:
● strncasecmp() ~x3 faster than GLIBC’s
● URI matching ~x6 faster than GLIBC’s strspn()
● kernel_fpu_begin()/kernel_fpu_end() for whole softirq shot
HTTP strong validation
TODO: https://github.com/tempesta-tech/tempesta/issues/628
Injections: specify allowed URI characters for a Web app
Resistant to large HTTP fields
Easy to do with SIMD
https://natsys-lab.blogspot.ru/2016/10/http-strings-processing-using-c-
sse42.html
Fast network I/O: kernel bypass
Netmap, DPDK, PF_RING etc.
No [zero-copy] tcpdump, tc, ipvs, iptables etc.
User-space TCP/IP stack issues
● No preemption control => no [good] RCU
● pthread_spinlock are naive (vs. MCS locks.)
● No access to buddy allocator (need memory reservation)
Win for simple applications only
(IP & UDP, but not for TCP & HTTP)
Web-accelerators are slow: SSL/TLS copying
User-kernel space copying
● Copy network data to user space
● Encrypt/decrypt it
●
Copy the date to kernel for transmission (or splice())
Kernel-mode TLS
● Facebook & RedHat: https://lwn.net/Articles/666509/
● Mellanox: https://netdevconf.org/1.2/session.html?boris-pismenny
● Netflix: https://people.freebsd.org/~rrs/asiabsd_2015_tls.pdf
Kernel SSL/TLS: the history
KSSL (http://www.ksl.ci.kyutech.ac.jp/~kourai/research/kssl/kssl.html)
● OpenSSL 0.9.7i
● Linux 2.6.14
Solaris kernel SSL proxy
● Mostly for old hardware with slow context switch
Linux kernel TLS (since 4.13)
CONFIG_TLS (switched off by default)
Symmetric encryption only (no handshake)
Example (https://github.com/Mellanox/tls-af_ktls_tool):
struct tls12_crypto_info_aes_gcm_128 ci = {
.version = TLS_1_2_VERSION, .cipher_type = TLS_CIPHER_AES_GCM_128 };
connect(sd, ..., ...);
gnutls_handshake(*session);
gnutls_record_get_state(session, ..., ..., iv, key, seq);
memcpy(ci.iv, seq, TLS_CIPHER_AES_GCM_128_IV_SIZE);
memcpy(ci.rec_seq, seq, TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
memcpy(ci.key, key, TLS_CIPHER_AES_GCM_128_KEY_SIZE);
memcpy(ci.salt, iv, TLS_CIPHER_AES_GCM_128_SALT_SIZE);
setsockopt(sd, SOL_TCP, TCP_ULP, "tls", sizeof("tls"));
setsockopt(sd, SOL_TLS, TLS_TX, &ci, sizeof(ci));
Mellanox: TLS offload to network devices
https://netdevconf.org/1.2/papers/netdevconf-TLS.pdf
Control path: kTLS (user space handshakes)
Data path: per-record encryption
Linux kernel TLS & DDoS
Most Facebook users have established sessions
TLS handshake is still an issue
● TLS 1.3 has 1-RTT handshake and is almost here
● TLS 1.2 must live for a long time (is Windows XP still alive?)
● TLS renegotiation
HTTPS/TCP/IP stack
(in progress)
Alternative to user space TCP/IP stacks
HTTPS is built into TCP/IP stack
Kernel TLS (fork from mbedTLS) – [almost] no copying
(1 human month to port TLS to kernel!)
HTTP firewall plus to IPtables and Socket filter
Very fast HTTP parser and strings processing using AVX2
Cache-conscious in-memory Web-cache for DDoS mitigation
TODO
● HTTP QoS for asymmetric DDoS mitigation
● DSL for multi-layer filter rules
Tempesta FW
TODO: HTTP QoS
for asymmetric DDoS mitigation
https://github.com/tempesta-tech/tempesta/issues/488
“Web2K: Bringing QoS to Web Servers” by Preeti Bhoj et al.
Local stress: packet drops, queues overrun, response latency etc
(kernel: cheap statistics for asymmetric DDoS)
Upsream stress: req_num / resp_num, response time etc.
Static QoS rules per vhost: HTTP RPS, integration w/ Qdisc - TBD
Actions: reduce TCP window, don’t accept new connections,
close existing connections
User space HTTP proxying
1. Receive request at CPU1
2. Copy request to user space
3. Update headers
4. Copy request to kernel space
5. Send the request from CPU2
3 data copies
Access TCP control blocks and
data buffers from different CPUs
Synchronous sockets: HTTPS/TCP/IP stack
Socket callbacks call TLS and
HTTP processing
Everything is processing in
softirq (while the data is hot)
No receive & accept queues
No file descriptors
Less locking
Synchronous sockets: HTTPS/TCP/IP stack
Socket callbacks call TLS and
HTTP processing
Everything is processing in
softirq (while the data is hot)
No receive & accept queues
No file descriptors
Less locking
Lock-free inter-CPU transport
=> faster socket reading
=> lower latency
skb page allocator:
zero-copy HTTP messages adjustment
Add/remove/update HTTP
headers w/o copies
skb and its head are
allocated in the same
page fragment or
a compound page
skb page allocator:
zero-copy HTTP messages adjustment
Add/remove/update HTTP
headers w/o copies
skb and its head are allocated
in the same page fragment or a
compound page
HTTP/2
Pros
● Responses are sent in parallel and in
any order (no head-of-line blocking)
● Compression
Cons
● Zero copy techniques aren’t(?)
applicable
=> For client connections (slow network), not for LAN (fast network)
QUIC?
UDP-based with flow control
10% duplicates
0-RTT handshakes
Implemented as a user-space library
Questions:
● Opaque UDP traffic just like UDP flood
● TCP fast open + TLS 1.3 seem solve handshake problem
RFC 7457:
Summarizing Known Attacks on TLS
(D)DoS
● Renegotiation (should be disabled)
● Assymetric denial of service
...and others
TLS 1.3: client puzzles
https://tools.ietf.org/html/draft-nygren-tls-client-puzzles-02
ServerHello sends a puzzle to a client
● Cookie (simple echo)
● SHA-256 or SHA-512(many times)
● Genrealized birthday problem
The latest draft is dated by Jul 1, 2017
HTTP(S) DDoS mitigation: rate limits
Rate limits
● request_rate, request_burst
● connection_rate, connection_burst
● concurrent_connections
● TODO: TLS handshakes
(https://github.com/tempesta-tech/tempesta/issues/832)
Slow HTTP
● client_header_timeout, client_body_timeout
● http_header_cnt
● http_header_chunk_cnt, http_body_chunk_cnt
Web security checks
Length limits: http_uri_len, http_field_len, http_body_len
Content validation: http_host_required, http_ct_required,
http_ct_vals, http_methods
HTTP Response Splitting: count and match requests and responses
Injections: carefully verify allowed character sets
...and many upcoming filters:
https://github.com/tempesta-tech/tempesta/labels/security
Not a featureful WAF
Sticky cookie
User/session identification
● Cookie challenge for dummy DDoS bots
● Persistent/sessions scheduling (no rescheduling on a server failure)
Enforce: HTTP 302 redirect
sticky name=__tfw_user_id__ enforce;
Sticky cookie
User/session identification
● Cookie challenge for dummy DDoS bots
● Persistent/sessions scheduling (no rescheduling on a server failure)
Enforce: HTTP 302 redirect
sticky name=__tfw_user_id__ enforce;
TODO: JavaScript challenge
https://github.com/tempesta-tech/tempesta/issues/536
TODO: Multi-layer firewall
https://github.com/tempesta-tech/tempesta/issues/102
if ((req.user_agent =~ /firefox/i
|| req.cookie !~ /^our_tracking_cookie/)
&& (req.x_forwarded_for != "1.1.1.1"
|| client.addr == 1.1.1.1))
# Block the client at IP layer, so it will be filtered
# efficiently w/o further HTTP processing.
tdb.insert("ip_filter", client.addr, evict=10000);
Nftables integration via mark
https://github.com/tempesta-tech/tempesta/issues/760
Performance
https://github.com/tempesta-tech/tempesta/wiki/HTTP-cache-performance
Performance analysis
~x3 faster than Nginx (~600K HTTP RPS) for normal Web cache
operations
Must be much faster to block HTTP DDoS
(DDoS emulation is an issue)
Similar to DPDK/user-space TCP/IP stacks
http://www.seastar-project.org/
http-performance/
...bypassing Linux TCP/IP
isn’t the only way to get a fast Web server
...lives in Linux infrastructure:
LVS, tc, IPtables, eBPF, tcpdump etc.
Keep the kernel small
Just 30K LoC (compare w/ 120K LoC of BtrFS)
Only generic and crucial HTTPS logic is in kernel
Supplementary logic is considered for user space
● HTTP compression & decompression
https://github.com/tempesta-tech/tempesta/issues/636
● Advanced DDoS mitigation & WAF (e.g. full POST processing)
● ...other HTTP users (Web frameworks?)
Zero-copy kernel-user space transport for minimizing kernel code
TODO:
Zero-copy kernel-user space transport
HTTP compression
HTTPS DDoS mitigation
& WAF
● Machine learning
clusterization in user space
● Automatic L3-L7 filtering
rules generation
Thanks!
Web-site: http://tempesta-tech.com
Availability: https://github.com/tempesta-tech/tempesta
Blog: http://natsys-lab.blogspot.com
E-mail: ak@tempesta-tech.com
We are hiring!

More Related Content

What's hot

Centralized Logging with syslog
Centralized Logging with syslogCentralized Logging with syslog
Centralized Logging with syslog
amiable_indian
 
Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.
Mihai Iachimovschi
 
Abusing Microsoft Kerberos - Sorry you guys don’t get it
Abusing Microsoft Kerberos - Sorry you guys don’t get itAbusing Microsoft Kerberos - Sorry you guys don’t get it
Abusing Microsoft Kerberos - Sorry you guys don’t get it
E Hacking
 

What's hot (20)

Centralized Logging with syslog
Centralized Logging with syslogCentralized Logging with syslog
Centralized Logging with syslog
 
Defeating The Network Security Infrastructure V1.0
Defeating The Network Security Infrastructure  V1.0Defeating The Network Security Infrastructure  V1.0
Defeating The Network Security Infrastructure V1.0
 
Neutron Network Namespaces and IPtables--A Technical Deep Dive
Neutron Network Namespaces and IPtables--A Technical Deep DiveNeutron Network Namespaces and IPtables--A Technical Deep Dive
Neutron Network Namespaces and IPtables--A Technical Deep Dive
 
Introduction to Haproxy
Introduction to HaproxyIntroduction to Haproxy
Introduction to Haproxy
 
Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.
 
Troubleshooting containerized triple o deployment
Troubleshooting containerized triple o deploymentTroubleshooting containerized triple o deployment
Troubleshooting containerized triple o deployment
 
How to Troubleshoot OpenStack Without Losing Sleep
How to Troubleshoot OpenStack Without Losing SleepHow to Troubleshoot OpenStack Without Losing Sleep
How to Troubleshoot OpenStack Without Losing Sleep
 
OpenvSwitch Deep Dive
OpenvSwitch Deep DiveOpenvSwitch Deep Dive
OpenvSwitch Deep Dive
 
Usenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyUsenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a Proxy
 
HTTP/2, HTTP/3 and SSL/TLS State of the Art in Our Servers
HTTP/2, HTTP/3 and SSL/TLS State of the Art in Our ServersHTTP/2, HTTP/3 and SSL/TLS State of the Art in Our Servers
HTTP/2, HTTP/3 and SSL/TLS State of the Art in Our Servers
 
Abusing Microsoft Kerberos - Sorry you guys don’t get it
Abusing Microsoft Kerberos - Sorry you guys don’t get itAbusing Microsoft Kerberos - Sorry you guys don’t get it
Abusing Microsoft Kerberos - Sorry you guys don’t get it
 
How To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - SlidesHow To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - Slides
 
Максим Барышиков-«WoT: Geographically distributed cluster of clusters»
Максим Барышиков-«WoT: Geographically distributed cluster of clusters»Максим Барышиков-«WoT: Geographically distributed cluster of clusters»
Максим Барышиков-«WoT: Geographically distributed cluster of clusters»
 
Apache Httpd and TLS certificates validations
Apache Httpd and TLS certificates validationsApache Httpd and TLS certificates validations
Apache Httpd and TLS certificates validations
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPC
 
Docker Networking with New Ipvlan and Macvlan Drivers
Docker Networking with New Ipvlan and Macvlan DriversDocker Networking with New Ipvlan and Macvlan Drivers
Docker Networking with New Ipvlan and Macvlan Drivers
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
 
When Crypto Attacks! (Yahoo 2009)
When Crypto Attacks! (Yahoo 2009)When Crypto Attacks! (Yahoo 2009)
When Crypto Attacks! (Yahoo 2009)
 

Viewers also liked

Andersen_HR_presentation_Kuripko
Andersen_HR_presentation_KuripkoAndersen_HR_presentation_Kuripko
Andersen_HR_presentation_Kuripko
Cherevatenko Irina
 
HR-проект, который Вам боялись доверить, или как стать HR бизнес-партнером - ...
HR-проект, который Вам боялись доверить, или как стать HR бизнес-партнером - ...HR-проект, который Вам боялись доверить, или как стать HR бизнес-партнером - ...
HR-проект, который Вам боялись доверить, или как стать HR бизнес-партнером - ...
PechaKucha Ukraine
 

Viewers also liked (20)

Dataplane networking acceleration with OpenDataplane / Максим Уваров (Linaro)
Dataplane networking acceleration with OpenDataplane / Максим Уваров (Linaro)Dataplane networking acceleration with OpenDataplane / Максим Уваров (Linaro)
Dataplane networking acceleration with OpenDataplane / Максим Уваров (Linaro)
 
Пиксельные шейдеры для Web-разработчиков. Программируем GPU / Денис Радин (Li...
Пиксельные шейдеры для Web-разработчиков. Программируем GPU / Денис Радин (Li...Пиксельные шейдеры для Web-разработчиков. Программируем GPU / Денис Радин (Li...
Пиксельные шейдеры для Web-разработчиков. Программируем GPU / Денис Радин (Li...
 
Key transparency: Blockchain meets NoiseSocket / Алексей Ермишкин (Virgil)
Key transparency: Blockchain meets NoiseSocket / Алексей Ермишкин (Virgil)Key transparency: Blockchain meets NoiseSocket / Алексей Ермишкин (Virgil)
Key transparency: Blockchain meets NoiseSocket / Алексей Ермишкин (Virgil)
 
Logging and ranting / Vytis Valentinavičius (Lamoda)
Logging and ranting / Vytis Valentinavičius (Lamoda)Logging and ranting / Vytis Valentinavičius (Lamoda)
Logging and ranting / Vytis Valentinavičius (Lamoda)
 
HR бизнес-партнер — место HR в организации
HR бизнес-партнер — место HR в организацииHR бизнес-партнер — место HR в организации
HR бизнес-партнер — место HR в организации
 
Просто HR. HR – это просто! Содержание и условия участия
Просто HR. HR – это просто! Содержание и условия участияПросто HR. HR – это просто! Содержание и условия участия
Просто HR. HR – это просто! Содержание и условия участия
 
Мотивация. Что посеял, то и пожнешь. Что посеять, чтобы "пожать" мотивацию?
Мотивация. Что посеял, то и пожнешь. Что посеять, чтобы "пожать" мотивацию?Мотивация. Что посеял, то и пожнешь. Что посеять, чтобы "пожать" мотивацию?
Мотивация. Что посеял, то и пожнешь. Что посеять, чтобы "пожать" мотивацию?
 
Andersen_HR_presentation_Kuripko
Andersen_HR_presentation_KuripkoAndersen_HR_presentation_Kuripko
Andersen_HR_presentation_Kuripko
 
HR-проект, который Вам боялись доверить, или как стать HR бизнес-партнером - ...
HR-проект, который Вам боялись доверить, или как стать HR бизнес-партнером - ...HR-проект, который Вам боялись доверить, или как стать HR бизнес-партнером - ...
HR-проект, который Вам боялись доверить, или как стать HR бизнес-партнером - ...
 
ИТ в розничной торговле 2014
ИТ в розничной торговле 2014ИТ в розничной торговле 2014
ИТ в розничной торговле 2014
 
HR-форум Юга России 2012
HR-форум Юга России 2012HR-форум Юга России 2012
HR-форум Юга России 2012
 
HR-партнер: миф или реальность?
HR-партнер: миф или реальность?HR-партнер: миф или реальность?
HR-партнер: миф или реальность?
 
Силиконовая долина: закулисье глазами HR
Силиконовая долина: закулисье глазами HRСиликоновая долина: закулисье глазами HR
Силиконовая долина: закулисье глазами HR
 
Hr as a business partner
Hr as a business partnerHr as a business partner
Hr as a business partner
 
What makes an Exceptional HR Business Partner?
What makes an Exceptional HR Business Partner?What makes an Exceptional HR Business Partner?
What makes an Exceptional HR Business Partner?
 
Дмитрий Лобасев. Подготовка корпоративной культуры к внедрению Agile.
Дмитрий Лобасев. Подготовка корпоративной культуры к внедрению Agile.Дмитрий Лобасев. Подготовка корпоративной культуры к внедрению Agile.
Дмитрий Лобасев. Подготовка корпоративной культуры к внедрению Agile.
 
Ukrainians at Tech Events of the World
Ukrainians at Tech Events of the WorldUkrainians at Tech Events of the World
Ukrainians at Tech Events of the World
 
Как зажечь огонь в сердцах сотрудников?
Как зажечь огонь в сердцах сотрудников?Как зажечь огонь в сердцах сотрудников?
Как зажечь огонь в сердцах сотрудников?
 
Как не вступить в "100 шагов EPAM"
Как не вступить в "100 шагов EPAM"Как не вступить в "100 шагов EPAM"
Как не вступить в "100 шагов EPAM"
 
Управление изменениями в зрелых Hr системах
Управление изменениями в зрелых Hr системахУправление изменениями в зрелых Hr системах
Управление изменениями в зрелых Hr системах
 

Similar to Linux kernel TLS и HTTPS / Александр Крижановский (Tempesta Technologies)

Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Ontico
 
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Alexander Krizhanovsky
 
Computer network (4)
Computer network (4)Computer network (4)
Computer network (4)
NYversity
 
Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014
bryan_call
 

Similar to Linux kernel TLS и HTTPS / Александр Крижановский (Tempesta Technologies) (20)

Linux HTTPS/TCP/IP Stack for the Fast and Secure Web
Linux HTTPS/TCP/IP Stack for the Fast and Secure WebLinux HTTPS/TCP/IP Stack for the Fast and Secure Web
Linux HTTPS/TCP/IP Stack for the Fast and Secure Web
 
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
 
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
HTTP/2 Introduction
HTTP/2 IntroductionHTTP/2 Introduction
HTTP/2 Introduction
 
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
 
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...Accelerating and Securing your Applications in AWS. In-depth look at Solving ...
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...
 
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
 
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
 
Computer network (4)
Computer network (4)Computer network (4)
Computer network (4)
 
Hands on with CoAP and Californium
Hands on with CoAP and CaliforniumHands on with CoAP and Californium
Hands on with CoAP and Californium
 
TLS - 2016 Velocity Training
TLS - 2016 Velocity TrainingTLS - 2016 Velocity Training
TLS - 2016 Velocity Training
 
Ngrep commands
Ngrep commandsNgrep commands
Ngrep commands
 
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openresty
 
Http2 in practice
Http2 in practiceHttp2 in practice
Http2 in practice
 
Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014
 
Kafka elastic search meetup 09242018
Kafka elastic search meetup 09242018Kafka elastic search meetup 09242018
Kafka elastic search meetup 09242018
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
 

More from Ontico

Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Ontico
 

More from Ontico (20)

One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
 
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
 
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
 
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
 
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
 
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
 
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
 
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
 
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
 
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
 
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
 
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
 
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
 
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
 
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
 
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
 
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
 
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
 
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
 

Recently uploaded

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 

Recently uploaded (20)

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 

Linux kernel TLS и HTTPS / Александр Крижановский (Tempesta Technologies)

  • 1. Linux Kernel TLS & HTTPS Alexander Krizhanovsky Tempesta Technologies, Inc. ak@tempesta-tech.com
  • 2. HTTPS challenges HTTP(S) is a core protocol for the Internet (IoT, SaaS, Social networks etc.) HTTP(S) DDoS is tricky ● Asymmetric DDoS (compression, TLS handshake etc.) ● A lot of IP addresses with low traffic (IoT) ● Machine learning is used for clustering ● How to filter out all HTTP requests with “Host: www.example.com:80”? ● "Lessons From Defending The Indefensible": https://www.youtube.com/watch?v=pCVTEx1ouyk
  • 3. TCP stream filter IPtables strings, BPF, XDP, NIC filters ● HTTP headers can cross packet bounds ● Scan large URI or Cookie for Host value? Web accelerator ● aren’t designed (suitable) for HTTP filtering
  • 4. IPS vs HTTP DDoS e.g. Suricata, has powerful rules syntax at L3-L7 Not a TCP end point => evasions are possible SSL/TLS ● SSL terminator is required => many data copies & context switches ● or double SSL processing (at IDS & at Web server) Double HTTP parsing Doesn’t improve Web server peroformance (mitigation != prevention)
  • 5. Interbreed an HTTP accelerator and a firewall TCP & TLS end point Very fast HTTP parser to process HTTP floods Network I/O optimized for massive ingress traffic Advanced filtering abilities at all network layers Very fast Web cache to mitigate DDoS which we can’t filter out ● ML takes some time for bots clusterization ● False negatives are unavoidable
  • 7. WAF accelerator Just like Web accelerator Advanced load balancing: ● Server groups by any HTTP field ● Rendezvous hashing ● Ratio ● Adaptive & predictive Some DDoS attacks can be just normally serviced
  • 8. Web-accelerator capabilities Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc. ● cache static Web-content ● load balancing ● rewrite URLs, ACL, Geo, filtering etc. ● C10K
  • 9. Web-accelerator capabilities Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc. ● cache static Web-content ● load balancing ● rewrite URLs, ACL, Geo, filtering? etc. ● C10K – is it a problem for bot-net? SSL? ● what about tons of 'GET / HTTP/1.0nn'? (CORNER CASES!)
  • 10. Web-accelerator capabilities Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc. ● cache static Web-content ● load balancing ● rewrite URLs, ACL, Geo, filtering? etc. ● C10K – is it a problem for bot-net? SSL? ● what about tons of 'GET / HTTP/1.0nn'? (CORNER CASES!) Kernel-mode Web-accelerators: TUX, kHTTPd ● basically the same sockets and threads ● zero-copy → sendfile(), lazy TLB
  • 11. Web-accelerator capabilities Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc. ● cache static Web-content ● load balancing ● rewrite URLs, ACL, Geo, filtering? etc. ● C10K – is it a problem for bot-net? SSL? ● what about tons of 'GET / HTTP/1.0nn'? (CORNER CASES!) Kernel-mode Web-accelerators: TUX, kHTTPd ● basically the same sockets and threads ● zero-copy → sendfile(), lazy TLB => not needed
  • 12. Web-accelerator capabilities Nginx, Varnish, Apache Traffic Server, Squid, Apache HTTPD etc. ● cache static Web-content ● load balancing ● rewrite URLs, ACL, Geo, filtering? etc. ● C10K – is it a problem for bot-net? SSL? ● what about tons of 'GET / HTTP/1.0nn'? (CORNER CASES!) Kernel-mode Web-accelerators: TUX, kHTTPd NEED AGAIN ● basically the same sockets and threads TO MITIGATE ● zero-copy → sendfile(), lazy TLB => not needed HTTPS DDOS!
  • 13. Web-accelerators are slow Slow & non-scalable network I/O (queues are bad for CPU caches) Data copyings & syscalls Dummy HTTP FSMs HTTP strings are special: LIBC functions don’t work well Don’t care about the corner cases Sometimes request blocking is slower than serving it https://www.netdevconf.org/2.1/session.html?krizhanovsky
  • 15. Web-accelerators are slow: strings We have AVX2, but GLIBC doesn’t still use it HTTP strings are special: ● No ‘0’-termination (if you’re zero-copy) ● Special delimiters (‘:’ or CRLF) ● strcasecmp(): no need case conversion for one string ● strspn(): limited number of accepted alphabets switch()-driven FSM is even worse
  • 16. Fast HTTP parser http://natsys-lab.blogspot.ru/2014/11/the-fast-finite-state-machine-for- http.html ● 1.6-1.8 times faster than Nginx’s HTTP optimized AVX2 strings processing: http://natsys-lab.blogspot.ru/2016/10/http-strings-processing-using-c- sse42.html ● ~1KB strings: ● strncasecmp() ~x3 faster than GLIBC’s ● URI matching ~x6 faster than GLIBC’s strspn() ● kernel_fpu_begin()/kernel_fpu_end() for whole softirq shot
  • 17. HTTP strong validation TODO: https://github.com/tempesta-tech/tempesta/issues/628 Injections: specify allowed URI characters for a Web app Resistant to large HTTP fields Easy to do with SIMD https://natsys-lab.blogspot.ru/2016/10/http-strings-processing-using-c- sse42.html
  • 18. Fast network I/O: kernel bypass Netmap, DPDK, PF_RING etc. No [zero-copy] tcpdump, tc, ipvs, iptables etc. User-space TCP/IP stack issues ● No preemption control => no [good] RCU ● pthread_spinlock are naive (vs. MCS locks.) ● No access to buddy allocator (need memory reservation) Win for simple applications only (IP & UDP, but not for TCP & HTTP)
  • 19. Web-accelerators are slow: SSL/TLS copying User-kernel space copying ● Copy network data to user space ● Encrypt/decrypt it ● Copy the date to kernel for transmission (or splice()) Kernel-mode TLS ● Facebook & RedHat: https://lwn.net/Articles/666509/ ● Mellanox: https://netdevconf.org/1.2/session.html?boris-pismenny ● Netflix: https://people.freebsd.org/~rrs/asiabsd_2015_tls.pdf
  • 20. Kernel SSL/TLS: the history KSSL (http://www.ksl.ci.kyutech.ac.jp/~kourai/research/kssl/kssl.html) ● OpenSSL 0.9.7i ● Linux 2.6.14 Solaris kernel SSL proxy ● Mostly for old hardware with slow context switch
  • 21. Linux kernel TLS (since 4.13) CONFIG_TLS (switched off by default) Symmetric encryption only (no handshake) Example (https://github.com/Mellanox/tls-af_ktls_tool): struct tls12_crypto_info_aes_gcm_128 ci = { .version = TLS_1_2_VERSION, .cipher_type = TLS_CIPHER_AES_GCM_128 }; connect(sd, ..., ...); gnutls_handshake(*session); gnutls_record_get_state(session, ..., ..., iv, key, seq); memcpy(ci.iv, seq, TLS_CIPHER_AES_GCM_128_IV_SIZE); memcpy(ci.rec_seq, seq, TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE); memcpy(ci.key, key, TLS_CIPHER_AES_GCM_128_KEY_SIZE); memcpy(ci.salt, iv, TLS_CIPHER_AES_GCM_128_SALT_SIZE); setsockopt(sd, SOL_TCP, TCP_ULP, "tls", sizeof("tls")); setsockopt(sd, SOL_TLS, TLS_TX, &ci, sizeof(ci));
  • 22. Mellanox: TLS offload to network devices https://netdevconf.org/1.2/papers/netdevconf-TLS.pdf Control path: kTLS (user space handshakes) Data path: per-record encryption
  • 23. Linux kernel TLS & DDoS Most Facebook users have established sessions TLS handshake is still an issue ● TLS 1.3 has 1-RTT handshake and is almost here ● TLS 1.2 must live for a long time (is Windows XP still alive?) ● TLS renegotiation
  • 24. HTTPS/TCP/IP stack (in progress) Alternative to user space TCP/IP stacks HTTPS is built into TCP/IP stack Kernel TLS (fork from mbedTLS) – [almost] no copying (1 human month to port TLS to kernel!) HTTP firewall plus to IPtables and Socket filter Very fast HTTP parser and strings processing using AVX2 Cache-conscious in-memory Web-cache for DDoS mitigation TODO ● HTTP QoS for asymmetric DDoS mitigation ● DSL for multi-layer filter rules
  • 26. TODO: HTTP QoS for asymmetric DDoS mitigation https://github.com/tempesta-tech/tempesta/issues/488 “Web2K: Bringing QoS to Web Servers” by Preeti Bhoj et al. Local stress: packet drops, queues overrun, response latency etc (kernel: cheap statistics for asymmetric DDoS) Upsream stress: req_num / resp_num, response time etc. Static QoS rules per vhost: HTTP RPS, integration w/ Qdisc - TBD Actions: reduce TCP window, don’t accept new connections, close existing connections
  • 27. User space HTTP proxying 1. Receive request at CPU1 2. Copy request to user space 3. Update headers 4. Copy request to kernel space 5. Send the request from CPU2 3 data copies Access TCP control blocks and data buffers from different CPUs
  • 28. Synchronous sockets: HTTPS/TCP/IP stack Socket callbacks call TLS and HTTP processing Everything is processing in softirq (while the data is hot) No receive & accept queues No file descriptors Less locking
  • 29. Synchronous sockets: HTTPS/TCP/IP stack Socket callbacks call TLS and HTTP processing Everything is processing in softirq (while the data is hot) No receive & accept queues No file descriptors Less locking Lock-free inter-CPU transport => faster socket reading => lower latency
  • 30. skb page allocator: zero-copy HTTP messages adjustment Add/remove/update HTTP headers w/o copies skb and its head are allocated in the same page fragment or a compound page
  • 31. skb page allocator: zero-copy HTTP messages adjustment Add/remove/update HTTP headers w/o copies skb and its head are allocated in the same page fragment or a compound page
  • 32. HTTP/2 Pros ● Responses are sent in parallel and in any order (no head-of-line blocking) ● Compression Cons ● Zero copy techniques aren’t(?) applicable => For client connections (slow network), not for LAN (fast network)
  • 33. QUIC? UDP-based with flow control 10% duplicates 0-RTT handshakes Implemented as a user-space library Questions: ● Opaque UDP traffic just like UDP flood ● TCP fast open + TLS 1.3 seem solve handshake problem
  • 34. RFC 7457: Summarizing Known Attacks on TLS (D)DoS ● Renegotiation (should be disabled) ● Assymetric denial of service ...and others
  • 35. TLS 1.3: client puzzles https://tools.ietf.org/html/draft-nygren-tls-client-puzzles-02 ServerHello sends a puzzle to a client ● Cookie (simple echo) ● SHA-256 or SHA-512(many times) ● Genrealized birthday problem The latest draft is dated by Jul 1, 2017
  • 36. HTTP(S) DDoS mitigation: rate limits Rate limits ● request_rate, request_burst ● connection_rate, connection_burst ● concurrent_connections ● TODO: TLS handshakes (https://github.com/tempesta-tech/tempesta/issues/832) Slow HTTP ● client_header_timeout, client_body_timeout ● http_header_cnt ● http_header_chunk_cnt, http_body_chunk_cnt
  • 37. Web security checks Length limits: http_uri_len, http_field_len, http_body_len Content validation: http_host_required, http_ct_required, http_ct_vals, http_methods HTTP Response Splitting: count and match requests and responses Injections: carefully verify allowed character sets ...and many upcoming filters: https://github.com/tempesta-tech/tempesta/labels/security Not a featureful WAF
  • 38. Sticky cookie User/session identification ● Cookie challenge for dummy DDoS bots ● Persistent/sessions scheduling (no rescheduling on a server failure) Enforce: HTTP 302 redirect sticky name=__tfw_user_id__ enforce;
  • 39. Sticky cookie User/session identification ● Cookie challenge for dummy DDoS bots ● Persistent/sessions scheduling (no rescheduling on a server failure) Enforce: HTTP 302 redirect sticky name=__tfw_user_id__ enforce; TODO: JavaScript challenge https://github.com/tempesta-tech/tempesta/issues/536
  • 40. TODO: Multi-layer firewall https://github.com/tempesta-tech/tempesta/issues/102 if ((req.user_agent =~ /firefox/i || req.cookie !~ /^our_tracking_cookie/) && (req.x_forwarded_for != "1.1.1.1" || client.addr == 1.1.1.1)) # Block the client at IP layer, so it will be filtered # efficiently w/o further HTTP processing. tdb.insert("ip_filter", client.addr, evict=10000); Nftables integration via mark https://github.com/tempesta-tech/tempesta/issues/760
  • 42. Performance analysis ~x3 faster than Nginx (~600K HTTP RPS) for normal Web cache operations Must be much faster to block HTTP DDoS (DDoS emulation is an issue) Similar to DPDK/user-space TCP/IP stacks http://www.seastar-project.org/ http-performance/ ...bypassing Linux TCP/IP isn’t the only way to get a fast Web server ...lives in Linux infrastructure: LVS, tc, IPtables, eBPF, tcpdump etc.
  • 43. Keep the kernel small Just 30K LoC (compare w/ 120K LoC of BtrFS) Only generic and crucial HTTPS logic is in kernel Supplementary logic is considered for user space ● HTTP compression & decompression https://github.com/tempesta-tech/tempesta/issues/636 ● Advanced DDoS mitigation & WAF (e.g. full POST processing) ● ...other HTTP users (Web frameworks?) Zero-copy kernel-user space transport for minimizing kernel code
  • 44. TODO: Zero-copy kernel-user space transport HTTP compression HTTPS DDoS mitigation & WAF ● Machine learning clusterization in user space ● Automatic L3-L7 filtering rules generation
  • 45. Thanks! Web-site: http://tempesta-tech.com Availability: https://github.com/tempesta-tech/tempesta Blog: http://natsys-lab.blogspot.com E-mail: ak@tempesta-tech.com We are hiring!