Nordray White Rabbit
Open source. MIT licence.

Keep your bunny.net API key out of CI/CD

Nordray White Rabbit keeps your bunny.net API key on a server. GitHub Actions and Forgejo Actions jobs identify themselves with their own OIDC token. They get short-lived credentials that can do only what you permit for that workflow.

Nordray logo: a white rabbit that jumps below the northern lights

Why

bunny.net has one API key for each account, and the key gives full control of the account. bunny.net does not supply OIDC login or keys with limited access.

If you put the key in a CI secret, each workflow has full control of your account. Each person who can change a workflow also has full control. With White Rabbit, a deploy job gets mc.read and mc.deploy for five minutes, and nothing more.

How it works

White Rabbit is a layer between your CI jobs and bunny.net. The rabbit command-line tool runs the official BunnyCLI through White Rabbit. BunnyCLI never sees the real key.

CI jobA GitHub Actions or Forgejo Actions job runs rabbit -- <bunny arguments>.
OIDC tokenThe job identifies itself with the OIDC token that the CI system issues.
White RabbitWhite Rabbit finds the workload binding, does the checks and adds your API key.
bunny.net APIsbunny.net receives only the permitted requests.
  1. You sign in one time

    rabbit auth login sends a one-time code of six digits to your email address. rabbit admin key set stores your bunny.net API key on the server, encrypted.

  2. You add a workload binding

    rabbit admin bindings add gives one workflow in one repository a set of capabilities. Only a person who is signed in can add a binding. CI jobs and repository content cannot.

  3. The CI job exchanges its token

    In CI, rabbit sends the OIDC token of the job to White Rabbit. Only a job that agrees exactly with a binding gets a session. A CI session is valid for 60 minutes or less.

  4. White Rabbit does a check of each request

    Each BunnyCLI call uses a virtual credential that is valid for five minutes. If an operation is not in the registry, the response is 404. If the capability is not in the binding, the response is 403.

  5. White Rabbit sends the request to bunny.net

    White Rabbit adds your bunny.net API key on the server and sends the request to api.bunny.net. The audit log records each decision.

In your workflow

There is no bunny.net secret and no White Rabbit secret in the repository. The job needs permission to get an OIDC token.

permissions:
  id-token: write   # Forgejo: enable-openid-connect: true

steps:
  - run: npm install -g @bunny.net/cli
  - run: curl -fsSL https://raw.githubusercontent.com/activout/nordray-whiterabbit/main/scripts/install-rabbit.sh | sh
  - run: rabbit -- apps deploy

The same rabbit -- … command operates at your own terminal. Thus an AI agent can use BunnyCLI and not see the key. rabbit --capabilities a,b -- … limits what the agent can do.

Security model

White Rabbit refuses each request that it does not know.

Deny by default

Each operation must be in a registry in the source code. A new endpoint needs a code review before it becomes available.

Exact workload bindings

A binding agrees with the issuer, the repository, the ref and the workflow exactly. Pull request events are never permitted.

Short-lived credentials

A virtual credential is valid for five minutes. White Rabbit stores only a SHA-256 hash of each session and each credential. You can revoke them at any time.

The key stays on the server

White Rabbit keeps the bunny.net API key encrypted in its database and adds it to outgoing requests. CI jobs and the CLI do not see the key.

Secrets in responses are removed

White Rabbit replaces container environment values and registry passwords with a placeholder before the caller sees them.

Sign-in allow-list

Only the email addresses and domains on the list can sign in. An empty list means that nobody can sign in.

Supported bunny.net APIs

Each area has its own capabilities. A workload binding gets only the capabilities that it needs.

AreaCapabilities
Magic Containersmc.read, mc.deploy, mc.env, mc.manage
Bunny Databasedb.read, db.manage, db.token
Pull Zonespullzone.read, pullzone.write
DNS Zonesdns.read, dns.write
Shieldshield.read, shield.write
Account and statisticsaccount.read, statistics.read

Run it

White Rabbit uses ASP.NET Core on .NET 11, YARP and libSQL. It operates as one container, for example on bunny.net Magic Containers with Bunny Database. The rabbit CLI is written in Go. The instructions are in the repository.

Get the source code on GitHub

Also from Nordray: Access

Nordray Access puts a login in front of your web application at the Bunny CDN edge. You do not change your application code.

Read about Nordray Access