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

Enrich network traffic metadata via NetBox lookups #132

Closed
mmguero opened this issue Dec 7, 2022 · 9 comments
Closed

Enrich network traffic metadata via NetBox lookups #132

mmguero opened this issue Dec 7, 2022 · 9 comments
Assignees
Labels
enhancement New feature or request netbox Related to Malcolm's use of NetBox

Comments

@mmguero
Copy link
Collaborator

mmguero commented Dec 7, 2022

Feature-tracking issue dependent on #131

@mmguero mmguero added enhancement New feature or request netbox Related to Malcolm's use of NetBox labels Dec 7, 2022
@mmguero mmguero added this to Malcolm Dec 7, 2022
@mmguero mmguero moved this to Todo (design) in Malcolm Dec 7, 2022
@mmguero
Copy link
Collaborator Author

mmguero commented Dec 8, 2022

existing behavior

Up until now network traffic metadata has been enriched using the Automatic host and subnet name assignment feature, in which network hosts are identified by IP address or MAC address, and subnets are identified by CIDR subnet. This is done via config files (originally a delimited file, later JSON) and can be managed with a web interface.

The way this is handled today is that the net-map.json file is read on logstash startup and a Logstash filter file is created so that it becomes part of the pipeline.

As logs are processed by logstash, the fields source.hostname and destination.hostname are populated, respectively, for matching source.ip, destination.ip, source.mac, and destination.mac fields. source.ip and destination.ip are also checked in subnet definitions, and matches are written into source.segment and destination.segment fields. These are not mutually exclusive: these fields can contain multiple values. See the link to the documentation in the first paragraph of this

proposed new behavior

This feature can be replaced with NetBox, although for now we will leave both in place, if someone wants to do the enrichment without the full complexity netbox provides. (in fact, even now (as of v6.4.3) if netbox is enabled and net-map.json exists, it will be automatically recreated in netbox).

I'll be using some examples on the netbox demo as I investigate the mappings we'll want to use for these lookups.

field changes and mapping

This describes which fields from the NetBox model will be enriched into which fields in the Malcolm opensearch indices.

For storage considerations, currently I've chosen to do NetBox enrichment for all Suricata logs and only Zeek conn, notice, weird, signatures and known_* logs. UID values can be used to pivot from another kind of zeek logs back to the conn.log to see the enriched values, and communityID can be used to pivot to Arkime sessions as usual. I'm not currently doing this enrichment for Arkime sessions (but I will probably figure out how to do so using WISE in a future release).

  • See the NetBox API documentation and the NetBox documentation. In this list I'll reference the corresponding NetBox model API for the given fields:
    • destination.hostname
    • source.hostname
    • destination.device.cluster (/virtualization/clusters/) (for Virtual Machine device types)
    • destination.device.device_type (/dcim/device-types/)
    • destination.device.id (/dcim/devices/{id})
    • destination.device.manufacturer (/dcim/manufacturers/)
    • destination.device.name (/dcim/devices/)
    • destination.device.role (/dcim/device-roles/)
    • destination.device.service (/ipam/services/)
    • destination.device.site (/dcim/sites/)
    • destination.device.url (/dcim/devices/)
    • destination.device.details (full JSON object, only with LOGSTASH_NETBOX_ENRICHMENT_VERBOSE: 'true')
    • destination.segment.id (/ipam/vrfs/{id})
    • destination.segment.name (/ipam/vrfs/)
    • destination.segment.site (/dcim/sites/)
    • destination.segment.tenant (/tenancy/tenants/)
    • destination.segment.url (/ipam/vrfs/)
    • destination.segment.details (full JSON object, only with LOGSTASH_NETBOX_ENRICHMENT_VERBOSE: 'true')
    • source.… same as destination.…
    • collected as "related" fields (the same approach used in ECS)
      • related.device_type
      • related.manufacturer
      • related.role
      • related.segment
      • related.service
      • related.site

For Malcolm's purposes, both physical devices and virtualized hosts will be stored as described above: the device_type field can be used to distinguish.

IP address to device mapping

IP addresses are under the IPAM model (demo).

Each device (demo) must be assigned a site, device role, and operational status, and may optionally be assigned to a specific location and/or rack within a site. A platform, serial number, and asset tag may optionally be assigned to each device. Device names must be unique within a site, unless the device has been assigned to a tenant. Devices may also be unnamed. When a device has one or more interfaces with IP addresses assigned, a primary IP for the device can be designated, for both IPv4 and IPv6.

Devices can be assigned IP addresses, even multiple IP addresses: When a device has one or more interfaces with IP addresses assigned, a primary IP for the device can be designated, for both IPv4 and IPv6.

In order to look up a device by IP address, you do it like ip -> interface -> device.

IP address to network segment mapping

IP subnets are described in "prefixes" (demo). The documentation states that: ... each prefix can be assigned to a particular site and virtual routing and forwarding instance (VRF). Each VRF represents a separate IP space or routing table. All prefixes not assigned to a VRF are considered to be in the "global" table.

In other words, for our purposes an IP address prefix will get its "name" from the VRF to which it belongs.

MAC address to host name mapping

After quite a bit of experimentation, I've determined that doing MAC address to device mapping isn't reliable enough to be useful (due to the issue of the MAC address shown for a packet is simply the MAC address of the last network device that it traversed). If we do this mapping, you've almost guaranteed both false positives and false negatives.

other considerations

NetBox has the concept of sites. Sites can have overlapping IP address ranges, of course. For now, the value in theNETBOX_DEFAULT_SITE variable in docker-compose will be used as a query parameter for enrichment lookups. If we need to handle multiple sites in a single malcolm instance we'll have to revisit that decision. At that point there would have to be a way to specify site on PCAP upload OR to associate a particular capture appliance (hedgehog capture node) with a site.

implementation

@mmguero mmguero pinned this issue Dec 8, 2022
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Dec 12, 2022
… NetBox lookups

Squashed commit of the following:

commit c05ca3b
Author: Seth Grover <[email protected]>
Date:   Mon Dec 12 10:27:52 2022 -0700

    testing with netbox API

commit a8d849a
Author: Seth Grover <[email protected]>
Date:   Mon Dec 12 10:22:36 2022 -0700

    testing with netbox API

commit caa7eaf
Author: Seth Grover <[email protected]>
Date:   Mon Dec 12 09:21:15 2022 -0700

    testing with netbox API

commit d6e3278
Author: Seth Grover <[email protected]>
Date:   Mon Dec 12 07:59:27 2022 -0700

    testing with netbox API

commit e884d27
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 15:29:19 2022 -0700

    testing with netbox API

commit 6436c9f
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 15:20:40 2022 -0700

    testing with netbox API

commit 720c8c3
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 15:10:59 2022 -0700

    testing with netbox API

commit 5e3f6a5
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 15:04:15 2022 -0700

    testing with netbox API

commit 5db3442
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 14:54:54 2022 -0700

    testing with netbox API

commit c4d28f1
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 14:51:17 2022 -0700

    testing with netbox API

commit df42a3c
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 14:48:10 2022 -0700

    testing with netbox API

commit 2d5948d
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 14:38:16 2022 -0700

    ruby netbox API work in progess

commit 6a2e7af
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 11:49:38 2022 -0700

    testing with netbox API

commit ad520b6
Author: Seth Grover <[email protected]>
Date:   Fri Dec 9 11:40:20 2022 -0700

    logstash -> ruby -> netbox work in progress

commit 2315505
Merge: 0af0907 d6dd77e
Author: Seth Grover <[email protected]>
Date:   Thu Dec 8 12:28:56 2022 -0700

    Merge branch 'netboxenrich' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 0af0907
Author: Seth Grover <[email protected]>
Date:   Wed Nov 16 07:21:43 2022 -0700

    testing for netbox enrichment

commit d6dd77e
Merge: 73a0536 4a2c336
Author: Seth Grover <[email protected]>
Date:   Thu Dec 8 09:06:34 2022 -0700

    Merge branch 'netboxenrich' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 73a0536
Author: Seth Grover <[email protected]>
Date:   Wed Nov 16 07:21:43 2022 -0700

    testing for netbox enrichment

commit 4a2c336
Merge: 3b0e402 6b6fd47
Author: Seth Grover <[email protected]>
Date:   Wed Dec 7 09:47:09 2022 -0700

    Merge branch 'netboxenrich' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 3b0e402
Author: Seth Grover <[email protected]>
Date:   Wed Nov 16 07:21:43 2022 -0700

    testing for netbox enrichment

commit 6b6fd47
Merge: 71693e7 c237a9d
Author: Seth Grover <[email protected]>
Date:   Wed Dec 7 07:51:57 2022 -0700

    Merge branch 'netboxenrich' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 71693e7
Author: Seth Grover <[email protected]>
Date:   Wed Nov 16 07:21:43 2022 -0700

    testing for netbox enrichment

commit c237a9d
Author: Seth Grover <[email protected]>
Date:   Wed Nov 30 13:50:52 2022 -0700

    added flexibility in demo reset/populate data

commit b323d49
Merge: 762dc93 9954373
Author: Seth Grover <[email protected]>
Date:   Wed Nov 30 12:27:56 2022 -0700

    Merge branch 'netboxenrich' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 762dc93
Author: Seth Grover <[email protected]>
Date:   Wed Nov 16 07:21:43 2022 -0700

    testing for netbox enrichment

commit 9954373
Merge: 0540a27 f8024bc
Author: Seth Grover <[email protected]>
Date:   Mon Nov 21 14:06:05 2022 -0700

    Merge branch 'netboxenrich' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 0540a27
Author: Seth Grover <[email protected]>
Date:   Wed Nov 16 07:21:43 2022 -0700

    testing for netbox enrichment

commit f8024bc
Merge: 88cf2ba 66ebec1
Author: Seth Grover <[email protected]>
Date:   Mon Nov 21 09:03:31 2022 -0700

    Merge branch 'netboxenrich' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 88cf2ba
Author: Seth Grover <[email protected]>
Date:   Wed Nov 16 07:21:43 2022 -0700

    testing for netbox enrichment

commit 66ebec1
Merge: 32e559c 4cf2b81
Author: Seth Grover <[email protected]>
Date:   Mon Nov 21 07:14:05 2022 -0700

    Merge branch 'development' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 32e559c
Merge: 7d43b0d 2fc15d4
Author: Seth Grover <[email protected]>
Date:   Mon Nov 21 06:43:55 2022 -0700

    Merge branch 'development' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 7d43b0d
Merge: 31e4ba9 f0ab2d8
Author: Seth Grover <[email protected]>
Date:   Thu Nov 17 14:15:33 2022 -0700

    Merge branch 'development' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit 31e4ba9
Merge: fa87bf4 a046e77
Author: Seth Grover <[email protected]>
Date:   Thu Nov 17 10:19:02 2022 -0700

    Merge branch 'development' of https://github.com/mmguero-dev/Malcolm into netboxenrich

commit fa87bf4
Author: Seth Grover <[email protected]>
Date:   Wed Nov 16 07:21:43 2022 -0700

    testing for netbox enrichment
@mmguero mmguero self-assigned this Dec 12, 2022
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Dec 12, 2022
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Dec 12, 2022
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Dec 13, 2022
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Dec 19, 2022
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Dec 19, 2022
@mmguero
Copy link
Collaborator Author

mmguero commented Dec 20, 2022

Currently I'm implementing these source and destination enrichment objects in the opensearch index template with the nested field type.

However, I might have to rethink this, due to opensearch-project/OpenSearch-Dashboards#657. Nested fields are not supported currently in visualizations, which makes them basically unusable in a Dashboards context. While they can be used in DQL queries, they can't be used in charts/tables/etc.

@mmguero
Copy link
Collaborator Author

mmguero commented Dec 21, 2022

However, I might have to rethink this

See mmguero-dev/Malcolm@29b0806

mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Jan 2, 2023
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Jan 2, 2023
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Jan 2, 2023
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Jan 3, 2023
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Jan 3, 2023
mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Jan 3, 2023
@mmguero
Copy link
Collaborator Author

mmguero commented Jan 3, 2023

Here's a screenshot of the new Network Assets dashboard which highlights the enrichment done to network traffic metadata based on NetBox lookups:

Screenshot 2023-01-03 at 08-24-29 Network Assets - Malcolm Dashboards

@mmguero
Copy link
Collaborator Author

mmguero commented Jan 3, 2023

Here's a screenshot of Arkime showing a conn.log entry with the netbox stuff populated:

Screenshot 2023-01-03 at 16-37-59 docker-cluster - Sessions - 5MtEEIyZFxjjv0gvaro_ - tags acme   tags cross_segment   bytes 2000   destination device id EXISTS!

@mmguero
Copy link
Collaborator Author

mmguero commented Jan 3, 2023

Here's a video illustrating navigating from Arkime directly to a device (or subnet) in the NetBox interface:

output.mp4

@mmguero mmguero closed this as completed Jan 3, 2023
@github-project-automation github-project-automation bot moved this from Todo (design) to Done in Malcolm Jan 3, 2023
@mmguero mmguero reopened this Jan 3, 2023
@mmguero
Copy link
Collaborator Author

mmguero commented Jan 3, 2023

Illustrates using network segment and other enriched data in Arkime's connections view:

Screenshot 2023-01-03 at 08-36-06 docker-cluster - Connections - cRdxUi9Aj_zIDMpD_uc_ - tags acme

Screenshot 2023-01-03 at 08-38-19 docker-cluster - Connections - cRdxUi9Aj_zIDMpD_uc_ - tags acme

Screenshot 2023-01-03 at 16-40-34 docker-cluster - Connections - 5MtEEIyZFxjjv0gvaro_ - tags acme
Screenshot 2023-01-03 at 16-41-33 docker-cluster - Connections - 5MtEEIyZFxjjv0gvaro_ - tags acme

mmguero added a commit to mmguero-dev/Malcolm that referenced this issue Jan 3, 2023
@mmguero
Copy link
Collaborator Author

mmguero commented Jan 3, 2023

Illustrates using SPIGraph to break down network traffic by netbox-enriched fields:

Screenshot 2023-01-03 at 16-42-34 docker-cluster - Spigraph - 5MtEEIyZFxjjv0gvaro_ - tags acme
Screenshot 2023-01-03 at 16-43-36 docker-cluster - Spigraph - 5MtEEIyZFxjjv0gvaro_ - tags acme
Screenshot 2023-01-03 at 16-44-14 docker-cluster - Spigraph - 5MtEEIyZFxjjv0gvaro_ - tags acme

@mmguero mmguero moved this from Done to In Progress in Malcolm Jan 4, 2023
@mmguero
Copy link
Collaborator Author

mmguero commented Jan 6, 2023

Here are some more screenshots from NetBox itself illustrating some of the things Malcolm will use to do enrichment (populated for some fake demo data).

Sites

Screenshot 2023-01-06 at 09-52-56 Sites NetBox

Devices

Screenshot 2023-01-06 at 09-53-48 Devices NetBox

Device Roles

Screenshot 2023-01-06 at 09-54-07 Device Roles NetBox

Device Types

Screenshot 2023-01-06 at 09-54-23 Device Types NetBox

Manufacturers

Screenshot 2023-01-06 at 09-54-34 Manufacturers NetBox

Prefixes/VRFs

Screenshot 2023-01-06 at 09-56-03 Prefixes NetBox

Virtual Machines

Screenshot 2023-01-06 at 09-56-31 Virtual Machines NetBox

@mmguero mmguero closed this as completed Jan 9, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Malcolm Jan 9, 2023
@mmguero mmguero removed the status in Malcolm Jan 9, 2023
@mmguero mmguero moved this to Done in Malcolm Jan 9, 2023
@mmguero mmguero moved this from Done to Released in Malcolm Jan 9, 2023
@mmguero mmguero unpinned this issue Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request netbox Related to Malcolm's use of NetBox
Projects
Status: Released
Development

No branches or pull requests

1 participant