Agent Foskett Academy • KQL Academy • Module 13 • Lesson 155 • Cloud & SaaS Investigation

Lesson 155 — The Application Accessed Data Without the User

Lesson 154 established that an OAuth application was granted consent during an already suspicious cloud investigation. Now the next clue appears: the application continues authenticating and reaching organisational resources when there is no corresponding interactive user session.

In this lesson we use KQL to investigate service principal sign-ins, identify the resources the application reached, search Microsoft 365 activity for matching application context and determine whether the granted permissions were actually exercised without the user.

Consent created the possibility of persistence. Non-interactive application activity is the evidence that tells us whether that possibility became real.
Agent Foskett KQL Academy application access without user investigation
Your case file

The consented application begins generating non-interactive authentication activity after the user stops actively working in Microsoft 365.

✓ Find service principal sign-ins
✓ Identify accessed resources
✓ Search for matching Microsoft 365 activity
✓ Prove whether user interaction was present

Case briefing

CASE FILE User: alex.wilson@contoso.com Application: Contoso Document Helper 14:34 — OAuth consent granted ↓ 14:41 — user activity begins to fall away ↓ 14:47 — service principal authentication recorded ↓ 15:03 — application reaches Microsoft 365 resource ↓ NO MATCHING INTERACTIVE USER SESSION ↓ THE QUESTION Did the application exercise the granted permissions independently of the user?

Investigation objective

Use Microsoft Entra service principal sign-in telemetry and Microsoft 365 audit data to determine whether the application authenticated after consent, which resources it targeted, whether corresponding user sign-ins were present and whether the evidence supports application-based access independent of an interactive user session.

Investigator's rule

Non-interactive does not automatically mean malicious. Applications and services are designed to operate without a person clicking through every request. The security question is whether this application was authorised, expected and operating within its approved permissions.

Stage 1 — find the application's service principal sign-ins

Pivot from the application identifier discovered in Lesson 154 into AADServicePrincipalSignInLogs. Preserve the application, resource, source IP, location, result and correlation context.

01-find-service-principal-signins.kql
12345678910111213141516
let TargetAppId = "11111111-2222-3333-4444-555555555555";
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(7d)
| where AppId == TargetAppId
| project TimeGenerated,
          ServicePrincipalName,
          ServicePrincipalId,
          AppId,
          ResourceDisplayName,
          ResourceServicePrincipalId,
          IPAddress,
          Location,
          ResultType,
          ResultDescription,
          CorrelationId
| order by TimeGenerated asc

Why AppId?

Display names can change or be duplicated. The application ID provides a stronger pivot when following a known application across identity telemetry.

ResourceDisplayName matters

The resource shows what the service principal attempted to access. Authentication to Microsoft Graph, SharePoint or another resource can materially change the impact assessment.

Stage 2 — summarise what the application accessed

Group service principal sign-ins by resource and result. This quickly shows how often the application authenticated, when it first and last appeared and which sources were involved.

02-summarise-application-resource-access.kql
12345678910111213
let TargetAppId = "11111111-2222-3333-4444-555555555555";
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(7d)
| where AppId == TargetAppId
| summarize SignIns=count(),
            FirstSeen=min(TimeGenerated),
            LastSeen=max(TimeGenerated),
            SourceIPs=make_set(IPAddress, 50),
            Locations=make_set(Location, 20)
          by ServicePrincipalName,
             ResourceDisplayName,
             ResultType
| order by SignIns desc

Success proves authentication, not data access

A successful service principal sign-in shows that the application obtained access to a resource context. It does not by itself prove which files, messages or records were read.

Repeated activity changes the story

A single authentication event may be setup or testing. Repeated successful access after the consent event can strengthen the hypothesis that the grant established ongoing application access.

Stage 3 — search Microsoft 365 activity for application context

Now inspect Microsoft 365 audit activity for evidence that can be associated with the application. The exact fields exposed for app-only or service activity vary, so validate the schema and actor fields in your tenant.

03-search-m365-for-application-activity.kql
12345678910111213141516171819202122
let TargetAppId = "11111111-2222-3333-4444-555555555555";
let TargetAppName = "Contoso Document Helper";
OfficeActivity
| where TimeGenerated > ago(7d)
| where OfficeWorkload in ("SharePoint", "OneDrive")
| extend ActorContext = strcat(
      tostring(UserId), " ",
      tostring(UserKey), " ",
      tostring(UserAgent), " ",
      tostring(ClientIP))
| where ActorContext has TargetAppId
   or ActorContext has TargetAppName
| project TimeGenerated,
          OfficeWorkload,
          Operation,
          UserId,
          UserKey,
          Site_Url,
          SourceFileName,
          ClientIP,
          UserAgent
| order by TimeGenerated asc

Schema validation is essential

OfficeActivity records vary by workload and operation. Application identity may appear differently from interactive user activity. Inspect raw events before assuming a particular field always contains the app ID.

Authentication and resource activity are different layers

Entra tells us the application authenticated. Workload audit evidence can help show what happened after authentication. Keep those conclusions separate until the records are correlated.

Stage 4 — test whether the user was actually active

Query interactive sign-in telemetry for the user during the same window. The absence of a matching user sign-in can support the conclusion that application activity occurred independently, but absence must be interpreted carefully.

04-check-for-interactive-user-signins.kql
1234567891011121314
let TargetUser = "alex.wilson@contoso.com";
let StartTime = datetime(2026-08-18 14:30:00);
let EndTime = datetime(2026-08-18 15:30:00);
SigninLogs
| where TimeGenerated between (StartTime .. EndTime)
| where UserPrincipalName =~ TargetUser
| project TimeGenerated,
          UserPrincipalName,
          AppDisplayName,
          IPAddress,
          Location,
          ClientAppUsed,
          ResultType
| order by TimeGenerated asc

No sign-in does not mean no session

Existing sessions and tokens can continue operating without generating a fresh interactive sign-in for every action. Do not equate “no new sign-in record” with “the user could not possibly have been involved.”

Application identity is the stronger clue

If service principal telemetry explicitly identifies the application as the authenticating principal, that is stronger evidence of app-driven access than simply observing a gap in user sign-ins.

Stage 5 — build the application-access timeline

Bring service principal authentication and Microsoft 365 workload activity into one chronological view. Use the timeline to test whether application access begins after consent and continues independently of the user's interactive activity.

05-build-application-access-timeline.kql
123456789101112131415161718192021222324252627
let TargetAppId = "11111111-2222-3333-4444-555555555555";
let StartTime = datetime(2026-08-18 14:30:00);
let EndTime = datetime(2026-08-18 16:00:00);
union
(
    AADServicePrincipalSignInLogs
    | where TimeGenerated between (StartTime .. EndTime)
    | where AppId == TargetAppId
    | project TimeGenerated,
              EvidenceType="Service principal sign-in",
              Actor=ServicePrincipalName,
              Target=ResourceDisplayName,
              Source=IPAddress,
              Detail=strcat("Result=", tostring(ResultType))
),
(
    OfficeActivity
    | where TimeGenerated between (StartTime .. EndTime)
    | where OfficeWorkload in ("SharePoint", "OneDrive")
    | project TimeGenerated,
              EvidenceType="Microsoft 365 activity",
              Actor=tostring(UserId),
              Target=Site_Url,
              Source=ClientIP,
              Detail=strcat(Operation, " | ", SourceFileName)
)
| order by TimeGenerated asc

Correlation requires a defensible key

Time proximity alone is useful but imperfect. Where available, strengthen the relationship with application IDs, service principal IDs, correlation identifiers, actor fields and resource details.

Now persistence can be assessed

If an unapproved application received meaningful permissions and subsequently authenticated as a service principal to relevant resources, the evidence for application-based persistence becomes substantially stronger.

Agent Foskett's application-access timeline

14:34 OAuth consent granted ↓ APPLICATION ID preserved from audit evidence ↓ 14:47 Service principal sign-in ↓ RESOURCE Microsoft 365 service identified ↓ 15:03 Workload activity observed ↓ USER SIGN-IN REVIEW No corresponding new interactive sign-in ↓ APPLICATION CONTEXT correlated across identity + workload evidence ↓ ASSESSMENT Granted permissions were exercised by the application Independent user interaction still assessed carefully
Lesson 154 showed us the key was handed over. Lesson 155 asks whether the application actually used it.

Your evidence board

EvidenceWhat it supportsWeight
Successful service principal sign-in after consentShows the application authenticated to a resource after the grant.Strong
Target resource matches granted permission purposeStrengthens the relationship between consent and subsequent access.Strong context
Workload activity correlated to application identitySupports that the application performed actions after authentication.Very strong when validated
No fresh interactive user sign-inSupports non-interactive operation but does not prove the user had no active session.Supporting context
Repeated application authenticationMay support persistence rather than a one-off setup event.Strong when unauthorised
Service principal sign-in aloneDoes not prove specific organisational data was read or exfiltrated.Insufficient alone

Write the finding like an investigator

Example: Following the OAuth consent event identified in Lesson 154, Microsoft Entra service principal sign-in telemetry recorded successful non-interactive authentication by the associated application to Microsoft 365 resources. The application was tracked using its application identifier and reviewed by target resource, source IP, location, result and time. Microsoft 365 workload audit activity was then examined for corresponding application context, while the target user's interactive sign-in activity was reviewed separately. The sequence supports the conclusion that the application exercised granted access after consent and was capable of operating without a new interactive user sign-in. The evidence should not be overstated: service principal authentication alone does not prove which organisational data was accessed or whether data was exfiltrated. Workload-level activity and permission scope should be used to determine actual impact.

Lesson 155 key takeaways

  • Use AADServicePrincipalSignInLogs to investigate non-interactive application authentication.
  • Track applications by stable identifiers rather than display name alone.
  • Identify the resources targeted by the service principal.
  • A successful application sign-in does not by itself prove specific data access.
  • Correlate identity telemetry with workload-level audit activity.
  • Validate how application identity is represented in your Microsoft 365 audit schema.
  • No new interactive user sign-in does not prove that no existing user session existed.
  • Explicit service principal identity is stronger evidence of app-driven activity.
  • Repeated unauthorised app authentication can strengthen a cloud-persistence finding.
  • Separate authentication, resource access and exfiltration into distinct evidence questions.

Module 13 — the investigation moves into the mailbox

Lesson 154 found the consent grant. Lesson 155 shows how to test whether the application exercised that access. Next, the cloud investigation pivots into Exchange Online, where a new inbox rule appears after the suspicious sign-in.

Next: Lesson 156 — A New Inbox Rule Appeared After the Sign-In.

Continue your KQL investigation training

Module 13 follows users, sessions, applications and data through Microsoft 365 and cloud services.

Related Agent Foskett Investigations

Continue investigating suspicious cloud identity, OAuth and application activity using evidence-led KQL hunting.

🔎 KQL Academy — Module 13: Advanced Cloud & SaaS Investigation

Following users, sessions, applications and data through Microsoft 365 and cloud services.

Investigate service principal sign-ins with KQL

Lesson 155 of the Agent Foskett KQL Academy uses Microsoft Sentinel and Microsoft Entra service principal sign-in telemetry to investigate application access after OAuth consent.

Investigate non-interactive Microsoft 365 application access

Learn how to identify service principal authentication, determine which resources an application targeted, correlate identity and workload evidence and distinguish application access from interactive user activity.