Skip to content

fix(spiffe): refuse client creation on missing expected server ID - #608

Draft
ahsan-zamil wants to merge 1 commit into
container-registry:mainfrom
ahsan-zamil:fix/spiffe-expected-server-id-required
Draft

fix(spiffe): refuse client creation on missing expected server ID#608
ahsan-zamil wants to merge 1 commit into
container-registry:mainfrom
ahsan-zamil:fix/spiffe-expected-server-id-required

Conversation

@ahsan-zamil

@ahsan-zamil ahsan-zamil commented Aug 10, 2026

Copy link
Copy Markdown

This PR resolves #589 by enforcing that ExpectedServerID is non-empty when SPIFFE is enabled on the satellite side.

Changes:

  1. Updated NewClient(cfg Config) in internal/spiffe/client.go to return an error if SPIFFE is enabled but ExpectedServerID is empty.
  2. Cleaned up GetTLSConfig() in internal/spiffe/client.go to remove the insecure tlsconfig.AuthorizeAny() fallback path.
  3. Added client_test.go to cover config validation and error scenarios.

Closes #589

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Strengthened SPIFFE-enabled connection security by requiring a valid expected server identity.
    • Connections now reject servers that do not match the configured identity instead of accepting any server.
  • Tests

    • Added coverage for disabled SPIFFE, missing or invalid identities, and valid client configuration.

@gitar-bot

gitar-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

@codacy-production

codacy-production Bot commented Aug 10, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 10 complexity · 8 duplication

Metric Results
Complexity 10
Duplication 8

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ahsan-zamil, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e89c88f1-5e01-479a-b5c5-997ff72258d7

📥 Commits

Reviewing files that changed from the base of the PR and between 3518b4b and 1d4587a.

📒 Files selected for processing (3)
  • internal/satellite/satellite.go
  • internal/satellite/state/reporting_process.go
  • internal/satellite/state/reporting_process_test.go
📝 Walkthrough

Walkthrough

When SPIFFE is enabled, NewClient now requires a valid ExpectedServerID. TLS configuration always authorizes that server ID. Table-driven tests cover disabled, invalid, incomplete, and valid configurations.

Changes

SPIFFE identity validation

Layer / File(s) Summary
Require and enforce expected server identity
internal/spiffe/client.go, internal/spiffe/client_test.go
NewClient rejects enabled configurations without a valid ExpectedServerID. TLS authorization uses AuthorizeID instead of AuthorizeAny. Tests cover configuration errors and successful client creation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: auth

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main security fix: refusing SPIFFE client creation when the expected server ID is missing.
Description check ✅ Passed The description explains the fix, lists the code and test changes, and references issue #589, with only minor template-heading differences.
Linked Issues check ✅ Passed The changes satisfy issue #589 by failing closed on a missing expected server ID and removing the AuthorizeAny fallback.
Out of Scope Changes check ✅ Passed The changes are limited to SPIFFE client validation, TLS authorization, and related tests, all within issue #589 scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/spiffe/client.go">

<violation number="1" location="internal/spiffe/client.go:52">
P1: An enabled, already-registered satellite with no server ID silently downgrades status reports to the non-SPIFFE HTTP path because `NewStatusReportingProcess` ignores this error; propagate or retain the configuration error so SPIFFE-enabled reporting cannot fall back.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/spiffe/client.go
return nil, fmt.Errorf("invalid expected server ID %q: %w", cfg.ExpectedServerID, err)
}
if cfg.ExpectedServerID == "" {
return nil, fmt.Errorf("expected server ID must be configured when SPIFFE is enabled")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: An enabled, already-registered satellite with no server ID silently downgrades status reports to the non-SPIFFE HTTP path because NewStatusReportingProcess ignores this error; propagate or retain the configuration error so SPIFFE-enabled reporting cannot fall back.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/spiffe/client.go, line 52:

<comment>An enabled, already-registered satellite with no server ID silently downgrades status reports to the non-SPIFFE HTTP path because `NewStatusReportingProcess` ignores this error; propagate or retain the configuration error so SPIFFE-enabled reporting cannot fall back.</comment>

<file context>
@@ -48,13 +48,13 @@ func NewClient(cfg Config) (*Client, error) {
-			return nil, fmt.Errorf("invalid expected server ID %q: %w", cfg.ExpectedServerID, err)
-		}
+	if cfg.ExpectedServerID == "" {
+		return nil, fmt.Errorf("expected server ID must be configured when SPIFFE is enabled")
+	}
+
</file context>

Signed-off-by: Ahsan Zamil <ahsanzamil76@gmail.com>
@ahsan-zamil
ahsan-zamil force-pushed the fix/spiffe-expected-server-id-required branch from 3518b4b to 1d4587a Compare August 10, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SPIFFE mTLS silently falls back to AuthorizeAny() when SPIFFE_EXPECTED_SERVER_ID is unset

1 participant