stacklok / stacklok/toolhive

Audience Uniqueness Warning

Open
#4,260 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement kubernetes operator security
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Description

When reconciling an MCPOIDCConfig, detect duplicate audience values across workloads referencing the same config and emit a Warning event. If two servers sharing the same OIDC config have the same audience, a token obtained for one is valid at the other — this is a security concern.

Implementation Notes

Location: Add to the MCPOIDCConfig controller reconciliation loop (02-C).

Logic:

  1. For each referencing workload, resolve the effective audience:
    • If spec.oidcConfig.audience is set, use it
    • Otherwise, use the default {kind}/{namespace}/{name}
  2. Check for duplicates in the resolved audience list
  3. If duplicates found, emit a Warning event on the MCPOIDCConfig resource:
    Warning AudienceDuplicate Duplicate audience "foo" found on workloads: server-a, server-b. Tokens may be replayable between these servers.
    

Event recorder: Use the controller's record.EventRecorder (already available in the controller struct pattern).

Testing

  • Two workloads with different audiences → no warning event
  • Two workloads with same explicit audience → Warning event emitted
  • Workload with default audience matching another's explicit audience → Warning event emitted

Acceptance Criteria

  • Duplicate audience detection runs during MCPOIDCConfig reconciliation
  • Warning event emitted on the MCPOIDCConfig resource when duplicates found
  • Event message identifies the duplicate audience value and the affected workloads
  • No warning emitted when all audiences are unique
  • Default audience computation ({kind}/{namespace}/{name}) is included in uniqueness check
  • Unit tests cover all audience uniqueness scenarios
  • Tests pass in CI (task test)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the MCPOIDCConfig controller reconciliation loop (02-C) and review the controller struct's available EventRecorder. Trace how referencing workloads and their effective audiences are resolved, then cover the three listed uniqueness scenarios with unit tests. Done means duplicate audiences emit the specified Warning event on MCPOIDCConfig, unique audiences emit none, and task test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.