Skip to content
Access control Write-up Intermediate

Hijacking SQL Server Credentials using Agent Jobs for Domain Privilege Escalation

A user with sysadmin rights on a SQL Server instance can abuse existing credential objects and proxy accounts to execute code as the credential's user, without knowing the password or having local admin rights. This allows privilege escalation from a limited SQL Server service account to a local or domain user.

Scott Sutherland Follow

Published on netspi.com

Technical / Network Pentesting

Scott Sutherland, on netspi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the design of SQL Server credential objects and proxy accounts allows anyone with sysadmin privileges to create a proxy and run agent jobs under the stored credential's context without knowing the password.

Impact

An attacker with sysadmin on the SQL Server could execute code as the credential's user, potentially escalating to local administrator or domain user privileges, though this requires that such credentials already exist and the attacker has sysadmin access.

What the attacker needed

Sysadmin access on SQL Server; existing credential object configured; SQL Server Agent running

The fix

Restrict sysadmin privileges and monitor the creation of proxy accounts and their assignment to subsystems.

How it was found

  1. Log into the SQL Server instance and verify sysadmin access.
  2. List existing credentials on the instance.
  3. List existing proxy accounts tied to credentials.
  4. Create a proxy account for the target credential and grant it the CmdExec subsystem.
  5. Create an agent job that uses the proxy to run a command, and schedule it.
  6. Execute the job and confirm the command ran as the proxy user.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

SQL Server can store usernames and passwords in 'credential objects' so that scheduled tasks (agent jobs) can run as other users. If an attacker already has full control of the SQL Server (sysadmin), they can create a proxy that uses an existing credential and then run a job as that user, without ever seeing the password. This means a compromised database server can lead to wider Windows or domain access.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.