--- title: "ADR 0055: Only provider-authenticated requests may add a trusted host" --- * Status: accepted * Code: [`pkg/hostpolicy/hostpolicy.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/hostpolicy/hostpolicy.go) ## Context In controller managed mode a default install needs no configuration because hosts are learnt from requests. Writing to the ConfigMap changes a security policy, so the question is which requests may do it. ## Decision * `Trusted` never writes. It is the function for every path the provider has not authenticated, and for paths authenticated by a secret a tenant controls, such as a per-Repository webhook secret: letting those record a host would give any namespace user a write primitive on the controller-wide policy. * `TrustOnFirstUse` is called only after the provider authenticated the request with a credential the controller owns, for instance the GitHub App webhook secret. * `TrustOnFirstUse` appends to the annotation (`append(slices.Clone(policy.autoTrusted), canonical)`) and never replaces it, so a controller serving several instances or providers learns all of them instead of being pinned to the first sender. * In administrator configured mode it only calls `check` and writes nothing. * Public hosts are not recorded: they are trusted while the policy is controller managed, and recording them would make a stock install fight its GitOps reconciler over an unneeded value. * Hosts for which `vcshost.IsPrivate` is true are refused with `reasonPrivate`, so a payload cannot point the controller at an in-cluster or cloud-metadata address. An administrator can still list one explicitly. * The update runs inside `retry.RetryOnConflict` and re-reads the ConfigMap on each attempt. * `logPolicyChange` logs a warning with the new list and the key to set to take the policy over, so an administrator can see when and to what the policy changed without diffing the ConfigMap. It is skipped when `run.Clients.Log` is nil. ## Consequences * A new caller of `TrustOnFirstUse` on an unauthenticated or tenant-authenticated path breaks the model; no code check enforces this. * Learned hosts persist in an annotation that GitOps tooling may see. * Private hosts must always be configured by an administrator.