Commit graph

552 commits

Author SHA1 Message Date
Jon Siwek
fe044ecc90 Set PE analyzer CMake dependencies correctly 2019-04-05 12:42:29 -07:00
Jon Siwek
995368e68c Remove variable content from weird names
This changes many weird names to move non-static content from the
weird name into the "addl" field to help ensure the total number of
weird names is reasonably bounded.  Note the net_weird and flow_weird
events do not have an "addl" parameter, so information may no longer
be available in those cases -- to make it available again we'd need
to either (1) define new events that contain such a parameter, or
(2) change net_weird/flow_weird event signature (which is a breaking
change for user-code at the moment).

Also, the generic handling of binpac exceptions for analyzers which
to not otherwise catch and handle them has been changed from a Weird
to a ProtocolViolation.

Finally, a new "file_weird" event has been added for reporting
weirdness found during file analysis.
2019-04-01 18:30:11 -07:00
Johanna Amann
ffa6756255 Merge branch 'master' of https://github.com/rbclark/bro into topic/johanna/md5-fips
* 'master' of https://github.com/rbclark/bro:
  Tell OpenSSL that MD5 is not used for security in order to allow bro to work properly on a FIPS system
2019-01-18 15:34:06 -08:00
Robert Clark
a72e9a8126
Tell OpenSSL that MD5 is not used for security in order to allow bro to work properly on a FIPS system 2019-01-11 16:09:42 -05:00
Jon Siwek
2982765128 Pre-allocate and re-use Vals for bool, int, count, enum and empty string 2019-01-09 18:29:23 -06:00
Jon Siwek
fc43d06955 GH-227: Improve LibreSSL support 2019-01-07 11:35:17 -06:00
Jon Siwek
2d82fe7e2e Improve error handling in x509_ocsp_verify function 2018-11-05 17:10:21 -06:00
Jon Siwek
05b10fe2e7 BIT-1544: allow NULs in file analysis handles 2018-08-15 18:03:02 -05:00
Johanna Amann
a251b32d85 Merge remote-tracking branch 'origin/topic/jsiwek/openssl-1.1'
* origin/topic/jsiwek/openssl-1.1:
  Update install instructions for OpenSSL 1.1 compat
  Remove requestorName parameter of ocsp_request event
  Adjust x509 unit tests to work around OpenSSL 1.0 vs. 1.1 differences
  Fixes for OpenSSL 1.1 support
2018-07-31 13:13:06 +02:00
Jon Siwek
bb55f82809 Remove requestorName parameter of ocsp_request event
This field isn't publicly available via the OpenSSL 1.1 API, not used
in the base scripts, and has no example in the test suit, so removing
it is simpler than trying to support manually parsing it out of the
raw data.
2018-06-29 16:15:34 -05:00
Jon Siwek
8f990036f6 Fixes for OpenSSL 1.1 support
The following tests currently fail due to what seems like different
behavior in OpenSSL 1.1 vs 1.0:

    scripts/base/protocols/rdp/rdp-x509.bro
    bifs/x509_verify.bro
2018-06-29 15:58:53 -05:00
Johanna Amann
a891517762 Fix read at invalid address in X509 extension parser.
When encountering an extension unknown to OpenSSL, we would read from
the wrong memory location. Also added a testcase to prevent this specific
case from happening again.
2018-06-04 12:05:56 -07:00
Johanna Amann
6d612ced3d Mark one-parameter constructors as explicit & use override where possible
This commit marks (hopefully) ever one-parameter constructor as explicit.

It also uses override in (hopefully) all circumstances where a virtual
method is overridden.

There are a very few other minor changes - most of them were necessary
to get everything to compile (like one additional constructor). In one
case I changed an implicit operation to an explicit string conversion -
I think the automatically chosen conversion was much more convoluted.

This took longer than I want to admit but not as long as I feared :)
2018-03-27 07:17:32 -07:00
Xiaogrill
cbe585dd87 Treat LibreSSL as an older OpenSSL 2018-02-11 09:07:22 -08:00
Johanna Amann
a8c0580b45 Merge branch 'topic/johanna/openssl-1.1'
* topic/johanna/openssl-1.1:
  Fix recently introduced double free in OpenSSL code.
  Adjust coding style & fix test failures.
  Adapt most of the X509 support to OpenSSL 1.1
2018-01-30 14:33:32 -08:00
Jon Siwek
f25a1453ee Remove TODO comments about using explicit bool operators 2018-01-19 11:40:57 -06:00
Johanna Amann
41285abea5 Make nearly all bool operators explicit.
These are a bit dangerous because the casting can happen in quite
unexpected circumstances and lead to undesirable comparison results.
2018-01-18 14:02:03 -08:00
Johanna Amann
bdb7f62335 Correct include-path in x509Common.h
The file used a relative path which leads to problems if it is included
by an external Plugin. This commit changes this to an absolute path,
like everywhere else.
2018-01-12 10:58:20 -08:00
Johanna Amann
cc738544eb Merge remote-tracking branch 'remotes/origin/topic/jsiwek/prealloc-ports'
* remotes/origin/topic/jsiwek/prealloc-ports:
  Clean up PortManager class, mark PortVal ctors deprecated.
  Add BRO_DEPRECATED macro.
  Preallocate all possible PortVals.

BIT-1881 #merged
2018-01-12 10:06:30 -08:00
Johanna Amann
762e3c9f12 Merge remote-tracking branch 'origin/topic/seth/add-file-lookup-functions'
* origin/topic/seth/add-file-lookup-functions:
  Functions for retrieving files by their id.

 BIT-1887 #merged
2018-01-12 09:46:24 -08:00
Seth Hall
7cb6cf24a6 Functions for retrieving files by their id.
There are two new script level functions to query and lookup files
from the core by their IDs.  These are adding feature parity for
similarly named functions for files.  The function prototypes are
as follows:

  Files::file_exists(fuid: string): bool
  Files::lookup_File(fuid: string): fa_file
2018-01-09 12:16:17 -05:00
Jon Siwek
1e4964de77 Preallocate all possible PortVals.
The performance benefit is small (maybe ~1% at most), however, it's a
trivial change without downsides.
2017-12-11 15:29:28 -06:00
Johanna Amann
03f98c7022 Fix recently introduced double free in OpenSSL code. 2017-12-07 14:47:56 -08:00
Johanna Amann
6a93abea32 Adjust coding style & fix test failures.
I am still not 100% convinced that there is no memory leak hidden
somwehere...

This also makes everything compile with OpenSSL 1.0.2 for me.
2017-12-07 14:02:27 -08:00
Hilko Bengen
ea4cf7dbe9 Adapt most of the X509 support to OpenSSL 1.1 2017-12-06 00:07:49 +01:00
Johanna Amann
fc33bf2014 Make strerror_r portable.
This uses the same code that broker already uses to determine if we use
the XSI or gnu version of strerror_r. Patch by Thomas Petersen.
2017-09-18 14:50:30 -07:00
Johanna Amann
e1997144c2 Fix small OCSP parser bug.
It turns out that the serial number field in all events was never
populated correctly. Instead, the previous field (issuer key hash) was
re-read and repeated in all events.
2017-09-11 09:26:33 -07:00
Robin Sommer
0b5894ce23 Merge remote-tracking branch 'origin/topic/johanna/ocsp-sct-validate'
* origin/topic/johanna/ocsp-sct-validate:
  SSL SCT/OCSP: small fixes by robin; mostly update comments.
2017-08-04 13:28:08 -07:00
Johanna Amann
d5678418da SSL SCT/OCSP: small fixes by robin; mostly update comments.
SetMime now only works on the first call (as it was documented) and
unused code was used from one of the x.509 functions.
2017-08-01 16:30:08 -07:00
Robin Sommer
faa4150154 Merge remote-tracking branch 'origin/topic/johanna/ocsp-sct-validate'
Closes #1830.

* origin/topic/johanna/ocsp-sct-validate: (82 commits)
  Tiny script changes for SSL.
  Update CT Log list
  SSL: Update OCSP/SCT scripts and documentation.
  Revert "add parameter 'status_type' to event ssl_stapled_ocsp"
  Revert "parse multiple OCSP stapling responses"
  SCT: Fix script error when mime type of file unknown.
  SCT: another memory leak in SCT parsing.
  SCT validation: fix small memory leak (public keys were not freed)
  Change end-of-connection handling for validation
  OCSP/TLS/SCT: Fix a number of test failures.
  SCT Validate: make caching a bit less aggressive.
  SSL: Fix type of ssl validation result
  TLS-SCT: compile on old versions of OpenSSL (1.0.1...)
  SCT: Add caching support for validation
  SCT: Add signed certificate timestamp validation script.
  SCT: Allow verification of SCTs in Certs.
  SCT: only compare correct OID/NID for Cert/OCSP.
  SCT: add validation of proofs for extensions and OCSP.
  SCT: pass timestamp as uint64 instead of time
  Add CT log information to Bro
  ...
2017-07-30 08:49:41 -07:00
Johanna Amann
9594f69598 SSL: Update OCSP/SCT scripts and documentation. 2017-07-27 16:22:40 -07:00
Johanna Amann
7a1ec3501d SCT: another memory leak in SCT parsing. 2017-05-14 19:38:36 -07:00
Johanna Amann
e1d42ec99c SCT validation: fix small memory leak (public keys were not freed) 2017-05-14 09:55:17 -07:00
Johanna Amann
b8e81029f8 TLS-SCT: compile on old versions of OpenSSL (1.0.1...) 2017-03-29 09:17:30 -07:00
Johanna Amann
115a676d08 SCT: Allow verification of SCTs in Certs.
This is much more complex than the TLS Extension/OCSP cases. We need to
first alter the certificate and remove the extension from it, before
extracting the tbscert. Furthermore, we need the key hash of the issuing
certificate to be able to validate the proof - which means that we need
a valid certificate chain.

Missing: documentation, nice integration so that we can just add a
script and use this in Bro.
2017-03-29 09:17:24 -07:00
Johanna Amann
41a2028dee SCT: only compare correct OID/NID for Cert/OCSP.
The old way of doing it did not really cause problems - but now only the
OID that can be used in practice is checked.
2017-03-29 09:04:11 -07:00
Johanna Amann
c403a7f4e6 SCT: add validation of proofs for extensions and OCSP.
This does not yet work for certificates, because this requires some
changing the ASN.1 structure before validation (we need to extract the
tbscert and remove the SCT extension before).

API will change in the future.
2017-03-29 09:04:05 -07:00
Johanna Amann
d50bddfbfb SCT: pass timestamp as uint64 instead of time
For verification, we need the exact uint64 as it was seen on the wire;
converting it to a double might mean that we loose precision.
2017-03-16 18:18:39 -07:00
Johanna Amann
5604f46dd3 OCSP SCT: use correct oid for old openssls 2017-02-15 17:38:56 -08:00
Johanna Amann
c550521221 OCSP: parse signed certificate timestamps
With this change, we also parse signed certificate timestamps from OCSP
replies. This introduces a common base class between the OCSP and X509
analyzer, which now share a bit of common code. The event for signed
certificate timestamps is raised by both and thus renamed do:

x509_ocsp_ext_signed_certificate_timestamp
2017-02-10 17:05:05 -08:00
Johanna Amann
b061a5db1a Merge branch 'topic/johanna/signed_certificate_timestamp' into topic/johanna/ocsp-new 2017-02-10 17:04:50 -08:00
Johanna Amann
cdcc21ea4b OCSP: generic extension parsing.
Raises ocsp_extension event if an extension is present in the reply or
in one of the singlereplies.
2017-02-10 17:03:50 -08:00
Johanna Amann
9fd7816501 Allow File analyzers to direcly pass mime type.
This makes it much easier for protocols where the mime type is known in
advance like, for example, TLS. We now do no longer have to perform deep
script-level magic.
2017-02-10 17:03:33 -08:00
Johanna Amann
1b19ab78b6 OCSP: split into two analysers in scriptland.
Instead of having an additional string argument specifying if we are
sending a request or a reply, we now have an ANALYZER_OCSP_REQUEST and
an ANALYZER_OCSP_REPLY
2017-02-10 17:03:27 -08:00
Johanna Amann
e1bcc4509f OCSP: rewrite events and data structures.
Instead of having a big event, that tries to parse all the data into a
huge datastructure, we do the more common thing and use a series of
smaller events to parse requests and responses.

The new events are:

ocsp_request -> raised for an ocsp request, giving version and requestor

ocsp_request_certificate -> raised n times per request, once per cert

ocsp_response_status -> raised for each ocsp response, giving status

ocsp_response_bytes -> raised for each ocsp response with information

ocsp_response_certificate -> raised for each cert in an ocsp response
2017-02-10 17:03:18 -08:00
Johanna Amann
9c6cebf324 OCSP: a bunch of whitespace fixes 2017-02-10 17:03:04 -08:00
Johanna Amann
b021fe7562 Rewrite of big parts of the OCSP analyzer.
Less redundancy, style closer to the X.509 analyzer, times being parsed
as real times, and lots of other changes.
2017-02-10 17:02:56 -08:00
Johanna Amann
c670613996 Make OCSP analyzer part of the X.509 analyzer
This allows the easier integration of shared functionality. And it also
makes logical sense, given that OCSP is not interesting without X.509.
2017-02-10 17:02:15 -08:00
Johanna Amann
dfc871f831 Merge remote-tracking branch 'origin/master' into topic/johanna/ocsp 2017-02-08 10:35:12 -08:00
Johanna Amann
2d64b45394 X509: make SCT parsing work with older OpenSSL versions 2017-02-07 16:05:47 -08:00