Skip to content
CVE IDCVE-2026-61795GitHub advisory IDGHSA-f94q-w3w8-cj67

Capsule: hostnameRegexHandler.OnUpdate validates stale (old) Tenant regex, allowing invalid AllowedHostnames regex to bypass webhook validation

CVE-2026-61795 (GitHub advisory GHSA-f94q-w3w8-cj67) is a medium-severity vulnerability with a CVSS 3.1 base score of 6.8, classed as Incorrect Comparison (CWE-697), in github.com/projectcapsule/capsule (Go). Affected versions: >= 0.13.0, < 0.13.7. It is fixed in 0.13.7.

Medium6.8Fix availableGitHub reviewed

Published 18 Sept 2026Updated 18 Sept 2026

6.8MediumCVSS 3.1
EPSS
0.32%higher than 26% of CVEs
Weakness (CWE)
KEV status
Not in KEV
Published
18 Sept 2026
Updated
18 Sept 2026
Ecosystem
  • Go
Assigned by (CNA)
GitHub_M

Summary

Source: OSV (GitHub advisory)

A parameter order bug in internal/webhook/tenant/validation/hostname_regex.go causes the hostnameRegexHandler.OnUpdate webhook to validate the old Tenant object's AllowedHostnames.Regex instead of the new one being submitted. This allows an invalid (malformed) regex to bypass admission validation and be persisted to etcd, causing a Denial of Service for all Ingress operations within the affected tenant.

Details

The TypedHandler[T] interface defines OnUpdate as:

// handlers.go
OnUpdate(c client.Client, reader client.Reader, obj T, old T, decoder admission.Decoder, recorder events.EventRecorder) Func
//                                               ^^^ NEW  ^^^ OLD

The dispatcher in handler.go:93 calls:

hndl.OnUpdate(c, reader, tnt, old, decoder, recorder)
//                        ^^^ NEW  ^^^ OLD

However, hostnameRegexHandler.OnUpdate in hostname_regex.go declares its parameters in reversed order:

// hostname_regex.go (BUGGY)
func (h *hostnameRegexHandler) OnUpdate(
    _ client.Client,
    _ client.Reader,
    old *capsulev1beta2.Tenant,   // ← receives NEW tenant (mislabeled as old)
    tnt *capsulev1beta2.Tenant,   // ← receives OLD tenant (mislabeled as tnt)
    ...
) handlers.Func {
    return func(...) *admission.Response {
        if err := h.validate(tnt, req); err != nil { // ← validates OLD, not NEW
            return err
        }
        return nil
    }
}

All 11 other handlers in the same package declare (tnt, old) correctly. hostname_regex.go is the only one with the swap.

As a result, when a Cluster Admin updates Tenant.Spec.IngressOptions.AllowedHostnames.Regex to a malformed value, the webhook compiles the previous valid regex and returns Allow. The malformed regex is then written to etcd.

Subsequently, every Ingress CREATE or UPDATE in that tenant triggers validate_hostnames.go:160:

matched, _ = regexp.MatchString(allowedRegex, currentHostname)

regexp.MatchString with an invalid pattern returns (false, error). The error is silently ignored, matched is false, and every hostname is rejected — blocking all Ingress operations in the tenant until the Tenant object is manually corrected by an admin.

PoC

//go:build ignore
// Standalone reproducer for hostname_regex.go argument swap bug in Capsule
// No external deps - shows the bug logic using only stdlib

package main

import (
	"fmt"
	"regexp"
)

// Simulating the Tenant spec structure
type AllowedHostnames struct {
	Regex string
}

type IngressOptions struct {
	AllowedHostnames *AllowedHostnames
}

type TenantSpec struct {
	IngressOptions IngressOptions
}

type Tenant struct {
	Name string
	Spec TenantSpec
}

// =========================================================
// BUGGY implementation (hostname_regex.go as-is)
// OnUpdate(_, _, old *Tenant, tnt *Tenant) → validates OLD
// =========================================================
func hostnameValidate(tnt *Tenant) error {
	if tnt.Spec.IngressOptions.AllowedHostnames == nil {
		return nil
	}
	if len(tnt.Spec.IngressOptions.AllowedHostnames.Regex) == 0 {
		return nil
	}
	_, err := regexp.Compile(tnt.Spec.IngressOptions.AllowedHostnames.Regex)
	if err != nil {
		return fmt.Errorf("Deny: unable to compile allowedHostnames allowedRegex")
	}
	return nil
}

// Dispatcher calls: OnUpdate(c, reader, newTenant, oldTenant, ...)
// Interface says:   OnUpdate(c, reader, obj[NEW], old[OLD], ...)
//
// BUGGY handler receives: (old, tnt) meaning:
//   3rd param (labeled "old") = actually NEW
//   4th param (labeled "tnt") = actually OLD
// Then calls h.validate(tnt) = validates the OLD tenant
func buggyOnUpdate(newTenant, oldTenant *Tenant) error {
	// BUG: parameters are SWAPPED vs the interface contract
	old := newTenant // dispatcher's "new" arrives as "old" in this function
	tnt := oldTenant // dispatcher's "old" arrives as "tnt" in this function
	_ = old          // unused in the real code too
	return hostnameValidate(tnt) // validates OLD, not NEW
}

// CORRECT implementation (what it should be)
func correctOnUpdate(newTenant, oldTenant *Tenant) error {
	_ = oldTenant
	return hostnameValidate(newTenant) // validates NEW
}

// Simulate ingress hostname validation AFTER bad regex is stored
func validateIngressHostname(tenant *Tenant, hostname string) bool {
	if tenant.Spec.IngressOptions.AllowedHostnames == nil {
		return true
	}
	allowedRegex := tenant.Spec.IngressOptions.AllowedHostnames.Regex
	if len(allowedRegex) == 0 {
		return true
	}
	// This is validate_hostnames.go:160 - error is IGNORED
	matched, _ := regexp.MatchString(allowedRegex, hostname)
	return matched
}

func main() {
	fmt.Println("=== Capsule Bug Reproducer: hostname_regex.go argument swap ===")
	fmt.Println()

	oldTenant := &Tenant{
		Name: "demo-tenant",
		Spec: TenantSpec{
			IngressOptions: IngressOptions{
				AllowedHostnames: &AllowedHostnames{
					Regex: `^[\w.-]+\.example\.com$`, // valid regex
				},
			},
		},
	}

	// Attacker (cluster admin) sets an INVALID regex in the new spec
	newTenant := &Tenant{
		Name: "demo-tenant",
		Spec: TenantSpec{
			IngressOptions: IngressOptions{
				AllowedHostnames: &AllowedHostnames{
					Regex: `[invalid-regex(`, // INVALID regex
				},
			},
		},
	}

	fmt.Printf("Old tenant regex: %q (valid)\n", oldTenant.Spec.IngressOptions.AllowedHostnames.Regex)
	fmt.Printf("New tenant regex: %q (INVALID)\n", newTenant.Spec.IngressOptions.AllowedHostnames.Regex)
	fmt.Println()

	// Step 1: Webhook runs OnUpdate
	fmt.Println("--- Step 1: Webhook OnUpdate ---")

	err := buggyOnUpdate(newTenant, oldTenant)
	if err != nil {
		fmt.Printf("[BUGGY]   Webhook DENIES update: %v\n", err)
	} else {
		fmt.Println("[BUGGY]   Webhook ALLOWS update (validates OLD regex) ← WRONG")
	}

	err = correctOnUpdate(newTenant, oldTenant)
	if err != nil {
		fmt.Printf("[CORRECT] Webhook DENIES update: %v ← EXPECTED\n", err)
	} else {
		fmt.Println("[CORRECT] Webhook ALLOWS update")
	}

	// Step 2: Invalid regex now stored in etcd - simulate ingress validation
	fmt.Println()
	fmt.Println("--- Step 2: Ingress creation after bad regex stored ---")
	storedTenant := newTenant // bad regex is now in etcd

	hostnames := []string{
		"app.example.com",
		"api.example.com",
		"evil.attacker.com",
	}

	for _, h := range hostnames {
		allowed := validateIngressHostname(storedTenant, h)
		fmt.Printf("  Ingress hostname %q → allowed=%v", h, allowed)
		if !allowed {
			fmt.Print("  ← BLOCKED (DoS: invalid regex causes all hostnames to fail)")
		}
		fmt.Println()
	}

	fmt.Println()
	fmt.Println("=== Result ===")
	fmt.Println("Invalid regex bypasses webhook validation and gets stored.")
	fmt.Println("All subsequent Ingress create/update in this tenant are BLOCKED.")
	fmt.Println("CWE-697: Incorrect Comparison — wrong Tenant object is validated.")
}
// Simulates the buggy webhook behaviour
oldTenant := &Tenant{AllowedRegex: `^[\w-]+\.example\.com$`} // valid
newTenant := &Tenant{AllowedRegex: `[invalid-regex(`}         // malformed

// Buggy OnUpdate: validates oldTenant (valid) → ALLOW
// Correct OnUpdate: validates newTenant (invalid) → DENY

// After malformed regex is stored, all ingress hostnames are rejected:
matched, _ := regexp.MatchString(`[invalid-regex(`, "app.example.com")
// matched = false, error ignored → Ingress blocked

Fix

Swap the parameter names in hostname_regex.go to match the interface contract:

// BEFORE (buggy)
func (h *hostnameRegexHandler) OnUpdate(
    _ client.Client,
    _ client.Reader,
    old *capsulev1beta2.Tenant,
    tnt *capsulev1beta2.Tenant,
    ...

// AFTER (fixed)
func (h *hostnameRegexHandler) OnUpdate(
    _ client.Client,
    _ client.Reader,
    tnt *capsulev1beta2.Tenant,
    old *capsulev1beta2.Tenant,
    ...

Impact

A Cluster Admin (or a compromised admin account) can — intentionally or via a typo — set a malformed AllowedHostnames.Regex on any Tenant. The webhook silently accepts the update. All users in the affected tenant are subsequently unable to create or update any Ingress resource until an admin manually corrects the Tenant spec. This constitutes a targeted Denial of Service against the tenant's ingress layer.

Technical details

Source: GitHub Advisory Database

CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:N/I:N/A:H

Medium6.8Base score from GitHub Advisory Database

Attack Vector AV
Network
Attack Complexity AC
Low
Privileges Required PR
High
User Interaction UI
None
Scope S
Changed
Confidentiality C
None
Integrity I
None
Availability A
High

Affected packages

Source: OSV (GitHub advisory)

  • github.com/projectcapsule/capsule
    Go
    pkg:golang/github.com/projectcapsule/capsule
    Affected versions
    >= 0.13.0, < 0.13.7
    Fixed in
    0.13.7

Fix

Source: OSV (GitHub advisory)

Fix available

Upgrade to 0.13.7 or later.

Patch commits

  • 8d89d68Patch commitgithub.com/projectcapsule/capsule

    fix(sec): corrects validation for regex objects (hostname and forbidden (#1983)

    +134 −6 across 4 files

    • e2e/ingress_hostnames_test.go+30 −0
    • e2e/tenant_forbidden_annotations_regex_test.go+89 −0
    • internal/webhook/tenant/validation/forbidden_annotations_regex.go+14 −5
    • internal/webhook/tenant/validation/hostname_regex.go+1 −1
  • #1983Pull requestgithub.com/projectcapsule/capsule

Vulnerability intelligence

References

Credits

Questions about CVE-2026-61795

What is the GHSA ID for CVE-2026-61795?
GitHub tracks CVE-2026-61795 as GHSA-f94q-w3w8-cj67.
What is the CVSS score of CVE-2026-61795?
CVE-2026-61795 has a CVSS 3.1 base score of 6.8 (Medium), vector CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:N/I:N/A:H.
Which versions are affected by CVE-2026-61795?
github.com/projectcapsule/capsule (Go): >= 0.13.0, < 0.13.7.
How do I fix CVE-2026-61795?
Upgrade to 0.13.7 or later. The fix is in commit 8d89d68 and pull request #1983.
What is the Package URL (PURL) for CVE-2026-61795?
The affected package's PURL is pkg:golang/github.com/projectcapsule/capsule.
Is CVE-2026-61795 exploited in the wild?
CISA's Known Exploited Vulnerabilities catalog doesn't list CVE-2026-61795. That means no confirmed exploitation has been catalogued, not that it is safe to leave unpatched. EPSS estimates a 0.32% chance of exploitation in the next 30 days, higher than 26% of CVEs.

Data sources

Upstream records

  • OSV (GitHub advisory)LoadedRaw JSON
  • GitHub Advisory DatabaseLoadedRaw JSON
  • OSV (CVE record)LoadedRaw JSON
  • CVE.orgLoaded
  • CISA KEV catalogLoaded

Fetched 6 days ago (8 Oct 2026, 06:25 UTC). Records refresh automatically after 24 hours.

Where each part of this page came from

Title and description
OSV (GitHub advisory)
Severity score
GitHub Advisory Database
Weakness (CWE)
GitHub Advisory Database
Affected packages
OSV (GitHub advisory)
Fix
OSV (GitHub advisory)
References
Computed by CVEminer
KEV status
CISA KEV catalog
EPSS
GitHub Advisory Database

OSV and GitHub Advisory Database content is licensed CC BY 4.0. Values marked as computed or derived were calculated by CVEminer from the upstream data.