0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00
Commit graph

1978 commits

Author SHA1 Message Date
Loïc Hoguin
5ffb4f98e0
Make cowboy_compress_h add vary: accept-encoding 2019-10-04 13:32:35 +02:00
Loïc Hoguin
1a9e62ae2a
Improve some early_error tests 2019-10-04 11:57:29 +02:00
Loïc Hoguin
28aee1f272
Document media type wildcard in content_types_accepted 2019-10-03 16:20:29 +02:00
Loïc Hoguin
1ba48c58b1
Make stream_error early_error reasons consistent
Now both HTTP/1.1 and HTTP/2 follow the documented format.
HTTP/1.1 was including an extra element containing the
StreamID before, which was unnecessary because it is also
given as argument to the callback.

HTTP/2 early_error will now include headers in its PartialReq.
2019-10-03 16:04:17 +02:00
Loïc Hoguin
57badc9082
Add HTTP/2 tests with responses with HTTP/1.1 specific headers 2019-10-03 11:56:57 +02:00
Loïc Hoguin
99df823cc3
Document stopping the listener in App:stop/1 2019-10-03 10:09:35 +02:00
Loïc Hoguin
e4a535cfa6
Fix another Dialyzer warning 2019-10-02 21:51:27 +02:00
Loïc Hoguin
eaa052616f
Ensure we can stream the response body from any process 2019-10-02 20:30:32 +02:00
Loïc Hoguin
20660d7566
Ensure we can read the request body from any process 2019-10-02 19:12:05 +02:00
Loïc Hoguin
8f6ee9c186
Make sure cowboy_http doesn't receive stray timeout messages 2019-10-02 16:59:41 +02:00
Loïc Hoguin
f673e191b3
Add {set_options, #{metrics_user_data := Map}}
This allows giving custom metadata to the metrics stream handler.
This can be useful to for example provide the name of the
module handling the request which is only known after routing.
But any user data is allowed.

When called multiple times the user data maps are merged.
2019-10-02 15:23:23 +02:00
Loïc Hoguin
a14ecf19c6
Add more HTTP/1.1 header parsing tests
Fix a case where Cowboy was waiting for more data that simply
did not come. Now Cowboy will generate an error immediately
when a header line has no colon separator.

These test cases come from known request smuggling attack
vectors. Cowboy was not vulnerable to any of them.
2019-10-02 13:31:13 +02:00
Loïc Hoguin
8e31548597
Fix a Dialyzer warning and improve some types 2019-10-02 12:01:40 +02:00
Loïc Hoguin
ab44985a9e
Fix HTTP/2 CVEs
A number of HTTP/2 CVEs were documented recently:

  https://www.kb.cert.org/vuls/id/605641/

This commit, along with a few changes and additions in Cowlib,
fix or improve protection against all of them.

For CVE-2019-9511, also known as Data Dribble, the new option
stream_window_data_threshold can be used to control how little
the DATA frames that Cowboy sends can get.

For CVE-2019-9516, also known as 0-Length Headers Leak, Cowboy
will now simply reject streams containing 0-length header names.

For CVE-2019-9517, also known as Internal Data Buffering, the
backpressure changes were already pretty good at preventing this
issue, but a new option max_connection_buffer_size was added for
even better control over how much memory we are willing to allocate.

For CVE-2019-9512, also known as Ping Flood; CVE-2019-9515, also
known as Settings Flood; CVE-2019-9518, also known as Empty Frame
Flooding; and similar undocumented scenarios, a frame rate limiting
mechanism was added. By default Cowboy will now allow 1000 frames
every 10 seconds. This can be configured via max_received_frame_rate.

For CVE-2019-9514, also known as Reset Flood, another rate limiting
mechanism was added and can be configured via max_reset_stream_rate.
By default Cowboy will do up to 10 stream resets every 10 seconds.

Finally, nothing was done for CVE-2019-9513, also known as Resource
Loop, because Cowboy does not currently implement the HTTP/2
priority mechanism (in parts because these issues were well known
from the start).

Tests were added for all cases except Internal Data Buffering,
which I'm not sure how to test, and Resource Loop, which is not
currently relevant.
2019-10-02 10:44:45 +02:00
Loïc Hoguin
e1d4524118
Update gun_down messages in test suites 2019-10-02 10:10:43 +02:00
Loïc Hoguin
6ddabc2c21
Remove lingering_data tuple handling 2019-10-02 10:09:30 +02:00
Loïc Hoguin
cf84f59d9b
Add persistent_term support to the router 2019-09-28 15:40:41 +02:00
Loïc Hoguin
7bccad4d21
Only test on the latest release per OTP major version by default 2019-09-18 09:48:12 +02:00
Loïc Hoguin
d143235a79
Fix closing of connection on response_body_too_small 2019-09-16 11:34:51 +02:00
Loïc Hoguin
8452df0617
Split up urlencoded tests to speed up req_SUITE 2019-09-15 21:49:45 +02:00
Loïc Hoguin
da5487b5a3
Skip req_SUITE:read_body_mtu on Windows
On Windows the loopback MTU seems to be set to 0xFFFFFFFF
(basically no limit) which makes the test irrelevant.
2019-09-15 21:34:14 +02:00
Loïc Hoguin
2888e9e6ef
Increase the period for req_SUITE:read_body_period
This should increase the likelihood of the test succeeding
on slower systems when run over TLS.
2019-09-15 16:30:09 +02:00
Loïc Hoguin
ea976f02e0
Fix h2spec_SUITE init_per_suite return values 2019-09-15 11:18:35 +02:00
Loïc Hoguin
e28a339ccd
Fix intermittent failures in sys_SUITE 2019-09-15 10:01:32 +02:00
Loïc Hoguin
49af57d546
Implement backpressure on cowboy_req:stream_body
This should limit the amount of memory that Cowboy is using
when a handler is sending data much faster than the network.

The new max_stream_buffer_size is a soft limit and only has
an effect when the cowboy_stream_h handler is used.
2019-09-14 18:21:05 +02:00
Loïc Hoguin
4427108b69
Improve the cowboy_static consistency across platforms
As a result we explictly reject path_info components that include
a forward slash, backward slash or NUL character. This only applies
to the [...] part of the path for dir/priv_dir configuration.

Also improve the tests so that they work on Windows.
2019-09-07 12:18:16 +02:00
Loïc Hoguin
36836594f8
Fix tests failing following Gun update to master 2019-09-06 15:37:42 +02:00
Loïc Hoguin
86c16fdccc
Rename Gun's transport_opts to tls_opts 2019-09-06 13:33:15 +02:00
Loïc Hoguin
36441d35bd
Correct tests modifying mtime of static files
On macOS this resulted in failure because the mtime did not
change between test groups. The mtime should now always change.
2019-09-06 12:56:16 +02:00
Loïc Hoguin
702c7ff788
Use Gun master for tests
We no longer support OTP-19 so we don't need to stay on the
old Gun version anymore.
2019-09-06 12:30:25 +02:00
Loïc Hoguin
42eb6bae69
Fix using custom fields in Req 2019-09-06 12:25:02 +02:00
Loïc Hoguin
d14c59d905
Document unit for options that are in bytes 2019-09-06 11:53:19 +02:00
Loïc Hoguin
d5814a59f4
rest_pastebin example: Add a constraint for lang parameter 2019-09-05 18:05:44 +02:00
ruanpienaar
094387a08f
file_server example: Fix ../ links
Amended to fix an issue with repeated path segments.
2019-09-05 17:40:37 +02:00
Alastair Hole
bbf36a2ac0
Minor grammar correction
Noun 'setup' -> verb phrase 'set up'
2019-09-05 17:15:13 +02:00
Loïc Hoguin
48f417ac8f
Fix and optimize sending of WINDOW_UPDATE frames
For long-running connections it was possible for the connection
window to become larger than allowed by the protocol because the
window increases claimed by stream handlers were never reclaimed
even if no data was consumed.

The new code applies heuristics to fix this and reduce the number
of WINDOW_UPDATE frames that are sent. It includes six new options
to control that behavior: margin, max and threshold for both the
connection and stream windows. The margin is some extra space
added on top of the requested read size. The max is the maximum
window size at any given time. The threshold is a minimum window
size that must be reached before we even consider sending more
WINDOW_UPDATE frames. We also avoid sending WINDOW_UPDATE frames
when there is already enough space in the window, or when the
read size is 0.

Cowlib is set to master until a new tag is done.
2019-09-05 14:07:38 +02:00
Loïc Hoguin
aedf6379cc
Update CI to only test on OTP-20+ 2019-08-29 16:59:03 +02:00
Loïc Hoguin
a0a752ab10
Gracefully shut down HTTP/2 connections on GOAWAY 2019-08-16 16:37:04 +02:00
Tony Han
22cc88bae4
Add a zero-length DATA frame in the lingering_data test 2019-07-26 10:05:30 +02:00
Loïc Hoguin
5829f1b9ac
Add more related specs 2019-07-22 10:41:04 +02:00
juhlig
5b4e78fac4
Make Cowboy compatible with upcoming Ranch 2.0 2019-07-16 15:35:45 +02:00
Tony Han
7708fc77cd
Data received after RST_STREAM counts toward window 2019-07-16 15:32:58 +02:00
Loïc Hoguin
504c7c55f7
Add two related specs 2019-07-12 10:46:49 +02:00
Loïc Hoguin
dfeec3b74a
Add two new RFCs to the list 2019-05-27 13:43:01 +02:00
Loïc Hoguin
3030c2d5c9
Fix a few examples using cert instead of certfile 2019-05-13 11:25:00 +02:00
Loïc Hoguin
8875b07b37
Add RFC 8586 2019-04-24 20:24:23 +02:00
Loïc Hoguin
d846827b2a
Cowboy 2.6.3 2019-04-05 11:09:55 +02:00
Loïc Hoguin
39a0bf4bee
Add a prepare_tag target to help with releasing 2019-04-05 11:08:33 +02:00
Loïc Hoguin
d5489b4c73
Cowboy 2.6.2
Updates Cowlib to 2.7.2.
2019-04-04 11:23:50 +02:00
Loïc Hoguin
6f68d7d2d6
Use Gun 1.2.0 for tests to avoid OTP-19 issues
And temporarily depend on Cowlib master to confirm everything
works as intended.
2019-04-03 15:53:51 +02:00