Skip to content

[Rule Tuning] Entra ID Federated Identity Credential Modified - #6936

Merged
terrancedejesus merged 11 commits into
mainfrom
rule-tuning/entra-id-federated-identity-credential-modified-310
Oct 8, 2026
Merged

terrancedejesus merged 11 commits into
mainfrom
rule-tuning/entra-id-federated-identity-credential-modified-310

Conversation

@terrancedejesus

@terrancedejesus terrancedejesus commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Renamed Entra ID Federated Identity Credential Issuer Modified to Entra ID Federated Identity Credential Modified; file renamed to match.
  • Rule now alerts on three federated identity credential (FIC) changes to an application: first credential created, additional credential added, issuer changed on an existing credential. Previously it only caught an issuer swap on the first credential in the array.
  • Why: lab emulation showed Entra appends a new credential, so the first-Issuer dissect never saw an add, and a first add ([] -> one credential) was invisible. This covers the behavior community PR [New] Entra ID Federated Identity Credential Added #6741 targets without a second rule on the same event.
  • Replaced DISSECT with JSON_EXTRACT over MV_EXPAND'ed credential objects matched by Id. min_stack_version 9.3.0 -> 9.4.0.
  • Subject/audience-only edits and credential removals do not alert.
  • Alert fields: Esql.fic_change (fic_created, fic_added, fic_issuer_changed), Esql.fic_id, Esql.fic_old_issuer, Esql.fic_new_issuer, Esql.fic_old_count, Esql.fic_new_count.
  • Investigation guide updated to the new fields and values.
  • Tagged Profile: Beta: the shipped rule has no alert telemetry, so noise cannot be measured until the new logic has run in the field.

Logic breakdown

  • Filter Update application audit events whose modified property is FederatedIdentityCredentials.
  • Count credentials in the old and new arrays by counting { (one JSON object per credential).
  • Drop events where the new array is empty or smaller than the old one (removals).
  • Strip the outer brackets, split the new array on },{, and MV_EXPAND to one row per credential.
  • JSON_EXTRACT the Id and Issuer from each new credential object.
  • LOCATE the same Id in the old array; if present, cut that object out and JSON_EXTRACT its Issuer.
  • CASE: old count 0 -> fic_created; Id not in old and count grew -> fic_added; same Id, different issuer -> fic_issuer_changed; otherwise none.
  • Drop none rows and the working fields, keep the alert fields.
Screenshot 2026-10-01 at 10 20 47 AM

Cover first credential created, additional credential added, and issuer
changed on an existing credential in one ES|QL query. Replace the
first-Issuer dissect with JSON_EXTRACT over MV_EXPAND'ed credential
objects matched by Id. Rename rule and file to match.
@terrancedejesus terrancedejesus added Integration: Azure azure related rules Rule: Tuning tweaking or tuning an existing rule Domain: Identity Domain: Cloud labels Oct 1, 2026
@terrancedejesus terrancedejesus self-assigned this Oct 1, 2026
@terrancedejesus
terrancedejesus marked this pull request as ready for review October 1, 2026 14:56
Copilot AI balanced review requested due to automatic review settings October 1, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Threat metadata and fleet-derived tags need correction before approval.

Review effort: Balanced
Findings: 3 Low severity

Open (3)
What changed in this PR

Broadens the Entra ID FIC rule to detect credential creation, addition, and issuer changes.

Changes:

  • Renames the rule and file.
  • Replaces DISSECT logic with per-credential JSON parsing.
  • Updates alert fields and investigation guidance.
File Description
persistence_entra_id_service_principal_federated_issuer_modified.toml Removes the former rule path.
persistence_entra_id_federated_identity_credential_modified.toml Adds the renamed, expanded rule.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bryans3c bryans3c left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggest adding a fic_subject_changed branch. For GitHub Actions FICs the issuer is the same for every repo on GitHub, the subject is the only thing scoping the trust. An attacker with app-management rights can just rewrite Subject on the existing credential (repo:acme/deploy:ref:refs/heads/main -> repo:attacker/x:*): no new credential, same issuer, same Id, and the rule returns none (our lab subject-edit event at 18:33:42 confirms). It's two extra json_extract calls on Subject plus one case line, and the subject is useful on fic_added alerts anyway.

concat("{", mv_last(split(substring(Esql.fic_old_value, 1, Esql.fic_old_id_pos - 1), "{")), mv_first(split(substring(Esql.fic_old_value, Esql.fic_old_id_pos), "}")), "}"),
null
)
| eval Esql.fic_old_issuer = json_extract(Esql.fic_old_object, "Issuer")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
| eval Esql.fic_old_issuer = json_extract(Esql.fic_old_object, "Issuer")
| eval Esql.fic_old_issuer = json_extract(Esql.fic_old_object, "Issuer"),
Esql.fic_old_subject = json_extract(Esql.fic_old_object, "Subject")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bryans3c - Issuer is the correct field being extracted here. It is whom will issue/mint tokens for the application as the third-party IdP.

Example:

{"Name":"fic-9c335d-extra","Issuer":"https://oidc.invalid/entra-fic-add-vs-modify-9c335d/extra","Subject":"lab-subject-extra","Id":"4f8b483d-f787-4b7f-a748-8cb0dd72c82b","Description":"emulation-run entra-fic-add-vs-modify-9c335d second credential","Audiences":["api://AzureADTokenExchange"],"ClaimsMatchingExpressionValue":null,"ClaimsMatchingExpressionLanguageVersion":0,"EncodingVersion":2,"TrustedIssuer":null}


query = '''
from logs-azure.auditlogs-* metadata _id, _version, _index
| where event.action == "Update application"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can be this a multi-value array?

Comment on lines +73 to +74
"Data Source: Microsoft Entra ID",
"Data Source: Microsoft Entra ID Audit Logs",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need to list both Data Source ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, not based on Platform inclusion. Will update, good catch.

…ntial

A subject-only edit on an existing credential (same Id, same issuer, same
count) previously classified as none and did not alert. On shared public
issuers such as GitHub Actions the subject is the only value scoping the
trust, so an actor with app-management rights could re-point an existing
credential at their own repository without tripping the rule.

Extract Subject from the old and new credential objects and add a
fic_subject_changed case after fic_issuer_changed. Subject is coalesced to
an empty string before comparing because json_extract returns null for the
JSON null that flexible credentials carry, and a raw != against null would
never be true. Verified against a year of trade-lab audit logs: the
2026-09-29 18:33:42 subject-edit event now alerts, the unchanged sibling
credential in the same event stays none, and all existing classifications
are unchanged.

@bryans3c bryans3c left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@terrancedejesus
terrancedejesus added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit 7e37a41 Oct 8, 2026
8 checks passed
@terrancedejesus
terrancedejesus deleted the rule-tuning/entra-id-federated-identity-credential-modified-310 branch October 8, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants