★ wanayoo — archive 1999 https://github.com/carbonblack/cbapi-python/issues/240Nouvelle recherche | Portail wanayoo
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

Python API for Cb ThreatHunter does not retrieve correct device IP information #240

Open
crahan opened this issue Jul 3, 2020 · 3 comments
Open

Comments

@crahan
Copy link
Contributor

@crahan crahan commented Jul 3, 2020

When retrieving process details for a process query using the Python API on Cb ThreatHunter, it does not return the proper IP information as part of the process object properties.

Regular non-enriched process
1  non-enriched

Enriched process
2  enriched

UI device details
3  device details

The device in the screenshots has both an internal and external IP address (per the device details in the UI). However, while looping over the query results for a specific GUID (process_guid:ORGKEY-011e05ee-0000044c-00000000-1d648aca4504395) and retrieving process information the following can be observed:

  1. regular non-enriched process details only contain a device_external_ip field and no device_internal_ip field.
  2. enriched process details only contain a device_internal_ip (which is incorrectly set to the device's external IP) and it is missing a device_external_ip field.

Expectation: both enriched and non-enriched process search results should contain the device_internal_ip and device_external_ip fields which are set to the correct IP values (as indicated by the device details in the UI for that endpoint).

@avanbrunt-cb
Copy link
Contributor

@avanbrunt-cb avanbrunt-cb commented Jul 6, 2020

@crahan Can you provide the sample code you are using to execute this query? Additionally are you using your PR with the new process search v2 routes?

@crahan
Copy link
Contributor Author

@crahan crahan commented Jul 7, 2020

Hi,

The above findings are for the v1 search with the below sample script (and without the v2 search PR applied):

from cbapi.psc.threathunter import CbThreatHunterAPI
from cbapi.psc.threathunter.models import Event, Process

cb = CbThreatHunterAPI(profile='profile-name')

query_result = cb.select(Process).where('process_guid:ORGKEY-011e05ee-0000044c-00000000-1d648aca4504395')

for process in query_result:
    print(process)

Depending on the process search result being enriched or not enriched the output is as described above. When I run this with the changes from the v2 search API I do get an internal and an external IP address for the single process search result from the above script (as the v2 search API aggregates all enriched process information for a specific process GUID into a single object). I've run the above script 3 times with the v2 changes and while the device record in the UI still reports the IP information similar to the above UI screenshot, the result from the above sample script were different for each run:

Run 1

       backend_timestamp: 2020-07-07T08:36:34.203Z
         childproc_count: 56
         crossproc_count: 233
      device_external_ip: 4-REDACTED-1 (a not before seen public IP address 1)
            device_group: mss-windows-test
         device_group_id: 17984
               device_id: 18744814
      device_internal_ip: 1-REDACTED-8 (a not before seen public IP address 2)
             device_name: REDACTED-x1
               device_os: WINDOWS

Run 2

       backend_timestamp: 2020-07-07T09:05:01.263Z
         childproc_count: 56
         crossproc_count: 237
      device_external_ip: 6-REDACTED-8 (same public IP as noted in the initial issue description)
            device_group: mss-windows-test
         device_group_id: 17984
               device_id: 18744814
      device_internal_ip: 6-REDACTED-8 (same public IP as noted in the initial issue description)
             device_name: REDACTED-x1
               device_os: WINDOWS

Run 3

       backend_timestamp: 2020-07-07T09:05:01.263Z
         childproc_count: 56
         crossproc_count: 237
      device_external_ip: 6-REDACTED-8 (same public IP as noted in the initial issue description)
            device_group: mss-windows-test
         device_group_id: 17984
               device_id: 18744814
      device_internal_ip: 4-REDACTED-1 (the same public IP 1 from the first run)
             device_name: REDACTED-x1
               device_os: WINDOWS

v2 API run 1: both IP addresses are different from what is reported in the device record in the UI.
v2 API run 2: both IP fields are set to the public IP address reported in the device record in the UI.
v2 API run 3: the external IP address matches what is reported by the device record in the UI and the internal IP address has changed back to the random external IP address from run 1.

It does not appear that the v2 search API resolves this issue, except for the device_external_ip and device_internal_ip fields always being present. For run 2 and 3 the backend_timestamp is even the same, but the IP info is not. I've run the same script (with the same GUID) a couple more times, and IP address information just keeps changing in between runs.

@avanbrunt-cb
Copy link
Contributor

@avanbrunt-cb avanbrunt-cb commented Jul 9, 2020

This item is being tracked through an EA for backend teams to triage the API service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.