elastic / beats

:tropical_fish: Beats - Lightweight shippers for Elasticsearch & Logstash
https://www.elastic.co/products/beats
Other
12.11k stars 4.91k forks source link

[Auditbeat] System module: Uniquely identify processes, sockets, users, and packages #10463

Closed cwurm closed 5 years ago

cwurm commented 5 years ago

While putting together dashboards for the Auditbeat system module I realized that with the current data model it's not possible to visualize the number of processes, sockets, users, and packages since there is no way to identify a unique entity.

For example, each process can and often will have multiple events of different types (when it starts, when it ends, and when it's reported by a regular state update). There's no one identifying field at the moment to count them properly: process names, executables, args, pid, ppid are all not unique. The same for sockets, users, and packages. Only the host dataset has a host.id field already that should be unique.

I'm proposing to introduce new fields that identify those entities.

As a field name, I'm still torn between:

As for the value, I'm thinking a hash of some of the fields of the entity and the host.id:

elasticmachine commented 5 years ago

Pinging @elastic/secops

tsg commented 5 years ago

@webmat @MikePaquette Is there any ECS field that would fit this purpose?

I think hash might also potentially conflict, for example, with file.hash if we ever add something like that.

tsg commented 5 years ago

I see now that user.hash exists in ECS:

Unique user hash to correlate information for a user in anonymized form. Useful if user.id or user.name contain confidential information and cannot be used.

Sort of matches, but not quite..

tsg commented 5 years ago

How about unique_id? So you'd have process.unique_id that makes it clear how it is different from process.id.

andrewkroh commented 5 years ago

I was literally thinking to use entity.id, but some events will have multiple entities. So along the same lines as @tsg's suggestion, how about process.entity_id or generally {thing}.entity_id?

BTW in Metricbeat's windows-service metricset we do this to create a service.id for the dashboards. It's a sha256(MachineGUID + ServiceName)[:10].

FrankHassanabad commented 5 years ago

I think this is uniquely identifying a process by each instance it is created, right?

Process: pid + start + host.id

Since you're using process id and start. So for example, if I run wget repeatedly on a box it will show up with different identities representing each individual process.

cwurm commented 5 years ago

@FrankHassanabad yes, that's the idea

cwurm commented 5 years ago

I don't have a strong preference on the field name. entity_id sounds good to me since that's exactly what is.

Another question is what hashing algorithm we should use. Internally, the Auditbeat system module uses xxhash for change detection (e.g. to detect if a running process has already existed the last time around). However, since this use is more exposed (the value will be stored in Elasticsearch, together with other data that could be from third parties) maybe there's a case to be made for something more "standard", e.g. SHA-1 or SHA-256? SHA comes out of the box for pretty much every programming language, it's FIPS compliant, it's what other tools in the wider ecosystem accept (e.g. it's one of the file hashes Virus Total accepts), and SHA-1 is the default for the file hash in Auditbeat's file_integrity module. Here as well, I don't have a strong opinion. Curious what others think.

tsg commented 5 years ago

+1 on entity_id.

I don't have a preference for the hash algorithm either. I agree the SHA1 will likely make troubleshooting easier. Is speed the argument for xxhash?

webmat commented 5 years ago

I like where this discussion is going. ECS would not define what the content of this field would be, as it can be implementation-specific.

For the naming of the field, I actually quite like entity_id. I think it makes it clear that this is a persistent identity, and doesn't give the incorrect impression that every event should have a distinct/unique value in the field. My vote is for entity_id. This field should be keyword.

I'll add this to the mountain of things to address officially in ECS soon ;-)

webmat commented 5 years ago

ping @ruflin new pattern emerging ^

cwurm commented 5 years ago

I don't have a preference for the hash algorithm either. I agree the SHA1 will likely make troubleshooting easier. Is speed the argument for xxhash?

I think so.

cwurm commented 5 years ago

Ok, so how about we use entity_id and SHA-256? Git is moving to it as well.