Commit graph

143 commits

Author SHA1 Message Date
jbencteux
2a01c70837 fix Content-Encoding: x-gzip
RFC 7230 section 4.2.3 states that:

"A recipient SHOULD consider 'x-gzip' to be equivalent to 'gzip'"

This could lead to evasions as an attacker could use:

Content-Encoding: x-gzip

To bypass Bro's decompression.
2018-05-08 15:29:53 -05:00
Johanna Amann
eab80c8834 HTTP: Recognize and skip upgrade/websocket connections.
This adds a slight patch to the HTTP analyzer, which recognizez when a connection is
upgraded to a different protocol (using a 101 reply with a few specific headers being
set).

In this case, the analyzer stops further processing of the connection (which will
result in DPD errors) and raises a new event:

event http_connection_upgrade(c: connection, protocol: string);

Protocol contains the name of the protocol that is being upgraded to, as specified in
one of the header values.
2017-08-04 07:04:28 -07:00
Robin Sommer
310ef6974f Small fix to revert to double-% handling in HTTP back to old behaviour. 2017-07-28 12:22:54 -07:00
Johanna Amann
ade9aa219b Better handling of % at end of line. 2017-07-27 22:04:47 -07:00
Robin Sommer
17dc28b8a8 Merge remote-tracking branch 'origin/topic/seth/remove-unescaped_special_char-weird'
BIT-1611 #merged

* origin/topic/seth/remove-unescaped_special_char-weird:
  Add urldecoding for the unofficial %u00AE style of encoding.
  Remove the unescaped_special_char HTTP weird.
2016-06-06 18:05:38 -07:00
Seth Hall
2f6e069c00 Add urldecoding for the unofficial %u00AE style of encoding. 2016-05-25 09:35:23 -04:00
Seth Hall
3151a95381 Remove the unescaped_special_char HTTP weird.
This weird points out a lot of benign stuff and it would
be easily reimplemented in a Bro script.  This commit
also makes the minor change to update the reserved and
unreserved characters from a newer from of the URI RFC.
2016-05-25 08:33:30 -04:00
Robin Sommer
d8adcae3ba Merge branch 'master' of git.bro.org:bro 2016-03-08 07:38:49 -08:00
Johanna Amann
642542ab17 Merge branch 'topic/http-evasion' of https://github.com/0xcc-labs/bro
* 'topic/http-evasion' of https://github.com/0xcc-labs/bro:
  updated weird message and tests
  update of http btest
  detect possible HTTP evasion attempts
2016-03-07 13:09:56 -08:00
wglodek
9ebe7b2a21 updated weird message and tests 2016-03-04 18:03:24 -05:00
Johanna Amann
446a44787a Remove old string functions.
More specifically, this removes the functions:
strcasecmp_n
strchr_n
strrchr_n

and replaces the calls with the respective C-library calls that should
be part of just about all operating systems by now.
2016-03-04 12:02:19 -08:00
wglodek
93f52fcdd2 detect possible HTTP evasion attempts 2016-02-07 11:22:09 -05:00
Robin Sommer
642ef5d3c1 Tweaking how HTTP requests without URIs are handled.
The change from #49 made it an error to not have a URI. That however
then led requests with an URI yet no version to abort as well.
Instead, we now check if the token following the method is an "HTTP/"
version identifier. If, so accept that the URI is empty (and trigger
a weird) but otherwise keep processing.

Adding test cases for both HTTP requests without URI and without
version.
2016-01-15 12:59:11 -08:00
wglodek
020b09faa0 update ParseRequest to handle missing uri 2015-12-23 13:37:06 -05:00
Robin Sommer
c151a25843 Fix support for HTTP connect when server adds headers to response.
Patch by Eric Karasuda.

I slightly tweaked the patch to not need a new member variable. Also
turned the provided trace into a test case.
2015-10-23 13:10:33 -07:00
Robin Sommer
3957091e1b Renaming config.h to bro-config.h.
A couple times now I had this conflicting with files of the same name
in other projects.
2015-07-28 11:57:04 -07:00
Jon Siwek
08822e0dd4 Allow '<' and '>' in MIME multipart boundaries.
The spec doesn't actually seem to permit these, but Seth had a (private)
pcap showing them used in the wild (and the HTTP/MIME analyzer failed to
parse content as a result).
2015-05-22 11:46:50 -05:00
Robin Sommer
ed91732e09 Merge remote-tracking branch 'origin/topic/seth/more-file-type-ident-fixes'
* origin/topic/seth/more-file-type-ident-fixes:
  File API updates complete.
  Fixes for file type identification.
  API changes to file analysis mime type detection.
  Make HTTP 206 reassembly require ETags by default.
  More file type identification improvements
  Fix an issue with files having gaps before the bof_buffer is filled.
  Fix an issue with packet loss in http file reporting.
  Adding WOFF fonts to file type identification.
  Extended JSON matching and added OCSP responses.
  Another large signature update.
  More signature updates.
  Even more file type ident clean up.
  Lots of fixes for file type identification.

BIT-1368 #merged
2015-04-20 13:31:00 -07:00
Seth Hall
49926ad7bf Merge remote-tracking branch 'origin/master' into topic/seth/more-file-type-ident-fixes 2015-04-09 23:58:52 -04:00
Seth Hall
89d66af792 Fix an issue with packet loss in http file reporting.
The HTTP analyzer was propogating Gaps to the files framework even
in the case of a packet drop occurring immediately after the headers
are completed in an HTTP response when the response content length
was declared to be zero (no file started, so no loss).

Includes passing test.
2015-04-08 13:39:42 -04:00
Jon Siwek
df60015333 Remove "unmatched_HTTP_reply" weird.
BIT-725 #close
2015-03-20 11:13:50 -05:00
Jon Siwek
e60ceea87c Fix errors/warnings when compiling with -std=c++11
These are compatibility changes only.
2014-10-27 12:54:17 -05:00
Jon Siwek
02c86b2304 Merge branch 'master' into topic/jsiwek/bit-1235 2014-10-14 14:45:58 -05:00
Jon Siwek
a7373a1ca4 Remove unneeded allocations for HTTP messages. 2014-09-15 13:40:45 -05:00
Jon Siwek
af9d31dcc1 Fix incorrect data delivery skips after gap in HTTP Content-Range.
The logic for determining whether a gap was entirely within a MIME
entity body was not asking the current entity, which may be better able
to answer that question if it was using the Content-Range header and
thus knows if the gap exceeds the length of the body that's still
expected.

Addresses BIT-1247
2014-09-11 14:53:47 -05:00
Jon Siwek
1e02d5d5b5 Fix file analysis placement of data after gap in HTTP Content-Range.
Addresses BIT-1248.
2014-09-11 12:25:43 -05:00
Jon Siwek
f97f58e9db Raise http_entity_data in line with data arrival.
As opposed to delaying until a certain-sized-buffer fills, which is
problematic because then the event becomes out of sync with the "rest of
the world".  E.g. content_gap handlers being called sooner than
expected.

Addresses BIT-1240.
2014-09-10 13:20:47 -05:00
Jon Siwek
d5513a0757 Improve multipart HTTP/MIME entity file analysis.
Singular CR or LF characters in multipart body content are no longer
converted to a full CRLF (thus corrupting the file) and it also no
longer considers the CRLF before the multipart boundary as part of the
content.

Addresses BIT-1235.
2014-08-26 17:54:41 -05:00
Robin Sommer
116ed370a2 Merge remote-tracking branch 'origin/topic/jsiwek/bit-348'
* origin/topic/jsiwek/bit-348:
  Update SNMP analyzer's DeliverPacket method signature.
  Fix reassembly of data w/ sizes beyond 32-bit capacities (BIT-348).

Conflicts:
	src/analyzer/protocol/file/File.cc
	src/analyzer/protocol/file/File.h
2014-04-24 18:14:04 -07:00
Jon Siwek
d3b27eb0c1 Adapt HTTP partial content to cache file analysis IDs.
The initial file ID I think is still ambiguous and/or depends on
script-layer state tracking enough that it still needs to request a file
ID via an event at first, but once that is assigned to an HTTP (MIME)
entity, it never makes sense that it can change (so re-using a cached ID
works).
2014-04-24 10:47:57 -05:00
Jon Siwek
de8f8f87b6 Adapt more of HTTP analyzer to use cached file analysis IDs.
Some EndOfFile calls can re-use a cached file ID.
2014-04-23 16:26:18 -05:00
Jon Siwek
2b3c2bd394 Fix reassembly of data w/ sizes beyond 32-bit capacities (BIT-348).
The main change is that reassembly code (e.g. for TCP) now uses
int64/uint64 (signedness is situational) data types in place of int
types in order to support delivering data to analyzers that pass 2GB
thresholds.  There's also changes in logic that accompany the change in
data types, e.g. to fix TCP sequence space arithmetic inconsistencies.

Another significant change is in the Analyzer API: the *Packet and
*Undelivered methods now use a uint64 in place of an int for the
relative sequence space offset parameter.
2014-04-09 13:03:24 -05:00
Robin Sommer
00755f1e40 Fixing (very unlikely) double delete in HTTP analyzer when decapsulating
CONNECTs.

BIT-1149 #closed
2014-03-13 16:51:21 -07:00
Robin Sommer
338d521003 Fixing removal of support analyzers, plus some tweaking and cleanup of
CONNECT code.

Removal of support analyzers was broken. The code now actually doesn't
delete them immediately anymore but instead just flags them as
disabled. They'll be destroyed with the parent analyzer later.

Also includes a new leak tests exercising the CONNECT code.

Lines starting # with '#' will be ignored, and an empty message aborts
the commit. # On branch topic/robin/http-connect # Changes to be
committed: # modified: scripts/base/protocols/http/main.bro #
modified: scripts/base/protocols/ssl/consts.bro # modified:
src/analyzer/Analyzer.cc # modified: src/analyzer/Analyzer.h #
modified: src/analyzer/protocol/http/HTTP.cc # new file:
testing/btest/core/leaks/http-connect.bro # modified:
testing/btest/scripts/base/protocols/http/http-connect.bro # #
Untracked files: # .tags # changes.txt # conn.log # debug.log # diff #
mpls-in-vlan.patch # newfile.pcap # packet_filter.log # reporter.log #
src/PktSrc.cc.orig # weird.log #
2014-03-02 13:52:32 -08:00
Seth Hall
dd0856a57f HTTP CONNECT proxy support.
- The HTTP analyzer now supports handling HTTP CONNECT proxies
   same as the SOCKS analyzer handles proxying.
2014-02-12 22:38:59 -05:00
Robin Sommer
d4b5da1597 Merge remote-tracking branch 'origin/topic/jsiwek/http-file-id-caching'
* origin/topic/jsiwek/http-file-id-caching:
  Revert use of HTTP file ID caching for gaps range request content.
  Extend file analysis API to allow file ID caching, adapt HTTP to use it.

BIT-1125 #merged
2014-01-31 08:41:31 -08:00
Jon Siwek
2b84af5b80 Revert use of HTTP file ID caching for gaps range request content.
Just an oversight on my part, this makes the use of file ID caching
consistent between the uses of the DataIn and Gap interfaces.
2014-01-29 17:11:20 -06:00
Jon Siwek
1842d324cb Extend file analysis API to allow file ID caching, adapt HTTP to use it.
This allows an analyzer to either provide file IDs associated with some
file content or to cache a file ID that was already determined by
script-layer logic so that subsequent calls to the file analysis
interface can bypass costly detours through script-layer.  This can
yield a decent performance improvement for analyzers that are able to
take advantage of it and deal with streaming content (like HTTP).
2014-01-29 15:34:24 -06:00
Robin Sommer
8e18f9d59e Renaming InternalAnalyzerError to AnalyzerError.
This is to avoid confusion when we abort and when not: InternalError()
aborts; AnalyzerError() does not.
2013-10-11 15:14:18 -07:00
Jon Siwek
b828a6ddc7 Review usage of Reporter::InternalError, addresses BIT-1045.
Replaced some with InternalWarning or InternalAnalyzerError, the later
being a new method which signals the analyzer to not process further
input.  Some usages I just removed if they didn't make sense or clearly
couldn't happen.  Also did some minor refactors of related code while
reviewing/exploring ways to get rid of InternalError usages.

Also, for TCP content file write failures there's a new event:
"contents_file_write_failure".
2013-10-10 14:45:06 -05:00
Jon Siwek
775ec6795e Fix uninitialized (or unused) fields. 2013-09-27 10:13:52 -05:00
Robin Sommer
eb637f9f3e Merge remote-tracking branch 'origin/master' into topic/robin/plugins
Thanks to git this merge was less troublesome that I was afraid it
would be. Not all tests pass yet though (and file hashes have changed
unfortunately).

Conflicts:
	cmake
	doc/scripts/DocSourcesList.cmake
	scripts/base/init-bare.bro
	scripts/base/protocols/ftp/main.bro
	scripts/base/protocols/irc/dcc-send.bro
	scripts/test-all-policy.bro
	src/AnalyzerTags.h
	src/CMakeLists.txt
	src/analyzer/Analyzer.cc
	src/analyzer/protocol/file/File.cc
	src/analyzer/protocol/file/File.h
	src/analyzer/protocol/http/HTTP.cc
	src/analyzer/protocol/http/HTTP.h
	src/analyzer/protocol/mime/MIME.cc
	src/event.bif
	src/main.cc
	src/util-config.h.in
	testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log
	testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log
	testing/btest/Baseline/istate.events-ssl/receiver.http.log
	testing/btest/Baseline/istate.events-ssl/sender.http.log
	testing/btest/Baseline/istate.events/receiver.http.log
	testing/btest/Baseline/istate.events/sender.http.log
2013-05-16 17:58:48 -07:00
Robin Sommer
4bc2ba60c9 Rename analyzer/protocols -> analyzer/protocol 2013-04-19 15:50:57 -07:00
Renamed from src/analyzer/protocols/http/HTTP.cc (Browse further)