Skip to content

tls_inspector: create JA3 client fingerprint - #18853

Merged
ggreenway merged 38 commits into
envoyproxy:mainfrom
jasonmillerstackpath:16622-JA3-client-fingerprint
Nov 16, 2021
Merged

ggreenway merged 38 commits into
envoyproxy:mainfrom
jasonmillerstackpath:16622-JA3-client-fingerprint

Conversation

@jasonmillerstackpath

Copy link
Copy Markdown
Contributor

Commit Message: Extend TLS inspector to capture JA3 client fingerprint. Co-authored-by: Ryland Degnan [email protected]
Additional Description: See #16622. JA3 fingerprint information is available at https://github.com/salesforce/ja3 and at https://ja3er.com. Based off of closed PR #16628.
Risk Level: low
Testing: unit tests
Docs Changes: Documented in proto
Release Notes:
Platform Specific Features:
Fixes #16622

@repokitteh-read-only

Copy link
Copy Markdown

Hi @jasonmillerstackpath, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #18853 was opened by jasonmillerstackpath.

see: more, trace.

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #18853 was opened by jasonmillerstackpath.

see: more, trace.

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/wait

Comment thread envoy/network/connection.h Outdated
/**
* @return ja3 fingerprint hash of the downstream connection, if any.
*/
virtual absl::string_view ja3Hash() const PURE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be moved to ConnectionInfoProvider, which can be accessed from the Connection. Then you won't need a change in the http-connection-manager.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ConnectionInfoProvider in commit 97f3f94.

"envoy.config.filter.listener.tls_inspector.v2.TlsInspector";

// Populate JA3 fingerprint hash using data from the TLS Client Hello packet.
bool enable_tls_ja3_fingerprinting = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_tls is probably redundant in this name; it's already inside TlsInspector.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to enable_ja3_fingerprinting in commit 97f3f94.

}
return absl::nullopt;
});
} else if (field_name == "JA3_TLS_FINGERPRINT_HASH") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I slightly prefer TLS_JA3_FINGERPRINT

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to TLS_JA3_FINGERPRINT in commit 97f3f94.

@ggreenway ggreenway self-assigned this Nov 1, 2021

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please also add an integration test that accepts a TLS connection and verifies that the ja3 hash is correct in the access log; that'll verify the full end-to-end feature.

I'm pretty sure you're missing a step to propagate the new value from the ListenSocket to the ConnectionInfoProvider.

/wait

@@ -1,5 +1,6 @@
#include "source/common/quic/envoy_quic_client_session.h"

#include "source/common/common/empty_string.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

revert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted in commit 34ba6e2.

#include <memory>

#include "source/common/common/assert.h"
#include "source/common/common/empty_string.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

revert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted in commit 34ba6e2.

Comment thread envoy/stream_info/stream_info.h Outdated
/**
* @return Connection ja3 fingerprint hash of the downstream connection, if any.
*/
virtual const std::string& ja3Hash() const PURE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the changes to this interface can be reverted; you can already access this via (improperly named due to a rename at some point) virtual const Network::ConnectionInfoProvider& downstreamAddressProvider() const PURE;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted in commit 34ba6e2.

@repokitteh-read-only

Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #18853 (comment) was created by @jasonmillerstackpath.

see: more, trace.

"envoy.config.filter.listener.tls_inspector.v2.TlsInspector";

// Populate `JA3` fingerprint hash using data from the TLS Client Hello packet.
bool enable_ja3_fingerprinting = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible that we'd want the default value of this to change in the future? If so, please use google.protobuf.BoolValue instead of bool.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, it's plausible that we may want to start using this for something internal, and that it would make sense to flip the default, so +1 on BoolValue type.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/wait

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/wait

enable_ja3_fingerprinting_(proto_config.enable_ja3_fingerprinting()),
max_client_hello_size_(max_client_hello_size) {

if (proto_config.has_enable_ja3_fingerprinting()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a helper macro for this pattern. Put back in the initializer list as enable_ja3_fingerprinting_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(proto_config, proto_config.enable_ja3_fingerprinting, false)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to use macro in commit 4315458

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@ggreenway

Copy link
Copy Markdown
Member

@markdroth can you give a final pass on the API?

@markdroth

Copy link
Copy Markdown
Contributor

/lgtm api

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, one least detail: please add a release note for this feature addition

@ggreenway

Copy link
Copy Markdown
Member

Merge conflict. Please merge main to resolve.

/wait

Extend TLS inspector to capture JA3 client fingerprint envoyproxy#16622

Co-authored-by: Ryland Degnan <[email protected]>
Signed-off-by: Jason Miller <[email protected]>
@ggreenway
ggreenway enabled auto-merge (squash) November 16, 2021 16:53
@ggreenway
ggreenway merged commit a305c74 into envoyproxy:main Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend TLS inspector to capture JA3 client fingerprint

4 participants