// Metabase Exploit Tooling with Bun · Part 1

Setup & Recon

Stand up a Metabase lab in Docker, wire up a Bun + TypeScript project, and write your first tool — a version fingerprinter that reads Metabase's unauthenticated properties endpoint and decides whether the target is in range for CVE-2023-38646.

TypeScriptBunReconMetabase
4 min read

This series builds a Metabase vulnerability scanner one piece at a time, in TypeScript on Bun. By the end you’ll have a single CLI that fingerprints a Metabase instance, pulls its pre-auth setup-token, and confirms CVE-2023-38646 through the same H2 injection walked solve-style in the Analytics writeup — reusable tooling, not a one-off payload.

This first part sets up the lab and the project, then writes the smallest useful tool: a version fingerprinter.

The lab

We target a Metabase we run ourselves. Metabase ships as a Docker image, and v0.46.6 is in the vulnerable range — the same version Analytics ran:

$ docker run -d --name metabase-lab -p 3000:3000 metabase/metabase:v0.46.6

Give it a minute to boot — the container initializes an internal H2 database on first run — then confirm it answers:

$ curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/api/health
200

A 200 means the app is up. Leave the container running; every tool we build points at http://localhost:3000.

The project

Bun gives us a TypeScript runtime, a package manager, and a test runner in one binary — no tsc, no bundler, no ts-node. Create the project:

$ mkdir metabase-tool && cd metabase-tool
$ bun init -y

bun init drops a package.json, a tsconfig.json, and an index.ts. We run .ts files directly — bun run recon.ts — so there’s no build step between editing and running.

The first request

Metabase exposes an unauthenticated endpoint, /api/session/properties, that returns a large JSON blob of client settings. Two of its fields matter to us: the version, and (before setup is finished) the setup-token. We’ll take the version now and come back for the token in Part 2.

Create recon.ts. Bun implements the standard fetch, so the request is one call:

const BASE = process.env.TARGET ?? "http://localhost:3000";

interface SessionProperties {
  version?: { tag?: string };
  "setup-token"?: string | null;
}

async function fetchProperties(base: string): Promise<SessionProperties> {
  const res = await fetch(`${base}/api/session/properties`);
  if (!res.ok) throw new Error(`${base} returned HTTP ${res.status}`);
  return (await res.json()) as SessionProperties;
}

The interface describes only the shape we care about — fetch hands back any, and the cast pins it to something typed so the compiler catches a typo like props.verison. Reading the target from TARGET means the same tool works against any host without editing code.

Reading the version

The version lives at version.tag, a string like "v0.46.6". Pull it, fall back to "unknown" if the field is missing, and print it:

const props = await fetchProperties(BASE);
const version = props.version?.tag ?? "unknown";
console.log(`Metabase version: ${version}`);

Run it:

$ bun run recon.ts
Metabase version: v0.46.6

One unauthenticated request, and we know exactly what we’re up against.

Is it vulnerable?

CVE-2023-38646 was patched in 0.46.6.1 on the open-source line; anything released before that is exploitable. To decide automatically, turn the tag into a list of numbers and compare it, component by component, against the patched release:

// Patched in 0.46.6.1 (open-source); earlier builds on the line are vulnerable.
const PATCHED = [0, 46, 6, 1];

function parseTag(tag: string): number[] {
  return tag.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
}

function isBefore(a: number[], b: number[]): boolean {
  for (let i = 0; i < Math.max(a.length, b.length); i++) {
    const x = a[i] ?? 0;
    const y = b[i] ?? 0;
    if (x !== y) return x < y;
  }
  return false;
}

parseTag strips the leading v and splits on dots, so "v0.46.6" becomes [0, 46, 6]. isBefore walks both lists in step, treating a missing component as 0, and returns on the first pair that differs — so [0, 46, 6] is before [0, 46, 6, 1]. Wire it into the output:

const vulnerable = version !== "unknown" && isBefore(parseTag(version), PATCHED);
console.log(`CVE-2023-38646: ${vulnerable ? "VULNERABLE" : "not in range"}`);
$ bun run recon.ts
Metabase version: v0.46.6
CVE-2023-38646: VULNERABLE

Enterprise builds carry a 1.x.y tag instead of 0.x.y; we’ll normalize that edge when we harden the tool in Part 5. For the lab — and for Analytics — the open-source check is all we need.

Where we are

The tool makes one unauthenticated request and reports the version and whether it’s in range for the CVE. That’s recon: cheap, safe, and decisive before you touch anything else. Part 2 goes back to the same endpoint for the field that turns a version number into an exploit — the setup-token.

← All parts