|
| 1 | +Wed Mar 28 23:48:24 2018 Eric Wong < [email protected]> |
| 2 | + |
| 3 | + webrick: prevent response splitting and header injection |
| 4 | + |
| 5 | + Original patch by tenderlove (with minor style adjustments). |
| 6 | + |
| 7 | + * lib/webrick/httpresponse.rb (send_header): call check_header |
| 8 | + (check_header): raise on embedded CRLF in header value |
| 9 | + * test/webrick/test_httpresponse.rb |
| 10 | + (test_prevent_response_splitting_headers): new test |
| 11 | + * (test_prevent_response_splitting_cookie_headers): ditto |
| 12 | + |
| 13 | +Wed Mar 28 23:45:36 2018 Eric Wong < [email protected]> |
| 14 | + |
| 15 | + webrick: use IO.copy_stream for multipart response |
| 16 | + |
| 17 | + Use the new Proc response body feature to generate a multipart |
| 18 | + range response dynamically. We use a flat array to minimize |
| 19 | + object overhead as much as possible; as many ranges may fit |
| 20 | + into an HTTP request header. |
| 21 | + |
| 22 | + * lib/webrick/httpservlet/filehandler.rb (multipart_body): new method |
| 23 | + (make_partial_content): use multipart_body |
| 24 | + |
| 25 | + webrick/httprequest: limit request headers size |
| 26 | + |
| 27 | + We use the same 112 KB limit started (AFAIK) by Mongrel, Thin, |
| 28 | + and Puma to prevent malicious users from using up all the memory |
| 29 | + with a single request. This also limits the damage done by |
| 30 | + excessive ranges in multipart Range: requests. |
| 31 | + |
| 32 | + Due to the way we rely on IO#gets and the desire to keep |
| 33 | + the code simple, the actual maximum header may be 4093 bytes |
| 34 | + larger than 112 KB, but we're splitting hairs at that point. |
| 35 | + |
| 36 | + * lib/webrick/httprequest.rb: define MAX_HEADER_LENGTH |
| 37 | + (read_header): raise when headers exceed max length |
| 38 | + |
| 39 | + webrick/httpservlet/cgihandler: reduce memory use |
| 40 | + |
| 41 | + WEBrick::HTTPRequest#body can be passed a block to process the |
| 42 | + body in chunks. Use this feature to avoid building a giant |
| 43 | + string in memory. |
| 44 | + |
| 45 | + * lib/webrick/httpservlet/cgihandler.rb (do_GET): |
| 46 | + avoid reading entire request body into memory |
| 47 | + (do_POST is aliased to do_GET, so it handles bodies) |
| 48 | + |
| 49 | + webrick/httprequest: raise correct exception |
| 50 | + |
| 51 | + "BadRequest" alone does not resolve correctly, it is in the |
| 52 | + HTTPStatus namespace. |
| 53 | + |
| 54 | + * lib/webrick/httprequest.rb (read_chunked): use correct exception |
| 55 | + * test/webrick/test_httpserver.rb (test_eof_in_chunk): new test |
| 56 | + |
| 57 | + webrick/httprequest: use InputBufferSize for chunked requests |
| 58 | + |
| 59 | + While WEBrick::HTTPRequest#body provides a Proc interface |
| 60 | + for streaming large request bodies, clients must not force |
| 61 | + the server to use an excessively large chunk size. |
| 62 | + |
| 63 | + * lib/webrick/httprequest.rb (read_chunk_size): limit each |
| 64 | + read and block.call to :InputBufferSize in config. |
| 65 | + * test/webrick/test_httpserver.rb (test_big_chunks): new test |
| 66 | + |
| 67 | + webrick: add test for Digest auth-int |
| 68 | + |
| 69 | + No changes to the actual code, this is a new test for |
| 70 | + a feature for which no tests existed. I don't understand |
| 71 | + the Digest authentication code well at all, but this is |
| 72 | + necessary for the subsequent change. |
| 73 | + |
| 74 | + * test/webrick/test_httpauth.rb (test_digest_auth_int): new test |
| 75 | + (credentials_for_request): support bodies with POST |
| 76 | + |
| 77 | + webrick/httpauth/digestauth: stream req.body |
| 78 | + |
| 79 | + WARNING! WARNING! WARNING! LIKELY BROKEN CHANGE |
| 80 | + |
| 81 | + Pass a proc to WEBrick::HTTPRequest#body to avoid reading a |
| 82 | + potentially large request body into memory during |
| 83 | + authentication. |
| 84 | + |
| 85 | + WARNING! this will break apps completely which want to do |
| 86 | + something with the body besides calculating the MD5 digest |
| 87 | + of it. |
| 88 | + |
| 89 | + Also, keep in mind that probably nobody uses "auth-int". |
| 90 | + Servers such as Apache, lighttpd, nginx don't seem to |
| 91 | + support it; nor does curl when using POST/PUT bodies; |
| 92 | + and we didn't have tests for it until now... |
| 93 | + |
| 94 | + * lib/webrick/httpauth/digestauth.rb (_authenticate): stream req.body |
| 95 | + |
| 96 | +Wed Mar 28 23:41:53 2018 NAKAMURA Usaku < [email protected]> |
| 97 | + |
| 98 | + get rid of test error/failure on Windows introduced at r62955 |
| 99 | + |
| 100 | + * lib/webrick/httpresponse.rb (send_body_io): use seek if |
| 101 | + NotImplementedError is raised in IO.copy_stream with offset. |
| 102 | + |
| 103 | + * lib/webrick/httpservlet/filehandler.rb (multipart_body): ditto. |
| 104 | + |
| 105 | +Wed Mar 28 23:41:53 2018 Eric Wong < [email protected]> |
| 106 | + |
| 107 | + webrick: support Proc objects as body responses |
| 108 | + |
| 109 | + * lib/webrick/httpresponse.rb (send_body): call send_body_proc |
| 110 | + (send_body_proc): new method |
| 111 | + (class ChunkedWrapper): new class |
| 112 | + |
| 113 | + * test/webrick/test_httpresponse.rb (test_send_body_proc): new test |
| 114 | + (test_send_body_proc_chunked): ditto |
| 115 | + [Feature #855] |
| 116 | + |
| 117 | + webrick: favor .write over << method |
| 118 | + |
| 119 | + This will make the next change to use IO.copy_stream |
| 120 | + easier-to-read. When we can drop Ruby 2.4 support in a few |
| 121 | + years, this will allow us to use writev(2) with multiple |
| 122 | + arguments for headers and chunked responses. |
| 123 | + |
| 124 | + * lib/webrick/cgi.rb (write): new wrapper method |
| 125 | + lib/webrick/httpresponse.rb: (send_header): use socket.write |
| 126 | + (send_body_io): ditto |
| 127 | + (send_body_string): ditto |
| 128 | + (send_body_proc): ditto |
| 129 | + (_write_data): ditto |
| 130 | + (ChunkedWrapper#write): ditto |
| 131 | + (_send_file): ditto |
| 132 | + |
| 133 | + webrick/httpresponse: IO.copy_stream for regular files |
| 134 | + |
| 135 | + Remove the redundant _send_file method since its functionality |
| 136 | + is unnecessary with IO.copy_stream. IO.copy_stream also allows |
| 137 | + the use of sendfile under some OSes to speed up copies to |
| 138 | + non-TLS sockets. |
| 139 | + |
| 140 | + Testing with "curl >/dev/null" and "ruby -run -e httpd" to |
| 141 | + read a 1G file over Linux loopback reveals a reduction from |
| 142 | + around ~0.770 to ~0.490 seconds on the client side. |
| 143 | + |
| 144 | + * lib/webrick/httpresponse.rb (send_body_io): use IO.copy_stream |
| 145 | + (_send_file): remove |
| 146 | + [Feature #14237] |
| 147 | + |
| 148 | + webrick: use IO.copy_stream for single range response |
| 149 | + |
| 150 | + This is also compatible with range responses generated |
| 151 | + by Rack::File (tested with rack 2.0.3). |
| 152 | + |
| 153 | + * lib/webrick/httpresponse.rb (send_body_io): use Content-Range |
| 154 | + * lib/webrick/httpservlet/filehandler.rb (make_partial_content): |
| 155 | + use File object for the single range case |
| 156 | + * test/webrick/test_filehandler.rb (get_res_body): use send_body |
| 157 | + to test result |
| 158 | + |
| 159 | + test/webrick/test_filehandler.rb: stricter multipart range test |
| 160 | + |
| 161 | + We need to ensure we generate compatibile output in |
| 162 | + the face of future changes |
| 163 | + |
| 164 | + * test/webrick/test_filehandler.rb (test_make_partial_content): |
| 165 | + check response body |
| 166 | + |
| 167 | + webrick: quiet warning for multi-part ranges |
| 168 | + |
| 169 | + Content-Length is ignored by WEBrick::HTTPResponse even if we |
| 170 | + calculate it, so instead we chunk responses to HTTP/1.1 clients |
| 171 | + and terminate HTTP/1.0 connections. |
| 172 | + |
| 173 | + * lib/webrick/httpservlet/filehandler.rb (make_partial_content): |
| 174 | + quiet warning |
| 175 | + |
| 176 | + webrick/httpresponse: make ChunkedWrapper copy_stream-compatible |
| 177 | + |
| 178 | + The .write method needs to return the number of bytes written |
| 179 | + to avoid confusing IO.copy_stream. |
| 180 | + |
| 181 | + * lib/webrick/httpresponse.rb (ChunkedWrapper#write): return bytes written |
| 182 | + (ChunkedWrapper#<<): return self |
| 183 | + |
| 184 | + webrick: use IO.copy_stream for multipart response |
| 185 | + |
| 186 | + Use the new Proc response body feature to generate a multipart |
| 187 | + range response dynamically. We use a flat array to minimize |
| 188 | + object overhead as much as possible; as many ranges may fit |
| 189 | + into an HTTP request header. |
| 190 | + |
| 191 | + * lib/webrick/httpservlet/filehandler.rb (multipart_body): new method |
| 192 | + (make_partial_content): use multipart_body |
| 193 | + |
| 194 | +Wed Mar 28 23:37:18 2018 Nobuyoshi Nakada < [email protected]> |
| 195 | + |
| 196 | + pack.c: fix underflow |
| 197 | + |
| 198 | + * pack.c (pack_unpack_internal): get rid of underflow. |
| 199 | + https://hackerone.com/reports/298246 |
| 200 | + |
| 201 | +Wed Mar 28 23:35:28 2018 Nobuyoshi Nakada < [email protected]> |
| 202 | + |
| 203 | + unixsocket.c: check NUL bytes |
| 204 | + |
| 205 | + * ext/socket/unixsocket.c (rsock_init_unixsock): check NUL bytes. |
| 206 | + https://hackerone.com/reports/302997 |
| 207 | + |
| 208 | + unixsocket.c: abstract namespace |
| 209 | + |
| 210 | + * ext/socket/unixsocket.c (unixsock_path_value): fix r62991 for |
| 211 | + Linux abstract namespace. |
| 212 | + |
| 213 | +Wed Mar 28 23:30:32 2018 SHIBATA Hiroshi < [email protected]> |
| 214 | + |
| 215 | + Ignore file separator from tmpfile/tmpdir name. |
| 216 | + |
| 217 | +Wed Mar 28 23:27:23 2018 Nobuyoshi Nakada < [email protected]> |
| 218 | + |
| 219 | + dir.c: check NUL bytes |
| 220 | + |
| 221 | + * dir.c (GlobPathValue): should be used in rb_push_glob only. |
| 222 | + other methods should use FilePathValue. |
| 223 | + https://hackerone.com/reports/302338 |
| 224 | + |
| 225 | + * dir.c (rb_push_glob): expand GlobPathValue |
| 226 | + |
| 227 | +Sat Feb 17 01:24:49 2018 SHIBATA Hiroshi < [email protected]> |
| 228 | + |
| 229 | + Merge RubyGems 2.7.6 from upstream. |
| 230 | + |
| 231 | + It fixed some security vulnerabilities. |
| 232 | + |
| 233 | + http://blog.rubygems.org/2018/02/15/2.7.6-released.html |
| 234 | + |
| 235 | + fix regexp literal warning. |
| 236 | + |
| 237 | + * test/rubygems/test_gem_server.rb: eliminate duplicated character class warning. |
| 238 | + [Bug #14481] |
| 239 | + |
1 | 240 | Fri Dec 15 00:08:26 2017 NAKAMURA Usaku < [email protected]> |
2 | 241 |
|
3 | 242 | * test/net/ftp/test_ftp.rb (process_port_or_eprt): merge a part of |
|
0 commit comments