Skip to content

[Submission] Internet facing exploit followed by webshell execution and privileged account creation - #94

Open
cql-hub-submission-bot-v2[bot] wants to merge 1 commit into
mainfrom
submission/Internet_facing_exploit_followed_by_webshell_execution_and_privileged_account_cr
Open

cql-hub-submission-bot-v2[bot] wants to merge 1 commit into
mainfrom
submission/Internet_facing_exploit_followed_by_webshell_execution_and_privileged_account_cr

Conversation

@cql-hub-submission-bot-v2

Copy link
Copy Markdown

Automated PR from a submission on byteray.com/cql-hub-contribute.

Query: Internet facing exploit followed by webshell execution and privileged account creation
Submitted by: @Subhomoy21(https://github.com/Subhomoy21)
Tags: Hunting, Monitoring, Detection
MITRE: T1190, T1136
Log sources: Endpoint, Network, Identity
Falcon modules: Identity
Submission ID: 6b0d958a85e283c094a76525

Please review the query logic, test it, and merge or request changes.

@dweissbacher

Copy link
Copy Markdown
Collaborator

Hi @Subhomoy21, thanks for this!

Unfortunately the CQL doesn't parse in its current form, and it looks like something got mangled on the way into the form (a ) where a ] belongs, 25 where ?$ would be, fevent_simpleName, spaces inside field names). Could you paste the exact version that runs in your tenant? Along with that, a few things we'd like changed:

  1. Syntax: the Vendor filter needs to move inside Perimeter: { … }, that block needs its closing },, and the coalesces should read coalesce([a, b, c], as=x). Other fixes: #event_simpleName=ProcessRollup2, corr_host, within=30m, and no / inside the regex alternation (it ends the regex).

  2. Two regexes let the wrong things through: ^(deny denied block|blocked|reset) $ should be ^(deny|denied|block|blocked|reset)$, otherwise blocked attacks pass the filter. (w3wp|…) (\.exe)? has a space before .exe, so it never matches w3wp.exe. I'd also drop the FileName= branch: the web server is the parent of the shell, so ParentBaseFileName alone is the right check.

  3. Linking the WAF to the server: in most WAF logs, server.address / destination.address / server.domain hold the public IP, VIP or site FQDN, while ComputerName is the server's short name, so stage 1 → 2 will rarely match. Which field in your WAF data holds the backend server's hostname as Falcon knows it? Please mention it in the explanation.

  4. Vendor placeholder: no parser sets Vendor="WAF". Could you turn it into a parameter (#Vendor=?perimeter_vendor) and explain in the text what to fill in? Also, does your WAF parser set event.category to threat? Many use intrusion_detection or web.

  5. Account stages: the SID comparison is case-sensitive, and Windows logs S-1-5-32-544 in upper case. windows.Computer is an FQDN, so it won't equal ComputerName either. The simplest fix is to use the sensor's own UserAccountCreated / UserAccountAddedToGroup events, which need no Windows log ingestion and can be joined on aid and UserRid. Here's a starting point for the whole query:

    correlate(
      Perimeter: {
        #Vendor=?perimeter_vendor
        | event.category[0]="threat"
        | coalesce([event.action, Vendor.action, Vendor.attackData.appliedAction], as=perimeter_action)
        | perimeter_action!=/^(deny|denied|drop|dropped|block|blocked|reset)$/i
        | coalesce([server.address, server.domain, destination.address, destination.domain, host.name, Vendor.httpMessage.host], as=corr_host_raw)
        | lower(corr_host_raw, as=corr_host)
        | corr_host=*
      },
      WebShell: {
        #event_simpleName=ProcessRollup2
        | ParentBaseFileName=/^(w3wp|java|php-cgi|httpd|nginx)(\.exe)?$/i
        | CommandLine=/(powershell|cmd\.exe|whoami|certutil|curl|wget|net1?(\.exe)?\s+(user|localgroup))/i
        | lower(ComputerName, as=corr_host)
        | corr_host <=> Perimeter.corr_host
      },
      AccountCreated: {
        #event_simpleName=UserAccountCreated event_platform=Win
        | aid <=> WebShell.aid
      },
      PrivilegeGranted: {
        #event_simpleName=UserAccountAddedToGroup event_platform=Win
        | GroupRid=/^(0*220|544)$/   // BUILTIN\Administrators, RID 544 (0x220) - check the format in your tenant
        | aid <=> AccountCreated.aid
        | UserRid <=> AccountCreated.UserRid
      },
      sequence=true, within=30m, includeMatchesOnceOnly=true
    )
    
  6. Metadata: nothing here uses Falcon Identity Protection, so the module should be Insight (and the log sources Endpoint + Network). I'd also drop the Monitoring tag, since that's for inventory-style queries, and fix the double space in the name.

  7. Explanation: please add what telemetry is needed (a WAF/NGFW connector plus Falcon endpoint data), the false positives you've seen (Java application servers that legitimately spawn shells, admin portals that provision local users), and how to tune them.

Once we have a version that runs in your tenant, I'm happy to apply the metadata and wording fixes on merge myself if you'd rather. Thanks again for contributing!

@dweissbacher dweissbacher self-assigned this Dec 2, 2026
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.

1 participant