Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: TLS related fields #6

Merged
merged 4 commits into from
Jun 18, 2018
Merged

Conversation

ph
Copy link
Contributor

@ph ph commented May 29, 2018

While working on the TCP inputs for beats I am able to extract information about the TLS envelope,
this might be useful information for post-mortems or audit. Also, this was a feature requested on
the beats input on the Logstash side.

We are also extracting some information in packetbeat from the work of @adriansr.

Concerning the TCP or the beats input, I think we can extract the following field and provide some
useful information.

  • TLS version
  • Remote Certificates (mutual auth)
  • ServerName
  • Cipher used.

Where OR should this information be in the ECS schema? Maybe we could add a transport top level
key and have something like this.

Field Description Type Example
tls.version string representation of the tls version keyword TLSv1.1
tls.certificates array of certificates used by the client. text raw certificate
tls.servername server name requested by client keyword localhost1
tls.ciphersuite Name of the cipher used keyword ECDHE-ECDSA-AES-128-CBC-SHA

@ph
Copy link
Contributor Author

ph commented May 29, 2018

@ruflin Good job, the tooling for this repository works great. 🎉

@ruflin ruflin added the review label May 30, 2018
@ruflin ruflin requested review from andrewkroh and adriansr May 30, 2018 08:34
schemas/tls.yml Outdated
- name: certificates
type: text
description: >
An array of certificates.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the format of this field? If one were to use base64-encoded certificates, a keyword field would make more sense than text.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right for the keyword, I’ll update the PR.

@ph
Copy link
Contributor Author

ph commented May 31, 2018

@ruflin to move the certificate type from a text field to a keyword I will need to make a small change on the template generator, we have the ignore_above value hardcoded, I think we should allow users to override that from the schema definition. I need to do some checks on the openssl documentation but it can be over 1024.

I don't expect any problems since the ES default is much higher.

Do not index any string longer than this value. Defaults to 2147483647 so that all values would be accepted. 

@ruflin
Copy link
Contributor

ruflin commented Jun 1, 2018

@ph We should add support for ignore_above config in field.go: https://github.com/elastic/beats/blob/master/libbeat/common/field.go#L36

ruflin pushed a commit to elastic/beats that referenced this pull request Jun 6, 2018
)

By default all fields of the type keyword were limitted to 1024
characters, this PR keep the default but allow developers to redefine that limit using the
`ignore_above` directive in the field.yml.

Ref: elastic/ecs#6
@ph ph force-pushed the proposal/tls-fields branch from d9d2d47 to c2d1218 Compare June 11, 2018 16:56
@ph
Copy link
Contributor Author

ph commented Jun 11, 2018

@ruflin The required support for ignore_above was merged into master, I've rebased and regenerated the files in this PR. I've gone with a 4096 upper bound limit on the base64 certificate; I think it should cover the maximum size, look at the commit message for more details.

@praseodym
Copy link
Contributor

Is there a reason to specify a value for ignore_above? Current documentation doesn't list any advantages.

It is very common for certificates to be >4096 bytes, e.g. check out this certificate for elastic.co at 4885 bytes or this certificate for microsoft.com at 5697 bytes. There is no set limit on a certificate's size; e.g. the number of subject alternative names is unbounded.

@ph
Copy link
Contributor Author

ph commented Jun 11, 2018

Right, thanks for enlightening me, I am OK to remove it relies on ES keyword default which will be in this case 2147483647, I will need to make changes on the template generator on libbeat, since there is no way to opt out of it.

@ruflin what you think if we make it an explicit choice, so users have to use -1 in the fields.yaml?

@ph
Copy link
Contributor Author

ph commented Jun 11, 2018

@ruflin Also, defining this kind of size limits should be in another document we generated like the CSV, I don't think this information should only be kept in the template. This could be part of a new discussion or issue.

@ruflin
Copy link
Contributor

ruflin commented Jun 12, 2018

We started to set for some fields index: false and doc_values: false (see https://github.com/elastic/ecs/blob/master/schemas/event.yml#L73) I wonder if this also applies to certificate as it will not be a field that anyone queries on I would assume?

@ph +1 on having the option in the generator to disable it. For the discussion on where these things should show up, let's move it to an other Github issue as proposed.

@ph
Copy link
Contributor Author

ph commented Jun 12, 2018

@ruflin I think it would make sense in that context to set doc_values to false, we won't sort or aggregate on that field. So that would be a space saver.

@ruflin ruflin mentioned this pull request Jun 12, 2018
@ruflin
Copy link
Contributor

ruflin commented Jun 12, 2018

I would also set index:false. Like this the keyword length becomes irrelevant.

@ph
Copy link
Contributor Author

ph commented Jun 12, 2018

Setting index: false will make it not queryable, in the context of certificates, querying it can be useful when doing forensic, no? What is your reasoning for not indexing it?

@ph
Copy link
Contributor Author

ph commented Jun 12, 2018

Created #23 for exposing keyword limit.

@ruflin
Copy link
Contributor

ruflin commented Jun 13, 2018

My assumption was that there is not going to be a query on the certificate field but as you mentioned above, there are potential queries. So index should be set to true.

ph added 2 commits June 13, 2018 10:03
While working on the TCP inputs for beats I am able to extract information about the TLS envelope,
this might be useful information for post-mortems or audit. Also, this was a feature requested on
the beats input on the Logstash side.

We are also extracting some information in [packetbeat](https://github.com/elastic/beats/blob/master/packetbeat/protos/tls/_meta/fields.yml) from the work of @adriansr.

Concerning the TCP or the beats input, I think we can extract the following field and provide some
useful information.

- TLS version
- Remote Certificates (mutual auth)
- ServerName
- Cipher used.

Where OR should this information be in the ECS schema? Maybe we could add a `transport` top level
key and have something like this.

| Field  | Description  | Type  | Example  |
|---|---|---|---|
tls.version| string representation of the tls version| keyword|	TLSv1.1 |
tls.certificates| array of certificates used by the client.|text| raw certificate|
tls.servername| server name requested by client|keyword| localhost[1]
tls.ciphersuite| Name of the cipher used| keyword|  ECDHE-ECDSA-AES-128-CBC-SHA

[1]:https://en.wikipedia.org/wiki/Server_Name_Indication
@ph ph force-pushed the proposal/tls-fields branch from c2d1218 to 22d8d4a Compare June 13, 2018 14:04
@ph
Copy link
Contributor Author

ph commented Jun 13, 2018

@ruflin updated the PR with the latest review.

README.md Outdated
@@ -358,6 +359,21 @@ Source fields describe details about the source of the event.
| <a name="source.subdomain"></a>`source.subdomain` | Source subdomain. | keyword | | |


## <a name="tls"></a> TLS fields

The tls fields contains the TLS related data about a specific connection.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/contains/contain/

schemas/tls.yml Outdated
- name: version
type: keyword
description: >
TLS version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a . at the end?

@ruflin ruflin requested a review from karenzone June 14, 2018 12:08
README.md Outdated

The tls fields contains the TLS related data about a specific connection.

As an example in the case of Filebeat and the TCP input, the `version` field would be the version of the TLS protocol in use, the `certificates` would be the chain of certificates provided by the client and the `ciphersuite` is the encryption algorithm used for the communication.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider tagging as footnote: >to push this example to after the table

@ruflin
Copy link
Contributor

ruflin commented Jun 15, 2018

@ph I think you need to run make again.

@ph
Copy link
Contributor Author

ph commented Jun 15, 2018

@ruflin @karenzone added footnote and run make again, I didn't know about footnote.

@ruflin ruflin merged commit 50c160c into elastic:master Jun 18, 2018
@ruflin
Copy link
Contributor

ruflin commented Jun 18, 2018

@ph footnote is something we just introduced a few days ago.

@ph ph deleted the proposal/tls-fields branch June 18, 2018 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants