Commit graph

476 commits

Author SHA1 Message Date
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
Johanna Amann
5dd19f84a7 Add parsing of signed certificate timestamps out of X.509 certs.
This is a tiny bit evil because it uses parts of the SSL protocol
analyzer in the X.509 certificate parser. Which is the fault of the
protocol, which replicates the functionality.
2017-02-07 13:31:21 -08:00
Johanna Amann
1de6cfc2e3 Fix memory leak in file analyzer.
This undoes the changes applied in merge 9db27a6d60
and goes back to the state in the branch as of the merge 5ab3b86.

Getting rid of the additional layer of removing analyzers and just
keeping them in the set introduced subtle differences in behavior since
a few calls were still passed along. Skipping all of these with SetSkip
introduced yet other subtle behavioral differences.
2017-02-04 16:47:07 -08:00
Johanna Amann
9db27a6d60 Merge remote-tracking branch 'origin/topic/robin/file-analysis-fixes'
* origin/topic/robin/file-analysis-fixes:
  Adding test with command line that used to trigger a crash.
  Cleaning up a couple of comments.
  Fix delay in disabling file analyzers.
  Fix file analyzer memory management.

The merge changes around functionality a bit again - instead of having
a list of done analyzers, analyzers are simply set to skipping when they
are removed, and cleaned up later on destruction of the AnalyzerSet.

BIT-1782 #merged
2017-02-01 14:20:14 -08:00
Robin Sommer
16f20507fd Cleaning up a couple of comments. 2017-01-31 14:45:06 -08:00
Robin Sommer
fead5f5d5e Fix delay in disabling file analyzers.
When a file analyzer signaled being done with data delivery, the
analyzer would only be scheduled for removal at that poing, meaning it
could still receive more data until that action actually took effect.
Now we make sure to not send any more data to an analyzer.
2017-01-28 13:24:13 -08:00
Robin Sommer
3ce6a031d4 Fix file analyzer memory management.
File analyzers got deleted immediately once the queue with the
corresponding removal operation got drained. That however can happen
while the analyzer is still doing stuff: the queue is drained whenever
any the "special" file analysis events needing immediate attention has
been executed. This fix now only schedules the analyzer for deletion
at that time, but postpones the actual operation until file object
itself is being destroyed.
2017-01-28 13:07:51 -08:00
Johanna Amann
37a51b354e Fix validation of OCSP replies inside of Bro.
At one place in the code, we do not check the correct return code. This
makes it possible for a reply to get a response of "good", when the ocsp
reply is not actually signed by the responder in question.

This also instructs ocsp verication to skip certificate chain
validation, which we do ourselves earlier because the OCSP verify
function cannot do it correctly (no way to pass timestamp).
2016-11-30 13:17:09 -08:00
Seth Hall
2cfe2c292d Fix an event from the file extraction analyzer.
The "file_extraction_limit" event was passing a Files::AnalyzerArgs
record as an "any" type.  This is not right at the least and may
have been causing a crash for a user at worst.
2016-08-28 21:30:42 -04:00
Johanna Amann
c464cf78dd Fix a number of format errors when using debug macros. 2016-08-12 15:42:02 -07:00
Johanna Amann
65d977f278 Make tags generated during component initialization stable.
The order in which the plugin initializers are executed is compiler
dependent. With this change, Tags will always be generated in
alphabetical ordering, not in compiler-dependent order.
2016-08-11 19:48:53 -07:00
Johanna Amann
2756dfe581 Make x509 intel seen script robust against file analyzer ordering.
Now it consistently works, even if the SHA1 file analyzer gets the data
before the X509 file analyzer.
2016-08-11 16:12:08 -07:00
Robin Sommer
d7c10ca7c3 Removing OpenSSL dependency for plugins.
Compiling a plugin required having access to OpenSSL headers because
they were pulled in by Bro headers that the plugin had to include.
Removinng then OpenSSL dependency from those Bro headers.

I'm also reverting a4e5591e. This is a different fix for the same
problem, and reverting that commit gives us a test case. :-)
2016-08-01 12:32:27 -07:00
Robin Sommer
50945a6359 Fixing a few Coverity warnings. 2016-05-23 08:25:11 -07:00
Seth Hall
d9d579c52c Merge remote-tracking branch 'origin/master' into topic/seth/stats-improvement 2016-05-02 14:34:29 -04:00
Johanna Amann
e9a87566ef Fix parsing of x509 pre-y2k dates
There was a bug in the new parsing code, introduced in
708ede22c6 which parses validity times
incorrectly if they are before the year 2000. What happens in this case
is that the 2-digit year will be interpreted to be in the 21st century
(1999 will be parsed as 2099, e.g.).
2016-04-26 12:30:28 -07:00
Seth Hall
89b4d79f93 Merge remote-tracking branch 'origin/master' into topic/seth/file-entropy
# Conflicts:
#	scripts/test-all-policy.bro
#	testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log
2016-03-21 11:39:15 -04:00
Seth Hall
a58c308427 Adding override/final to overridden virtual methods.
C++11 compilers complain about overridden virtual methods
not being specified as either final or overridden.
2016-01-16 23:35:31 -05:00
Seth Hall
6d836b7956 More stats improvements
Broke out the stats collection into a bunch of new Bifs
in stats.bif.  Scripts that use stats collection functions
have also been updated.  More work to do.
2016-01-07 16:20:24 -05:00
Seth Hall
2b0a28686a Cleaned up stats collection.
- Removed the gap_report event.  It wasn't used anymore
   and functionally no more capable that scheduling events
   and using the get_gap_summary bif.

 - Added functionality to Dictionaries to count cumulative
   numbers of inserts performed.  This is further used to
   measure the total number of connections of various types.
   Previously only the number of active connections was
   available.

 - The Reassembler base class now tracks active reassembly
   size for all subclasses (File/TCP/Frag & unknown).

 - Improvements to the stats.log.  Mostly, more information.
2016-01-04 00:55:52 -05:00
Johanna Amann
da9b5425e4 Merge remote-tracking branch 'origin/master' into topic/johanna/ocsp 2015-12-14 16:05:41 -08:00
Johanna Amann
5785530c6b Make x509 end-of-string-check nicer.
Use remaining instead of the total length, in case someone changes the
code later and changes pString before.
2015-09-18 12:55:55 -07:00
Johanna Amann
708ede22c6 Refactor X509 generalizedtime support and test.
The generalizedtime support in for certificates now fits more
seamlessly to how the rest of the code was structured and does the
different processing for UTC and generalized times at the beginning,
when checking for them.

The test does not output the common name anymore, since the output
format might change accross openssl versions (inserted the serial
instead).

I also added a bit more error checking for the UTC time case.
2015-09-18 12:46:49 -07:00
Yun Zheng Hu
2327f5bba5 Fixed parsing of V_ASN1_GENERALIZEDTIME timestamps in x509 certificates 2015-09-10 10:50:35 +02:00
Robin Sommer
07210faa3d Merge remote-tracking branch 'origin/topic/johanna/BIT-1465'
I did a bit more cleanup in GetTimeFromAsn1().

BIT-1465 #merged

* origin/topic/johanna/BIT-1465:
  Make asn.1 date/time parsing more robust.
2015-08-29 10:51:55 -07:00
Johanna Amann
d054158713 Make asn.1 date/time parsing more robust.
These changes should be safe -- testing the failure cases proves a bit
difficult at the moment due to the fact that OpenSSL seems to fix the
values that are present in the original ASN.1 before passing them on to
us. It is thus not directly easily possible to trigger the error cases
from scriptland.

This also means that a lot of the new error cases we try to catch here
can probably never happen.
2015-08-27 21:44:37 -07:00
Liang Zhu
1989f34a0a add parsing certificates in OCSP responses 2015-08-18 19:35:43 -07:00