← All posts

Investigation scenario: New SQLServer on an AWS Webserver

Updated 7 November 2026: I corrected the host telemetry and AWS guidance below. See the correction notes.

Context

Chris Sanders proposed on Twitter the following scenario:

One of your web servers hosted in the Amazon cloud launched a new process named sqlserver.exe. What do you look for to investigate whether an incident occurred?

Credit: https://twitter.com/chrissanders88/status/1628050893315899393

My investigation path

  • What is this executable?
  • Who dropped that executable?
  • How was this executable dropped?
  • Who is responsible for the execution of this file?
  • Any difference in handling in the AWS context?

What is this executable?

When I read SQLServer, I think automatically of Microsoft SQL Server. However, the official binary name is SQLSERVR.EXE (pay attention to the missing E) so it may be an attempt to masquerade a piece of malware… Or can it be a legitimate binary from a barely known company?

Before looking up its reputation, I would collect the full path, command line, parent process, execution account, and available hash. I would compare those with the software and deployment activity expected on this server.

Curiosity time

It would not change the course of the investigation, but first, I was curious to see if there was any tool signed with an “Original Name” of sqlserver.exe.

At the time of writing in March 2023, we had a local collection of VirusTotal metadata in Splunk. I queried it as follows:

search sqlserver.exe Signed  
| spath "additional_info.sigcheck.product" 
| spath "additional_info.sigcheck.verified"
| spath "additional_info.sigcheck.original name"
| spath "submission_names{}"
| search "additional_info.sigcheck.verified"=Signed
| search "additional_info.sigcheck.original name" = "sqlserver.exe"
| spath "md5"
| dedup "md5"
| table "md5" "additional_info.sigcheck.original name" "submission_names{}"

Two samples matched in that collection:

md5 original name submission_names
40593f27c042bf07c86a659b8745999d sqlserver.exe dhserver, sqlserver.exe, sqlserver.exe.E908FD29_F7EC_46D3_A5F5_ED4B563EB5AA
c6b9b0d924476e5154c1e49e4e1aa4f0 sqlserver.exe dhserver, sqlserver.exe, SqlServer.exe

The stored metadata identified both executables as signed by Unisys Corporation:

  sigcheck: {
       copyright: Copyright © 2016, Unisys Corporation, All Rights Reserved
       counter signers: COMODO SHA-1 Time Stamping Signer; UTN-USERFirst-Object; The USERTrust Network?
       counter signers details: [ [+]
       ]
       description: ODBC Data Access
       file version: 58.1.189.8008
       internal name: dhserver
       link date: 10:49 PM 7/12/2016
       original name: sqlserver.exe
       product: ODBC Access
       signers: Unisys Corporation; Symantec Class 3 SHA256 Code Signing CA; VeriSign
       signers details: [ [+]
       ]
       signing date: 10:53 PM 7/12/2016
       verified: Signed
     }

This gives us a possible legitimate explanation to check against the server’s software inventory. It is not an exhaustive list of legitimate executables. The query filters on the embedded OriginalFilename metadata, which can differ from the filename on disk, and only covers our historical collection. A familiar name or a valid signature does not establish that the execution was expected.

Hash reputation

If the alert, EDR, or Sysmon Event ID 1 provides a file hash, we apply the Triage Executable routine. Sysmon’s hash algorithms depend on its configuration. Native Security Event ID 4688 provides process creation context, but no executable hash. If necessary, collect the file and hash it, keeping in mind that the file on disk may have changed since the process started.

Data acquisition

Depending on the available means, we collect the executable:

  • If there is an EDR, we perform a file acquisition with it
  • Otherwise, if the file is on an EBS volume, we snapshot that volume and extract the binary from a volume restored from the snapshot.
  • If we must connect manually, we choose a method that avoids leaving reusable administrator credentials on the suspected host. This depends on the tool, logon type, and credential delegation, not just Kerberos versus NTLM. An ordinary RDP session can expose reusable credentials even when Kerberos is used.

For this scenario, we will assume that there is no evidence that the executable is legitimate. My next move is to understand how this binary was planted.

How was this executable dropped on disk? And by whom?

We need to understand how this executable ended up on the host. File creation information can be gathered from:

  • Sysmon Event ID 11 (FileCreate)
  • EDR Telemetry
  • Checking the Zone.Identifier Alternate Data Stream for download provenance, if present; its absence does not rule out an Internet download
  • MFT timestamps and file ownership as timeline clues, not proof of which person created the file

What if it was coming from the web server?

As we know that a web server is running, possibly over the Internet, it is possible that the executable was created following the exploitation of a vulnerable Web application:

  • Correlate requests around the file creation time with application and process telemetry. Where request sizes are logged, compare them with plausible upload sizes. Check the field’s meaning first: Apache’s mod_logio input count includes headers and can include TLS overhead, so it is not the executable’s size. Exploitation could also make the server download the file separately.
  • Use GreyNoise classifications to add context and prioritize requests. Do not discard an IP merely because GreyNoise has observed it scanning: widespread exploitation can be the entry point we are looking for.
  • Group requests by target URL and look for unusual resources or access patterns.

Investigation fallback

If the previous steps come back blank, we can also go the heavy way and build a timeline of the MFT and registry hives to get the activities observed in the timeframe of the file creation: It may lead, for example, to the discovery of a Windows Service registered around the file creation and so on.

We also need to identify the account and process involved: Which credentials were in use, and from where? An account name alone does not identify the person operating it.

Around the time of the file creation, we investigate:

  • Event ID 4624
  • RDP Connections:
    • Microsoft-Windows-TerminalServices-RemoteConnectionManager: Event ID 1149
    • Microsoft-Windows-TerminalServices-LocalSessionManager: Event 21

Who is responsible for the execution of this file?

Alongside the file creation investigation, we examine how the file was executed:

  • What is the parent process of sqlserver.exe?
  • Based on the registry timeline, can we spot the creation or modification of a Run key? Or a Windows Service?
  • Alternatively, we can use autoruns to spot new entries

We should also investigate the surrounding AWS environment; this does not need to wait until the host investigation is complete.

AWS Context

Exposed to the Internet

If the web application was exposed to the Internet, directly or through a load balancer or proxy, and compromise is suspected, I would hunt for webshells on the host. Being in a VPC with Internet connectivity alone does not tell us whether the application was reachable.

One of the most relevant resources in this endeavor is the “Mitigating Web Shells” strategy defined by the NSA and ASD teams: They describe Yara rules as well as detection heuristics.

IAM

Working with AWS is easy… once you understand IAM and its ramifications. I strongly recommend reading Effective IAM by Stephen Kuenzli to get a grasp on it.

For this EC2 investigation, I would look for two common sources of AWS credentials:

  • An IAM role supplied through an EC2 instance profile. Applications can obtain temporary credentials from the instance metadata service. AWS SDKs can retrieve and refresh them automatically. This avoids distributing long-term access keys, but an attacker able to obtain these temporary credentials may still use them while they remain valid. See IAM roles for EC2 applications.
  • Credentials stored by an application or operator. These may include an IAM user’s access key ID and secret access key, or cached temporary credentials. An IAM user’s permissions come from policies, including those inherited through groups. The user can separately be allowed to assume a role; creating an access key does not assign a role to that user.

Lambda also uses an IAM role, but it has an execution role, not an EC2 instance profile. These examples are not an exhaustive list of AWS authentication mechanisms.

Instance profile

To inspect the permissions available through the host’s instance profile:

  1. Check whether the EC2 instance has an instance profile.
  2. Retrieve the role contained in that profile.
  3. Retrieve all inline and attached managed policies for the role.
  4. Evaluate those policies together with the other applicable controls.

A single role policy is not a complete account of effective permissions. AWS policy evaluation also considers resource policies, permissions boundaries, session policies, and applicable Organizations controls. Conditions and explicit denies matter. For incident scoping, reconstruct the permissions at the time of the suspected activity where possible; the current configuration may have changed.

Get the instance profile

Let’s assume we know the instance ID of the compromised host. The identifiers and responses below are illustrative:

$ aws ec2 describe-instances                  \
        --region eu-west-1                    \
        --instance-ids i-01a840fe4d183f01b    \
        --query 'Reservations[*].Instances[*].IamInstanceProfile'
[
  [
    {
      "Arn": "arn:aws:iam::123456789012:instance-profile/foobar_instance_profile",
      "Id": "AIPAUYIIQRRERETH2BTWBT9"
    }
  ]
]
Get the role name
$ aws iam get-instance-profile                            \
        --region eu-west-1                                \
        --instance-profile-name foobar_instance_profile   \
        --query 'InstanceProfile.Roles[*].RoleName'
[
    "foobar_role"
]
Get the inline policy names

list-role-policies returns inline policies only:

$ aws iam list-role-policies --region eu-west-1 --role-name foobar_role
{
    "PolicyNames": [
        "foobar_policy"
    ]
}
Get each inline policy

Here is a simplified example allowing reads of two Secrets Manager secrets:

$ aws iam get-role-policy        \
        --region eu-west-1       \
        --role-name foobar_role  \
        --policy-name foobar_policy
{
    "RoleName": "foobar_role",
    "PolicyName": "foobar_policy",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": "secretsmanager:GetSecretValue",
                "Resource": "arn:aws:secretsmanager:eu-west-1:123456789012:secret:prod/foobar/ssl_certificate_key-abcdef"
            },
            {
                "Effect": "Allow",
                "Action": "secretsmanager:GetSecretValue",
                "Resource": "arn:aws:secretsmanager:eu-west-1:123456789012:secret:prod/foobar/deploy_keys-C4B23a"
            }
        ]
    }
}

Use the actual secret ARNs when reviewing a policy: Secrets Manager adds six random characters to the secret name in the ARN.

Get the attached managed policies

Even if the inline policy list is empty, the role may have managed policies. List them with list-attached-role-policies:

aws iam list-attached-role-policies --role-name foobar_role

For each returned policy ARN, use get-policy to find its DefaultVersionId, then get-policy-version to retrieve that version’s document. For example, if the returned version is v3:

aws iam get-policy \
    --policy-arn arn:aws:iam::123456789012:policy/foobar_managed_policy \
    --query 'Policy.DefaultVersionId' --output text
aws iam get-policy-version \
    --policy-arn arn:aws:iam::123456789012:policy/foobar_managed_policy \
    --version-id v3

The version and ARN are placeholders. Repeat this for every attached policy, then review the other applicable controls described above.

Credential use in CloudTrail

Investigate both the instance role’s temporary credentials and any other credentials found on the host.

In CloudTrail’s userIdentity fields, pivot on accessKeyId where present, principalId, the assumed-role session ARN, and sessionContext.sessionIssuer.arn. A role can be shared by multiple instances, so distinguish the relevant sessions and account for credential rotation.

Use sourceIPAddress as additional context, not the sole search criterion. Stolen credentials can be used from another host, and the instance may share a NAT egress address. Review the available events across relevant accounts and Regions, including attempts to assume other roles, read secrets, or change permissions. Check the logging coverage and retention before interpreting a lack of events as a lack of activity.

For each identity, distinguish what its permissions could allow from what the logs show it actually did. Follow any further role assumptions or retrieved credentials when assessing the extent of the compromise.

Lateral movement

If VPC Flow Logs were enabled for the relevant interfaces and period, use them to look for unexpected network activity from the compromised instance. They provide flow metadata, not packet contents or process identity, and do not capture every type of traffic. Correlate them with endpoint and destination logs before concluding that lateral movement succeeded.

Corrections — 7 November 2026

I corrected the guidance in the body of this post:

  • Scoped the two Unisys matches to the historical metadata collection, and separated process creation context from executable hashes.
  • Replaced the Kerberos-versus-NTLM shortcut with guidance based on logon type and credential delegation.
  • Qualified the file provenance, upload-size, and GreyNoise heuristics.
  • Distinguished EC2 instance profiles, Lambda execution roles, IAM users, and temporary credentials; added managed policies and effective-permission checks.
  • Corrected the CLI option and illustrative ARNs, and simplified the policy example to the two Secrets Manager reads.
  • Expanded CloudTrail scoping beyond the victim’s IP address and clarified the limits of VPC Flow Logs.

The original scenario, publication date, and historical sample metadata remain.