Azure-Sentinel icon indicating copy to clipboard operation
Azure-Sentinel copied to clipboard

Palo Alto Cortex XDR CCP 3.0.5 & Cortex XDR 3.0.2 - fix PaloAltoCortexXDR_Alerts_CL offset-pagination loop

Open v-krishnachi opened this issue 6 months ago • 5 comments

Palo Alto Cortex XDR CCP 3.0.5 & Cortex XDR 3.0.2 — fix PaloAltoCortexXDR_Alerts_CL offset-pagination loop

Solutions affected: Palo Alto Cortex XDR CCP (3.0.4 → 3.0.5) and the legacy Cortex XDR (3.0.1 → 3.0.2) — both ship the same CortexXdrAlerts RestApiPoller resource and therefore both carry the same defect. ICM (internal): 2605070040011703 Type: Bug fix (request-body correction + sort-order correction)


Symptom

A customer running the Palo Alto Cortex XDR CCP solution stopped ingesting any rows into PaloAltoCortexXDR_Alerts_CL, while the other four Cortex XDR streams (Agent / Endpoints / Incidents / Management) continued ingesting normally. Palo Alto's API-gateway telemetry showed the customer's API key emitting ~120–200 POST requests/minute against POST /public_api/v1/alerts/get_alerts, all using the same fixed creation_time start value (~2025-05-05), sustained across many minutes. Palo Alto rate-limited the key with HTTP 429 and asked Microsoft to reduce call volume.

Root cause

The CortexXdrAlerts rule in PollingConfig.json declares an offset-paging block:

"paging": {
  "offsetParaName":    "$.request_data.search_from",
  "pagingType":        "Offset",
  "offsetEndParaName": "$.request_data.search_to",
  "pageSize":          100
}

…but the request body it points at did not contain those two keys:

"queryParametersTemplate":
  "{ 'request_data': { 'filters': [
       { 'field': 'creation_time', 'operator': 'gte', 'value': {_QueryWindowStartTime} },
       { 'field': 'creation_time', 'operator': 'lte', 'value': {_QueryWindowEndTime}   }
     ],
     'sort': { 'field': 'creation_time', 'keyword': 'desc' }
  } }"

How CCP RestApiPoller offset paging actually works in the runtime:

  1. The runtime substitutes {_QueryWindowStartTime} / {_QueryWindowEndTime} from its internal cursor state, then issues page 1.
  2. After each response it inspects eventsJsonPaths ($.reply.alerts). If the page is "full" (count ≥ pageSize), it writes the next offsets to the JSONPaths configured in offsetParaName / offsetEndParaName and issues the next page.
  3. Paging stops only when a response returns fewer than pageSize rows under the configured JSONPath.

Because $.request_data.search_from and $.request_data.search_to were not present in the body, the runtime's per-page writes silently no-op'd. Every page request therefore went out identical to the previous one. Combined with sort.keyword = "desc" on creation_time (which makes XDR's offset pagination non-deterministic under load — new alerts arriving mid-poll push existing alerts down by one, breaking offset semantics), the API kept returning full pages indefinitely, the runtime kept asking for more, and a single 5-minute poll cycle entered an unbounded loop.

Because the loop never produced a "Success" cycle, _QueryWindowStartTime never advanced — every subsequent poll re-attempted the same frozen window. That is why Palo Alto's SRE team saw a fixed creation_time date repeated on every request.

Reference documentation

  • Palo Alto Cortex XDR API Reference — "Get All Alerts" (POST /public_api/v1/alerts/get_alerts): defines request_data.search_from (start offset, default 0) and request_data.search_to (end offset, default 100, max page size 100). Documents sort as { field, keyword } with default creation_time, desc, both asc/desc valid. https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR-REST-API/Get-all-Alerts
  • Microsoft Learn — "Create a codeless connector for Microsoft Sentinel", RestApiPoller → paging: for pagingType: Offset, offsetParaName / offsetEndParaName JSONPaths must resolve to properties that already exist in queryParametersTemplate, otherwise the runtime cannot advance pages. https://learn.microsoft.com/azure/sentinel/create-codeless-connector
  • ARM REST schema for RestApiPollerDataConnector.properties.paging: https://learn.microsoft.com/rest/api/securityinsights/data-connectors/create-or-update

Fix

Two surgical changes, applied only to the CortexXdrAlerts RestApiPoller resource in both solutions:

  1. Added 'search_from': 0, 'search_to': 100 to the Alerts queryParametersTemplate request body. The literal values are the seed values the runtime uses for page 1 (they match PAN's documented defaults — search_from = 0 zero-based, search_to = 100 matches PAN's hard 100-row page-size cap). On subsequent pages the runtime now has real JSON nodes to overwrite via offsetParaName / offsetEndParaName, so pagination advances correctly and exits on a short final page.
  2. Changed sort.keyword for creation_time from desc → asc. PAN explicitly allows the override, and offset pagination is only deterministic with ascending sort on the same field used in filters. New alerts created mid-poll then append at the end of the result set instead of shifting every existing offset down by one.

Files changed (10)

Palo Alto Cortex XDR CCP solution (3.0.4 → 3.0.5)

  1. Solutions/Palo Alto Cortex XDR CCP/Data Connectors/CortexXDR_ccp/PollingConfig.json — Alerts request body + sort.
  2. Solutions/Palo Alto Cortex XDR CCP/Package/mainTemplate.json — same fix on the embedded CortexXdrAlerts resource; _solutionVersion (line 48) and contentPackages.properties.version (line 2675) bumped to 3.0.5.
  3. Solutions/Palo Alto Cortex XDR CCP/Data/Solution_CortexXDR.json — Version bumped to 3.0.5.
  4. Solutions/Palo Alto Cortex XDR CCP/ReleaseNotes.md — new 3.0.5 row.
  5. Solutions/Palo Alto Cortex XDR CCP/Package/3.0.5.zip — regenerated solution package.

Legacy Cortex XDR solution (3.0.1 → 3.0.2)

  1. Solutions/Cortex XDR/Data Connectors/CortexXDR_ccp/PollingConfig.json — Alerts request body + sort.
  2. Solutions/Cortex XDR/Package/mainTemplate.json — same fix on the embedded CortexXdrAlerts resource; _solutionVersion (line 48) and contentPackages.properties.version (line 3747) bumped to 3.0.2.
  3. Solutions/Cortex XDR/Data/Solution_CortexXDR.json — Version bumped to 3.0.2 (and aligned with mainTemplate; was a pre-existing 3.0.0 drift).
  4. Solutions/Cortex XDR/ReleaseNotes.md — new 3.0.2 row.
  5. Solutions/Cortex XDR/Package/3.0.2.zip — regenerated solution package.

v-krishnachi avatar May 30 '26 04:05 v-krishnachi

Hi @v-krishnachi, I noticed in cortex xdr solutions inside and outside maintemplate is diffrent please make sure both should be same. Rest PR is good. Thanks! image

v-shukore avatar Jun 08 '26 06:06 v-shukore

Hi @v-krishnachi, please update maintemplate and commit the chnages. Thanks!

v-shukore avatar Jun 11 '26 08:06 v-shukore

@v-shukore , thanks for feedback on the maintemplateapiversion inside the package. Waiting for some changes from the scuba platform on the paging gap fixing. will update both at once.

v-krishnachi avatar Jun 11 '26 15:06 v-krishnachi

Ok sure @v-krishnachi thanks for the update.

v-shukore avatar Jun 12 '26 07:06 v-shukore

Hi @v-krishnachi, if you have some time to make updates, please move this PR to draft for now. Once your updates are done, you can mark the PR as ready for review. Thanks!

v-shukore avatar Jun 26 '26 05:06 v-shukore