Restrict where policies come from
About 649 words
A tailnet policy decides who reaches what. Anyone who can get a kind: Tailscale entity into your catalog can add a grant to it. This guide limits where the kind may come from, and lists the other inputs worth guarding.
Allow the kind from one location
Catalog rules match an entity's origin location: the location that first discovered it. Register the directory that holds the policy as a location of its own, and allow Tailscale for that location only:
# app-config.yaml
catalog:
rules:
# The kinds every location may hold. Tailscale is not one of them.
- allow: [Component, System, API, Resource, Location, Group, User]
locations:
- type: url
target: https://github.com/acme/network/blob/main/tailscale/policy/*.yaml
rules:
- allow: [Tailscale]Then check two things:
- No global rule allows
Tailscale. Acatalog.rulesentry withallow: [Tailscale]lets every location register the kind. - No other location discovers the same files first: not a broader glob, not a
Locationentity, not a discovery provider that scans theacme/networkrepository. If one does, it becomes the origin, and its rules apply.
The catalog refuses a Tailscale entity from any other location.
Protect the directory
The location rule is only as strong as the repository behind it. Treat tailscale/policy/ like the policy file itself: require reviews on it, for example with a CODEOWNERS entry for the team that owns the tailnet, and protect the branch the location points at.
Know the other inputs
Tailscale entities aren't the only thing that changes the rendered file. These come from ordinary catalog entities, usually in many repositories:
| Input | What it can change |
|---|---|
specht-labs.de/tailnet-group on a Group | which Group's Users form a tailnet group |
spec.memberOf on a User, or a Group's members | who is in a tailnet group |
specht-labs.de/tailnet-login on a User | which login a user: reference and a group member render as |
specht-labs.de/tailnet-dst, -ports, -allow and -client-tag on an API | catalog grants to the API's destination, including to people named in tailnet-allow |
specht-labs.de/tailnet-src and consumesApis on a Component | catalog grants from the Component's tags |
dependsOn a kubernetes-cluster Resource | whether a consumption needs a grant at all |
specht-labs.de/tailnet-device-reason on a tag entity | whether a device destination is a warning |
Catalog grants only exist when the policy has catalogGrants: true, and they only reach destinations someone has put in an API's tailnet-dst. Still, anyone who can edit an API's annotations can grant access to its destination, and anyone who can edit a Component can claim a tag in tailnet-src and consume an API.
If that's more trust than you want, there are two places to stop it:
- Review the pull request. With
flow: pullRequest, nothing reaches the tailnet until someone merges Backstage's pull request in the policy repository. The pull request's description lists every problem, and the diff shows every grant that changed. - Leave
catalogGrantsoff and write every grant as an entity in the protected directory.
Limit where Backstage writes
tailscale.allowedRepos in app-config.yaml lists the only repositories Backstage writes a policy file to. A policy entity can name any repository in spec.publish, but Backstage won't publish to one that isn't on the list. Keep it to the policy repository, and give the GitHub App access to that repository only. Publish to GitHub has the permissions.
Who can read the policy
The backend reads the catalog with its own service credentials, so /api/tailscale/overview contains every policy, whatever catalog permissions the user who asks has. Any user who can call Backstage's backend can read the rendered policies, their groups and their members. If your policies shouldn't be visible to everyone with Backstage access, keep that in mind before you install the frontend.
