Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
feat(connectors): Okta and Entra emit the session, network and client fields AiTM needs
Beenu Arorac2f0de1986bf
diff --git a/services/connectors/app/connectors/azure_entra.py b/services/connectors/app/connectors/azure_entra.pyindex c549a2b87..36b176af7 100644--- a/services/connectors/app/connectors/azure_entra.py+++ b/services/connectors/app/connectors/azure_entra.py@@ -210,6 +210,8 @@ class AzureEntraConnector(BaseConnector):"medium": "medium","high": "high",}.get(risk, "medium")+ device = raw.get("deviceDetail") or {}+ location = raw.get("location") or {}return {"source": self.connector_id,"external_id": raw.get("id", ""),@@ -224,6 +226,42 @@ class AzureEntraConnector(BaseConnector):"actor": raw.get("userDisplayName"),"actor_email": raw.get("userPrincipalName"),"event_type": "azure.entra.signin.risky",+ # Depth 7.3 — adversary-in-the-middle session reuse. Graph's+ # `signIn` resource carries all of this and `normalize()`+ # emitted none of it, so a rule grouping by session or+ # comparing networks had nothing to read: the engine+ # flattens `raw_event` one level and `deviceDetail` arrives+ # as a dict.+ #+ # `sessionId` is read first and `correlationId` is **not** a+ # fallback for it. They mean different things: a correlation+ # id identifies one sign-in request, a session id identifies+ # the session the sign-in established. Substituting one for+ # the other would make every sign-in its own session and the+ # reuse detection could never fire, while looking like it+ # worked. Both are emitted under their own names and the+ # detection names the one it needs.+ "session_id": raw.get("sessionId"),+ "correlation_id": raw.get("correlationId"),+ "src_asn": raw.get("autonomousSystemNumber"),+ "src_country": location.get("countryOrRegion"),+ "user_agent": raw.get("userAgent"),+ "client_browser": device.get("browser"),+ "client_os": device.get("operatingSystem"),+ "client_app": raw.get("clientAppUsed"),+ "device_id": device.get("deviceId"),+ "device_compliant": device.get("isCompliant"),+ # Graph states this directly, so there is nothing to infer.+ # `None` when the field is absent, which is not the same as+ # single-factor: an older API version that does not return+ # it must not make every sign-in look unchallenged.+ "mfa_satisfied": (+ None+ if raw.get("authenticationRequirement") is None+ else raw.get("authenticationRequirement") == "multiFactorAuthentication"+ ),+ "authentication_requirement": raw.get("authenticationRequirement"),+ "incoming_token_type": raw.get("incomingTokenType"),"raw_event": raw,"created_at": raw.get("createdDateTime"),}diff --git a/services/connectors/app/connectors/okta.py b/services/connectors/app/connectors/okta.pyindex 182579dca..248b7eb27 100644--- a/services/connectors/app/connectors/okta.py+++ b/services/connectors/app/connectors/okta.py@@ -16,6 +16,53 @@ from app.connectors.base import BaseConnector, Capability, ConnectorSchema, Fiellogger = structlog.get_logger()+#: Okta event types whose SUCCESS means a second factor was actually+#: verified. Listed rather than inferred from a substring, because+#: `user.authentication.auth_via_mfa` and `user.mfa.factor.deactivate` both+#: contain "mfa" and only one of them is a satisfied challenge.+_MFA_SATISFIED_EVENTS: frozenset[str] = frozenset(+ {+ "user.authentication.auth_via_mfa",+ "user.authentication.verify",+ "user.mfa.okta_verify.deny_push",+ "user.mfa.attempt_bypass",+ }+)++#: The subset of the above that means the challenge *passed*. A denied push+#: and a bypass attempt are MFA events and emphatically not satisfied ones,+#: and folding them in would make `mfa_satisfied` true for the exact+#: sequence an MFA-fatigue rule is looking for.+_MFA_DENIED_EVENTS: frozenset[str] = frozenset({"user.mfa.okta_verify.deny_push", "user.mfa.attempt_bypass"})+++def _mfa_satisfied(raw: dict[str, Any], result: str) -> bool | None:+ """Did this event record a second factor being verified?++ Three-valued on purpose. ``None`` means "this event says nothing about+ MFA", which is most of them, and a detection that treats that as+ ``False`` would fire on every directory read. Only an event type that+ records a factor check answers True or False at all -- the same shape as+ the ``not_evaluated`` third value in sender authentication, and for the+ same reason: silence is not a negative result.+ """+ event_type = str(raw.get("eventType") or "")+ if event_type in _MFA_DENIED_EVENTS:+ return False+ if event_type in _MFA_SATISFIED_EVENTS:+ return result == "SUCCESS"+ # A session start carries the factor it was satisfied with in debugData+ # when the policy required one. Absent that, the sign-in was+ # single-factor and this says so rather than staying silent, because a+ # session that never met a challenge is the baseline an AiTM detection+ # compares against.+ if event_type == "user.session.start" and result == "SUCCESS":+ debug = (raw.get("debugContext") or {}).get("debugData") or {}+ factor = str(debug.get("factor") or debug.get("factorUsed") or "")+ return bool(factor)+ return None++class OktaConnector(BaseConnector):connector_id = "okta"connector_name = "Okta Identity"@@ -138,6 +185,10 @@ class OktaConnector(BaseConnector):actor = raw.get("actor", {})client_info = raw.get("client", {})+ auth_context = raw.get("authenticationContext") or {}+ security_context = raw.get("securityContext") or {}+ user_agent = client_info.get("userAgent") or {}+ geo = client_info.get("geographicalContext") or {}return {"source": self.connector_id,@@ -169,6 +220,43 @@ class OktaConnector(BaseConnector):# connector and is provable by replay."outcome": result,"outcome_reason": outcome.get("reason"),+ # Depth 7.3 — adversary-in-the-middle session reuse.+ #+ # Same class of fix as `outcome` above and for the same reason:+ # the engine flattens `raw_event` exactly one level, so+ # `authenticationContext` arrives as a dict and a rule clausing+ # on a session id compares a string against `{...}`. Okta carries+ # every field an AiTM detection needs and `normalize()` emitted+ # none of them, so the family had nothing to group by.+ #+ # `session_id` is the one that matters. An AiTM proxy relays the+ # victim's credentials *and* their MFA response, so the sign-in+ # itself is legitimate by every check Okta makes; what gives the+ # attacker away is the stolen session cookie being replayed from+ # somewhere else. That is only visible if the session identity+ # survives normalization.+ "session_id": auth_context.get("externalSessionId"),+ "authentication_step": auth_context.get("authenticationStep"),+ # The network the request came from. `src_ip` alone cannot+ # express "a different network": a residential ISP rotates+ # addresses within one ASN all day, and an AiTM replay from a+ # hosting provider is a different ASN entirely.+ "src_asn": security_context.get("asNumber"),+ "src_asn_org": security_context.get("asOrg"),+ "src_isp": security_context.get("isp"),+ "is_proxy": security_context.get("isProxy"),+ "src_country": geo.get("country"),+ # The client family. A session that was established in Chrome on+ # Windows and is next used by a bare HTTP client is the second+ # half of the same signal.+ "user_agent": user_agent.get("rawUserAgent"),+ "client_browser": user_agent.get("browser"),+ "client_os": user_agent.get("os"),+ # Whether this sign-in actually satisfied MFA. `authnRequestId`+ # and the factor live in debugData; the step-up itself is a+ # distinct event type, so this reads the outcome of the one Okta+ # recorded rather than inferring it.+ "mfa_satisfied": _mfa_satisfied(raw, result),"raw_event": raw,"created_at": raw.get("published"),}