Building vquery: how AI helped us secure ESXi
In six weeks, one engineer working with an AI coding agent built vquery: agentless security for VMware ESXi and vCenter, now watching every real vCenter in our lab. This post covers what it does, how the AI helped build
In six weeks, one engineer working with an AI coding agent built vquery: agentless security for VMware ESXi and vCenter, now watching every real vCenter in our lab. This post covers what it does, how the AI helped build it, and what it found.
The blind spot
ESXi hosts are where the VMs run, yet they rarely get the scrutiny a laptop or a cloud account gets. You can't install an agent on them, so they stay out of view.
Our own lab showed the problem. Under three real vCenters we had 37 ESXi 6.7 hosts, a release that is out of support. Scripts logged in as root so often that the first pull from each vCenter hit our 200,000-event cap, almost all of it root and DCUI logins and logouts. Nobody had been looking, because nothing was set up to look.
What vquery is
vquery reads everything it needs from the vCenter APIs, with a read-only account, so there is nothing to install on ESXi. It pulls inventory, settings, permissions and events, streams them through Kafka, and stores them in ClickHouse for fast SQL.
It answers the questions a security team and the people who run vSphere ask every week:
| Area | The question it answers | What ships with vquery |
|---|---|---|
| Vulnerabilities | Which hosts, vCenters and VMs run builds with known CVEs, and which of those are being exploited? | A catalog of 53 CVEs across vCenter, ESXi and VMware Tools. Exploited flags come from CISA's Known Exploited list and refresh from the internet with one click. |
| Compliance | Does each host, VM and vCenter meet the hardening standard we follow? | 10 standards and 989 checks: CIS ESXi 6.5 to 8, DISA STIG vSphere 7 and 8, and VMware's Security Configuration Guides 6.7 to VCF 9.1 |
| Exposure | Which hosts are the easiest way in? | Hosts ranked on exploited CVEs, SSH and Shell, lockdown mode, failed checks and alerts, each with its fix |
| Risk | Which assets matter most right now, and why? | 45 risk factors combined into one score per asset, which shows the factors behind it |
| Detections | Is anyone attacking us right now? | 47 rules over vCenter events, mapped to MITRE ATT&CK, plus baselines that flag unusual hours |
| Attack chains | Do separate alerts add up to one attack? | 10 playbooks, such as ESXi ransomware preparation and hypervisor backdoor, with blast radius and response steps |
| Identity | Who can do real damage? | Who can delete VMs, open consoles or run commands in guests; admin rights given to individuals; unused rights; password guessing |
| Host software | Has anything been planted on the hypervisor? | Every installed package (VIB) on every host: look-alikes, unsigned ones, recent additions, and hosts that differ from their cluster |
| Change and drift | What changed, and when? | Full history of every object, a timeline per asset, "compare with a date", and hosts that drift from their cluster |
| Operations | Is the estate healthy, backed up and right-sized? | Performance ("why is it slow?"), cluster health from 9 checks, backups, a maintenance and upgrade planner, and capacity to reclaim |
| IT Help and Ask | Can I just ask? | 199 ready-made questions in 16 tabs, a plain-English Ask box, and a daily report sorted into Fix now, Fix soon, Plan and Housekeeping |
| Reporting | How does the team hear about it? | A weekly digest and a Jira ticket from any finding, with the evidence attached |
Nothing is hard-coded. Every page has a Setup tab where a team switches rules off, changes weights and thresholds, or adds its own, then previews the effect on every vCenter before saving.
Every stage is its own small service, 13 in all. Each can be stopped, replayed or scaled without touching the others.
Data only flows one way, from vCenter to the UI. Each processing app reads its own Kafka topics and writes its results back to Kafka, where ClickHouse picks them up.
How a customer uses it
A customer points vquery at their vCenters, and the findings appear after the first pull.
- Install vquery on one Linux server with Docker. Each piece starts from its own Docker Compose file, and one settings file holds the site's own values: its address, public URL and login realm.
- Connect sign-in to whatever the company already uses: vquery's own users, Google, any SAML or OIDC single sign-on (Okta, Entra ID, ADFS) or LDAP and Active Directory. People get one of two roles: a viewer sees everything and changes nothing, and an administrator can also change vquery.
- Add vCenters on the vCenters page with a read-only account. vquery tests the connection before saving and encrypts the password, which is never shown again.
- Let it pull. Events sync every 15 minutes, a delta pull runs every few hours, and a full pull runs on a longer cycle. Pulls are paced so a busy vCenter isn't overloaded.
- Read the findings on the pages: vulnerabilities, compliance, exposure, risks, detections, attack chains and drift. Every list can be filtered, opened down to one asset and taken back in time.
- Act on them. Raise a Jira ticket from a finding, get the weekly digest and the daily summary reports, or ask in plain English ("which hosts have SSH enabled?"). vquery itself never writes to vCenter.
Built for production
A security tool that loses data or goes down quietly is worse than none, so most of the engineering went into what happens when things fail.
| Concern | How vquery handles it |
|---|---|
| A program crashes mid-batch | Each app commits its place in Kafka only after its output is safely written, so it resumes exactly where it stopped. We killed an instance during a full pull: of 3,972 VM rows, none was duplicated or missing. |
| Load and failover | Every app runs as two instances. Kafka splits the work between them, and Redis leases stop a stalled instance from overwriting newer data. |
| An app is up but stuck | A watchdog checks every app's health and restarts the ones that stopped working. It also watches Kafka lag, disk, memory, the clock and vCenters that went quiet. |
| Who can see and change what | Every API call needs a login, except the health check. Viewers can't change anything. A test classifies every API route, so a new one can't slip through unguarded. |
| Services on the network | Kafka asks every client for a login, and each service may use only its own topics. The query runner answers only the API server. Checks after every deploy call both with no credentials and fail if either answers. |
| Secrets | Every password is random, made at install and kept in one file on the server, never in git. vCenter passwords are encrypted, and the key never leaves the server. |
| Correct answers | The vulnerability matcher agrees with Mirage's answer key on all 68,946 findings. The compliance checks agree on all 349,809 rule results for one simulated vCenter. |
| Upgrades | Setup changes only what differs: Kafka topics, the configuration database (through numbered migrations), users and permissions. Running it again with nothing new changes nothing. |
A tour of the product
Every page answers one question at a glance, then lets you drill down to the asset, its history and the evidence. A selector at the top narrows any page to one vCenter. These screenshots are from our lab: 8 vCenters, 1,214 ESXi hosts and about 25,000 VMs, real and simulated. IP addresses and account names are blurred.
Overview: the whole estate on one screen
Counts of vCenters, hosts and VMs, one sentence on what matters now, and the top insights. Known-exploited vulnerabilities come first, then hygiene such as outdated VMware Tools or disconnected hosts.
Vulnerabilities: what to fix first
Open findings, critical ones, those on CISA's exploited list, exposed VMs and those with a fix available, plus the trend of new versus closed. The exploited-CVE table shows each flaw's impact, how many hosts it touches and which build fixes it.
Compliance: ten standards, one score each
A pass rate for each standard, the trend of checks that started failing or passing, and a click-through to every rule and every asset that fails it.
Exposure: fix these first
Hosts ranked by how easy they are to break into. A host with an exploited CVE, SSH on and lockdown mode off goes to the top, with the patch that closes it.
Risks: one score, with the reasons
Findings, exposure, identity and configuration combine into one score per asset, grouped into domains such as runtime and identity. Each top asset lists exactly which factors put it there.
Detections and baselines: is anyone attacking us?
Alerts per day by severity, the MITRE ATT&CK techniques behind them, and each alert with its evidence. The Baselines tab learns what is normal for each vCenter at each hour and flags what isn't.
Attack chains: alerts that add up to an attack
Ten intrusion playbooks, each matched step by step against detections by the same person or on the same host. A chain shows the stages it walked, its blast radius and the response steps.
Identity: who could do real damage
Accounts, roles and permissions turned into plain findings: administrator rights given to a person rather than a group, rights never used, service accounts used in a browser, and logins that never succeed.
Host software: where hypervisor backdoors hide
Every package installed on every host, flagged when it is a look-alike, unsigned, added recently, or present on only some hosts of a cluster.
IT Help: the data center's weekly questions, one click each
199 ready-made questions in 16 tabs, from "which datastores are below 20% free?" to "which host certificates expire within 90 days?". Each answers across every vCenter at once, can be edited, and can raise a Jira ticket with the evidence.
Summary reports: a review every morning
At 06:00 UTC vquery runs every question against each vCenter and writes a report in four priorities: Fix now, Fix soon, Plan and Housekeeping. A calendar marks the days with Fix now findings, and each report shows what is new and what was fixed since yesterday.
Planner: can this host go into maintenance?
For any host: will its VMs move, is there room for them elsewhere, and what would an upgrade to ESXi 8.0 need, including unsupported hardware and old packages.
Drift: hosts that differ from their cluster
Each host's settings compared with its cluster's golden value, such as the ESXi build or lockdown mode, so one forgotten host stands out.
Reclaim: capacity you can win back
Powered-off, orphaned, unused and oversized VMs, old snapshots and unused templates, with the storage, vCPUs and memory each would free. It exports to CSV.
Backups: which VMs have no recent backup
Backup tools found by their accounts and logins, and each VM's newest backup snapshot, so unprotected VMs show up per vCenter.
Weekly digest: the week for the whole team
Critical detections, attack chains, exposure, vulnerabilities and compliance, and changes and logins for the week, built every Monday and raised as a Jira ticket.
Events and Investigate: dig as deep as you need
Every vCenter event, searchable by type, user and severity, with a link to what changed. Investigate runs your own read-only SQL over every table, with ready-made starting points.
vCenters: add one in a minute
Add a vCenter with a read-only account, test the connection, and see each one's pull status and the schedule for the next 24 hours.
How the AI helped build it
The split was simple: the human set the goal and made the calls, and the AI did the building. From 10 October to 18 November that came to 296 commits across Mirage and vquery. vquery alone is 16 Go programs (about 35,000 lines), 163 test functions and 54 UI components.
First, a fake vCenter to test against
Testing security code on production vCenters is slow and risky, and you can't make a real one misbehave on demand. So before vquery, the AI built Mirage, a simulator that serves five vCenters (6.7, 7.0, 8.0 twice and 9.1), each on its own IP and speaking the real SOAP and REST APIs.
To keep it honest, the AI copied the real event catalogs from our lab's ESXi 6.7 hosts and vCenter 8.0.3, about 2,200 event types, using read-only access. It also generated the API shapes from VMware's own SDK bindings. Mirage knows which settings and CVEs each simulated vCenter has, so every vquery result can be checked against that answer key.
Then, the real thing
The real lab vCenters came next: 8.0.3 with 3 hosts, 8.0.2 with 33 hosts and about 495 VMs, and a third 8.0.3. Their passwords are encrypted on the vquery server, and the key never leaves it. Where real vCenters behaved differently from Mirage, the AI wrote the gap down and fixed both sides.
Every change goes through the same loop
- The human states what's needed, often in one sentence ("vCenters are configured from the UI").
- The AI writes the code, the tests and the design notes together.
- Pre-commit checks run, then the change is pushed to
main. - A deploy script installs that exact commit on the server.
- Live checks run: calls from outside the server, plus 29 browser page checks. A failure stops the deploy.
The design docs are part of each change rather than an afterthought. The Kafka doc lists every topic, writer and reader, and the AI updates it in the same commit that changes them.
What it found in our own lab
Pointed at our three real vCenters, vquery found that 37 of 38 ESXi hosts run an out-of-support release, and every one of them has lockdown mode off. These figures were read from the vquery server on 1 December 2026; they cover 38 hosts and 552 VMs.
| What vquery checked | Result |
|---|---|
| ESXi versions | 37 hosts on 6.7.0 (builds 14320388 and 13006603), 1 host on 8.0.3 |
| Lockdown mode | Off on all 38 hosts |
| Flaws on CISA's Known Exploited list | 12 CVEs, across ESXi, VMware Tools and vCenter |
| Most widespread exploited flaw | CVE-2025-22224 (CVSS 9.3, VM escape), found on 593 assets |
| Compliance checks | 12,736 pass and 22,591 fail, so 36% pass |
| Detections | 309 alerts: 26 high, 269 medium, 14 low |
The alerts were real activity, not noise from the tool. The top ones were host firewall changes, permission and role changes, commands run inside VMs, SSH sessions opened on hosts, and the ESXi Shell being turned on.
The IT Help report on the 8.0.2 vCenter (33 hosts) took about 15 seconds. It sorted the work into 9 Fix now, 16 Fix soon, 17 Plan and 18 Housekeeping items. That matched the review we had written by hand earlier.
When the security tool had holes of its own
A security tool has to be secure itself. In November, an AI code review of a different project flagged vquery's query runner. We checked it, and the finding was real.
The query runner (port 8071) ran any SQL it was sent, with no login. A single curl from anywhere on the lab network could query all 71,066 VMs vquery tracks.
We asked the AI to confirm it, then look for anything else like it. It ran four scanners over the code (gitleaks, govulncheck, gosec and osv-scanner) and also read the code for services listening with no login. The worst find was Kafka. Anyone on the network could list all 51 topics, read every record, and write fake ones that vquery would have believed.
The fix shipped in one commit and was live the same day:
- Kafka asks every client for a login. Each service has its own user (SCRAM-SHA-512, so passwords never cross the network). Each user may touch only its own topics: the puller can only write raw data, ClickHouse can only read results, and the watchdog can only see lag.
- The query runner answers only the API server, which proves itself with a shared secret.
- The install script creates the new passwords and permissions on its own, and running it again changes nothing.
- Two new checks run after every deploy. They call Kafka and the query runner from outside with no credentials, and the deploy fails if either answers.
After the deploy, the original curl got HTTP 401, and a Kafka listing with no login showed 0 topics. All app containers stayed up with no restarts, and ClickHouse kept up with Kafka (0 lag).
One gap remains: Kafka traffic is still not encrypted. Passwords are safe, but the records could be read by someone listening on the lab network. Turning on TLS needs certificates, and it's the next step.
What we learned
The AI made us fast. Speed alone wasn't what made it safe; the guardrails around the AI did that.
- Build the test bed first. Mirage let the AI try every change against five vCenter versions before it touched a real one. Building it took days and has repaid that many times over.
- Ground the AI in real data. Event catalogs copied from real hosts and API shapes generated from VMware's SDK kept the simulator from drifting into fiction.
- Make checks the gate, not a suggestion. Every deploy runs live checks, and a failure stops it. The Kafka fix added two checks of its own, so that hole can't quietly come back.
- Let one AI review another's work. The query runner hole was found by an AI review of a different codebase. A second set of eyes, even an automated one, catches what the builder assumed was safe.
- Keep the human on the decisions. Which vCenters to touch, where passwords live, and what counts as done were the human's calls. The AI did the work in between.
What's next
- Encrypt Kafka traffic with TLS.
- Add a login to the Mirage console.
- Narrow the read-only database user to vquery's own tables.
- Extend the vulnerability catalog as Broadcom publishes new advisories, and turn the IT Help reports into tickets automatically.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.



















