Skip to content

ping_federate: strip brackets from IPv6 in audit CEF before decode_cef#17620

Merged
navnit-elastic merged 2 commits intoelastic:mainfrom
navnit-elastic:ping_federate-brackets-around-ipv6
Mar 10, 2026
Merged

ping_federate: strip brackets from IPv6 in audit CEF before decode_cef#17620
navnit-elastic merged 2 commits intoelastic:mainfrom
navnit-elastic:ping_federate-brackets-around-ipv6

Conversation

@navnit-elastic
Copy link
Contributor

@navnit-elastic navnit-elastic commented Mar 2, 2026

Proposed commit message

ping_federate: strip brackets from IPv6 in audit CEF before decode_cef

PingFederate can emit CEF audit logs with IPv6 in brackets
(e.g. src=[2a01:599:110:e652:...]), which violates CEF spec and causes
decode_cef to fail with "value is not a valid IP address".

Add a script processor before decode_cef in TCP, UDP, and filestream
streams to remove brackets around IPv6 addresses so the decoder
receives a valid IP.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Author's Checklist

  • [ ]

How to test this PR locally

System Tests:

--- Test results for package: ping_federate - START ---
╭───────────────┬─────────────┬───────────┬───────────┬────────┬───────────────╮
│ PACKAGE       │ DATA STREAM │ TEST TYPE │ TEST NAME │ RESULT │  TIME ELAPSED │
├───────────────┼─────────────┼───────────┼───────────┼────────┼───────────────┤
│ ping_federate │ admin       │ system    │ logfile   │ PASS   │    41.068725s │
│ ping_federate │ audit       │ system    │ logfile   │ PASS   │ 36.846062666s │
│ ping_federate │ audit       │ system    │ tcp       │ PASS   │ 40.067340083s │
│ ping_federate │ audit       │ system    │ tls       │ PASS   │ 40.995306209s │
│ ping_federate │ audit       │ system    │ udp       │ PASS   │ 41.058248209s │
╰───────────────┴─────────────┴───────────┴───────────┴────────┴───────────────╯
--- Test results for package: ping_federate - END   ---
Done

Related issues

Screenshots

@navnit-elastic navnit-elastic self-assigned this Mar 2, 2026
@navnit-elastic navnit-elastic added bug Something isn't working, use only for issues bugfix Pull request that fixes a bug issue Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] Integration:ping_federate PingFederate Team:SDE-Crest Crest developers on the Security Integrations team [elastic/sit-crest-contractors] labels Mar 2, 2026
@navnit-elastic navnit-elastic force-pushed the ping_federate-brackets-around-ipv6 branch from f268aec to b163a1b Compare March 2, 2026 12:27
@navnit-elastic navnit-elastic marked this pull request as ready for review March 2, 2026 12:55
@navnit-elastic navnit-elastic requested a review from a team as a code owner March 2, 2026 12:55
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

Can you add a link to documentation that supports the rationale for this change? The CEF parser that we are using does not support IPv6 (the src field described in the v25 spec says that it is an IPv4, "Identifies the source that an event refers to in an IP network. The format is an IPv4 address. Example: “192.168.10.1”." ISTM that this is a workaround for a format that's not documented to support IPv6 (so it's not a bugfix, at least not in the processor; it is likely a bug in the data source if we are seeing IPv6 data coming through, though note paragraph below regarding spec versions).

If there is a later version of the spec that does support IPv6, we should probably make a change to the processor in beats. We can apply this workaround, but it should be noted as such.

@andrewkroh
Copy link
Member

Relates: elastic/beats#40269 (for CEF spec updates, mentions IPv6)

@navnit-elastic
Copy link
Contributor Author

The CEF parser that we are using does not support IPv6 (the src field described in the v25 spec says that it is an IPv4, "Identifies the source that an event refers to in an IP network. The format is an IPv4 address. Example: “192.168.10.1”." ISTM that this is a workaround for a format that's not documented to support IPv6 (so it's not a bugfix, at least not in the processor; it is likely a bug in the data source if we are seeing IPv6 data coming through

The failure is due to brackets around the IP, which are not part of the CEF src format in the spec.

The change strips those brackets so the parser receives a valid IP string; it’s a format normalization, not an IPv6‑vs‑IPv4 feature.

The CEF v25 “src is IPv4” point is a separate spec detail; if the processor later supports IPv6 per a newer spec, the same “no brackets” rule would still apply.

@efd6
Copy link
Contributor

efd6 commented Mar 3, 2026

Yes, it looks like Ping Federate had the same misconception as I did; they have misunderstood IPv6 syntax in a URI as being the general syntax. So what I said about IPv6 updates fixing it was wrong, but the comment about the nature of the change is now more correct; this is not a bugfix. The bug is in Ping Federate.

We should probably relax the CEF processor, I'm sure others will have made the same mistake.

@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@elasticmachine
Copy link

💚 Build Succeeded

History

cc @navnit-elastic

@navnit-elastic navnit-elastic requested a review from efd6 March 6, 2026 10:34
@navnit-elastic navnit-elastic added enhancement New feature or request and removed bug Something isn't working, use only for issues bugfix Pull request that fixes a bug issue labels Mar 9, 2026
var msg = event.Get("event.original");
if (msg != null) {
// Remove brackets from IPv6 addresses to comply with CEF specification
msg = msg.replace(/\[([0-9a-fA-F:]+)\]/gi, "$1");
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note that the IPv6 pattern is more complex than this. An indication of this is from the grok patterns here

Copy link
Contributor Author

@navnit-elastic navnit-elastic Mar 10, 2026

Choose a reason for hiding this comment

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

Thanks for the note.

This step only strips the brackets; it doesn’t validate the contents. Real validation happens in decode_cef, which will still reject invalid IPs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, my concern (minor) was that if there was anything else in the message that is [hexdigitsandcolons] then it would be mutated as well even if it were not an IPv6. I think this is reasonably unlikely, but it is less unlikely than something that specifically looks like an IPv6 and isn't an IPv6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for clarifying.

Agreed - there's a small risk. We will keep this in mind for the future.

@navnit-elastic navnit-elastic merged commit d715d01 into elastic:main Mar 10, 2026
13 checks passed
@elastic-vault-github-plugin-prod

Package ping_federate - 1.2.0 containing this change is available at https://epr.elastic.co/package/ping_federate/1.2.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Integration:ping_federate PingFederate Team:SDE-Crest Crest developers on the Security Integrations team [elastic/sit-crest-contractors] Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants