Safeguard
Security Guides•

Admission webhook matching gaps: matchPolicy and selectors

A webhook only protects what it matches. Equivalent matchPolicy, opt-in object selectors and namespace selectors can each leave a gap. Check them.

Safeguard Security Team
3 min read

A webhook protects only the requests it matches. Three settings decide that: matchPolicy, objectSelector and namespaceSelector. Used carelessly, each can leave a way around your rule. Review them whenever you rely on a webhook for security, and again after each change to its configuration.

matchPolicy: Exact or Equivalent

The docs say matchPolicy defines how a webhook's rules match incoming requests. Allowed values are Exact and Equivalent. Exact intercepts a request only if it exactly matches a rule. Equivalent intercepts a request if it modifies a resource listed in the rules, even through another API group or version.

Equivalent is recommended, and it is the default. Why it matters: the same Deployment can be reached through more than one API version. A rule written for one version should still catch the others.

If you see Exact in a security webhook, ask why.

objectSelector: opt-in only

A webhook can limit which requests it sees by the labels of the object. The docs evaluate the selector against both the new and old object, and a match on either counts.

The warning is the important part: use the object selector only if the webhook is opt-in, because end users can skip the webhook by setting the labels. If your rule is a security control, do not select on a label that a user controls. An attacker who can create the object can leave the label off.

namespaceSelector: scoping by label

For namespaced resources, a webhook can limit requests by the labels of the containing namespace. The docs note that for cluster-scoped resources other than Namespace itself, the selector has no effect.

Gap one: namespaces that lack the label are skipped. Gap two: someone who can patch Namespace objects can change labels. The RBAC good practices page makes the same point for Pod Security admission, noting that users who can patch Namespaces can modify labels, and may configure a more permissive policy than intended.

A review checklist

  1. Which rules and operations does each security webhook list? Include UPDATE, not only CREATE.
  2. Is matchPolicy Equivalent?
  3. Does any selector use a label that users control?
  4. Which namespaces are excluded, and why? Document each exclusion.
  5. Who can patch namespaces or edit webhook configurations?

Testing

Try to get past your own rule. Create a test object in a namespace the selector excludes, or with the opt-out label, and confirm what happens. Keep the test in a non-production cluster and record the result as evidence.

Where Safeguard fits

Safeguard cannot see your webhook configuration. It can enforce policies and gates on the manifests in your repositories, and compliance evidence automation can hold your review record.

Why this keeps happening

Selectors are often added to cut noise or to speed up a rollout, and the reason is forgotten later. Add a comment or annotation next to every exclusion in the configuration, with an owner and a date, so the next reviewer can tell a deliberate carve out from an accident.

Quick check

Is objectSelector a safe way to scope a security webhook?

Only if the webhook is opt-in. The docs warn that users can skip it by setting the labels.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.