Skip to content

require auth for provider endpoint changes - #5768

Open
akshaydeo wants to merge 9 commits into
devfrom
require-auth-for-provider-endpoint-changes
Open

akshaydeo wants to merge 9 commits into
devfrom
require-auth-for-provider-endpoint-changes

Conversation

@akshaydeo

@akshaydeo akshaydeo commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a server-side request forgery (SSRF) vulnerability (GHSA-vj9g-7rqh-x2p4) where an unauthenticated caller could exploit the auth middleware's fail-open bypass (triggered when dashboard authentication is disabled or unconfigured) to set arbitrary dial destinations on provider keys (Ollama, SGL, VLLM, Azure) or provider network_config.base_url, including private/loopback addresses, without any credential check.

Changes

  • Introduces a new context key BifrostContextKeyAuthBypassed that the auth middleware sets exclusively when a request is let through the fail-open branch (no credentials checked), distinct from IsLocalAdminContextKey which is also set on genuinely authenticated sessions.
  • Adds isAuthBypassed() helper to read that context key in handlers.
  • Adds providerKeyCarriesEndpointURL() to identify providers whose key config always carries a caller-chosen dial destination (Ollama, SGL, VLLM, Azure).
  • Adds requireGenuineAuthForEndpointChange() guard that returns HTTP 403 when a bypassed caller attempts to set an endpoint URL on those provider key types; applied to both create and update key handlers.
  • Adds equivalent 403 guards in addProvider and updateProvider for network_config.base_url, preventing a bypassed caller from combining base_url + allow_private_network: true to self-authorize an SSRF target past ValidateExternalURL's private-IP check.
  • Updates OpenAPI docs to document the new 403 responses on the affected endpoints (POST/PUT providers, POST/PUT provider keys).
  • Adds regression tests covering: the exact PoC scenario from the advisory (create and update), the guard's scoping to the fail-open case only (genuine auth is still allowed), provider classification correctness, and the base_url variants for both add and update provider.

Type of change

  • Bug fix

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Docs

How to test

go test ./transports/bifrost-http/handlers/...

Key test cases to verify:

  • TestCreateProviderKey_RejectsEndpointWhenAuthBypassed — unauthenticated caller cannot create an Ollama key with an arbitrary URL (expects 403, no key persisted).
  • TestUpdateProviderKey_RejectsEndpointWhenAuthBypassed — unauthenticated caller cannot rewrite an existing Ollama key's URL (expects 403, original URL unchanged).
  • TestRequireGenuineAuthForEndpointChange — a genuinely authenticated admin can still set any endpoint URL; non-endpoint-carrying providers (e.g. OpenAI) are never gated.
  • TestAddProvider_RejectsBaseURLWhenAuthBypassed — unauthenticated caller cannot create a provider with base_url + allow_private_network: true (expects 403, provider not persisted).
  • TestUpdateProvider_RejectsBaseURLWhenAuthBypassed — same for the PUT variant.
  • TestProviderKeyCarriesEndpointURL — confirms exactly which providers are gated.

Breaking changes

  • No

Genuinely authenticated admin sessions are unaffected. The restriction applies only to the fail-open bypass path.

Related issues

Closes GHSA-vj9g-7rqh-x2p4

Security considerations

This directly addresses an SSRF primitive: when dashboard auth is disabled or unconfigured, the auth middleware previously let all management API requests through with IsLocalAdminContextKey = true. Handlers that set dial destinations (provider key endpoint URLs, provider base_url) did not distinguish between a real admin and an unauthenticated network caller. The new BifrostContextKeyAuthBypassed flag allows those specific handlers to require genuine authentication without changing the fail-open behavior for the rest of the management API.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

jeremym-tanium and others added 9 commits July 31, 2026 00:08
…iew maintenance (#5693)

* feat: support matview_refresh_interval "off" to disable logstore matview maintenance

The materialized views back only the dashboard UI. Deployments that run
Bifrost headless behind their own observability stack pay the REFRESH
MATERIALIZED VIEW CONCURRENTLY cost for views nothing reads, and the 5s
floor means the interval alone cannot turn maintenance off.

With "off" (or a non-positive duration) the logs store skips view
creation, the initial refresh, and the periodic refresher entirely.
matViewsReady stays false, so dashboard queries fall back to the raw
tables, and the runtime self-heal path cannot re-arm maintenance since
it only triggers from matview-path queries.

* fix: guard matview self-heal when maintenance is disabled

Review follow-up: carry the resolved disabled state onto the store so
triggerMatViewSelfHeal cannot recreate views the configuration says must
not exist, and make the schema/docs explicit that a zero duration also
disables (positive sub-5s values still clamp up).
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved token parameter compatibility handling to preserve alternative formats when the primary option is unsupported.

* **Chores**
  * Version updated to 2.0.0.
  * Enhanced load testing configuration for more reliable builds.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary

Briefly explain the purpose of this PR and the problem it solves.

## Changes

- What was changed and why
- Any notable design decisions or trade-offs

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Describe the steps to validate this change. Include commands and expected outcomes.

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

If adding new configs or environment variables, document them here.

## Screenshots/Recordings

If UI changes, add before/after screenshots or short clips.

## Breaking changes

- [ ] Yes
- [ ] No

If yes, describe impact and migration instructions.

## Related issues

Link related issues and discussions. Example: Closes #123

## Security considerations

Note any security implications (auth, secrets, PII, sandboxing, etc.).

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
## Summary

Adds a `THIRD_PARTY_NOTICES.md` file to formally document third-party components used in Bifrost that carry license terms requiring explicit attribution — specifically MPL-2.0 licensed dependencies and embedded source code derived from external projects.

## Changes

- Introduces `THIRD_PARTY_NOTICES.md` to attribute:
  - Embedded source code in `framework/migrator/migrator.go` derived from `go-gormigrate/gormigrate` (MIT)
  - Go binary dependencies carrying MPL-2.0 terms: `github.com/cyphar/filepath-securejoin` and `github.com/hashicorp/go-version`
  - npm build-time devDependencies carrying MPL-2.0 terms: `lightningcss` (never shipped to end users) and `dompurify` (Apache-2.0 option elected)
- All MPL-2.0 components are used unmodified and combined as a "Larger Work" per MPL-2.0 Section 3.3; no Bifrost source files are themselves MPL-licensed.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [x] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [x] Docs

## How to test

No functional changes — review the file contents to confirm accuracy of license attributions against the listed upstream repositories.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

N/A

## Security considerations

This change has no security implications. It is a legal/compliance attribution document only.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
## Summary

Briefly explain the purpose of this PR and the problem it solves.

## Changes

- What was changed and why
- Any notable design decisions or trade-offs

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Describe the steps to validate this change. Include commands and expected outcomes.

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

If adding new configs or environment variables, document them here.

## Screenshots/Recordings

If UI changes, add before/after screenshots or short clips.

## Breaking changes

- [ ] Yes
- [ ] No

If yes, describe impact and migration instructions.

## Related issues

Link related issues and discussions. Example: Closes #123

## Security considerations

Note any security implications (auth, secrets, PII, sandboxing, etc.).

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
## Summary

Briefly explain the purpose of this PR and the problem it solves.

## Changes

- What was changed and why
- Any notable design decisions or trade-offs

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Describe the steps to validate this change. Include commands and expected outcomes.

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

If adding new configs or environment variables, document them here.

## Screenshots/Recordings

If UI changes, add before/after screenshots or short clips.

## Breaking changes

- [ ] Yes
- [ ] No

If yes, describe impact and migration instructions.

## Related issues

Link related issues and discussions. Example: Closes #123

## Security considerations

Note any security implications (auth, secrets, PII, sandboxing, etc.).

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
## Summary

Briefly explain the purpose of this PR and the problem it solves.

## Changes

- What was changed and why
- Any notable design decisions or trade-offs

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Describe the steps to validate this change. Include commands and expected outcomes.

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

If adding new configs or environment variables, document them here.

## Screenshots/Recordings

If UI changes, add before/after screenshots or short clips.

## Breaking changes

- [ ] Yes
- [ ] No

If yes, describe impact and migration instructions.

## Related issues

Link related issues and discussions. Example: Closes #123

## Security considerations

Note any security implications (auth, secrets, PII, sandboxing, etc.).

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
## Summary

Bumps several Go dependencies to their latest patch/minor versions across all modules in the repository.

## Changes

- `github.com/aws/aws-sdk-go-v2/service/s3`: `v1.97.3` → `v1.99.0`
- `github.com/aws/aws-sdk-go-v2/config`: `v1.32.11` → `v1.32.14`
- `github.com/aws/aws-sdk-go-v2/internal/ini`: `v1.8.5` → `v1.8.6`
- `github.com/weaviate/weaviate`: `v1.36.5` → `v1.38.0`
- `github.com/buger/jsonparser`: `v1.1.2` → `v1.2.0`
- `github.com/go-openapi/spec`: `v0.22.2` → `v0.22.3`
- `github.com/google/cel-go`: `v0.28.1` → `v0.29.0`
- `github.com/stretchr/objx`: `v0.5.3` added as an indirect dependency

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [x] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [x] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

```sh
go test ./...
```

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

None. All changes are dependency version bumps with no security-sensitive modifications.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Security

    • Provider and provider-key endpoint URL changes now require genuine admin authentication.
    • Requests attempting to configure endpoint URLs while authentication is disabled or unconfigured are rejected with HTTP 403.
    • Existing provider URLs are protected from unauthorized changes.
  • Documentation

    • Updated API documentation to describe the new authorization requirements and 403 responses.
  • Bug Fixes

    • Added safeguards against unauthorized private or external endpoint configuration.

Walkthrough

Authentication middleware now marks bypassed requests. Provider and provider-key handlers reject endpoint URL configuration from those requests with HTTP 403. Tests verify rejection, persistence protection, endpoint classification, and authenticated-session access. OpenAPI documentation describes the new requirements.

Changes

Endpoint authentication enforcement

Layer / File(s) Summary
Auth-bypass context marker
core/schemas/bifrost.go, transports/bifrost-http/handlers/middlewares.go
Adds BifrostContextKeyAuthBypassed and sets it when authentication is bypassed.
Provider base-URL enforcement
transports/bifrost-http/handlers/providers.go, transports/bifrost-http/handlers/providers_test.go, docs/openapi/paths/management/providers.yaml
Provider creation and updates return 403 for non-empty base URLs on bypassed requests. Tests verify that unsafe URLs are not persisted.
Provider-key endpoint enforcement
transports/bifrost-http/handlers/provider_keys.go, transports/bifrost-http/handlers/provider_keys_test.go, docs/openapi/paths/management/providers.yaml
Ollama, SGL, VLLM, and Azure endpoint changes return 403 on bypassed requests. Tests cover creation, updates, classification, persistence, and authenticated access.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: pratham-mishra04, impoiler, tejasghatte

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses SSRF protection for provider endpoints, but linked issue #123 requires Files API support for provider file uploads. Implement the Files API requirements from issue #123 or link the PR to the correct issue for provider endpoint authentication.
Out of Scope Changes check ⚠️ Warning The implementation is unrelated to linked issue #123, which concerns file upload APIs for providers. Remove the unrelated endpoint-authentication changes or update the linked issue to reflect the PR's actual security objectives.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: authentication is required for provider endpoint changes.
Description check ✅ Passed The description covers the required sections, security impact, implementation, testing steps, affected areas, and checklist.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch require-auth-for-provider-endpoint-changes

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

@akshaydeo
akshaydeo marked this pull request as ready for review August 2, 2026 06:42

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@transports/bifrost-http/handlers/provider_keys.go`:
- Around line 217-219: Allow bypassed updates when the merged endpoint matches
the persisted endpoint, and require genuine authentication only for endpoint
changes. In transports/bifrost-http/handlers/provider_keys.go:217-219, pass
endpoint-change state derived from oldRawKey and mergedKey to
requireGenuineAuthForEndpointChange; in
transports/bifrost-http/handlers/providers.go:505-509, compare nc.BaseURL with
the stored NetworkConfig.BaseURL before rejecting. Add coverage in
transports/bifrost-http/handlers/providers_test.go:197-246 and
transports/bifrost-http/handlers/provider_keys_test.go:500-535 for bypassed
updates preserving the endpoint while changing a non-endpoint field.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a721476-1c44-4c69-9220-8e1ce9c0ddcf

📥 Commits

Reviewing files that changed from the base of the PR and between e493a6a and 439bb79.

📒 Files selected for processing (7)
  • core/schemas/bifrost.go
  • docs/openapi/paths/management/providers.yaml
  • transports/bifrost-http/handlers/middlewares.go
  • transports/bifrost-http/handlers/provider_keys.go
  • transports/bifrost-http/handlers/provider_keys_test.go
  • transports/bifrost-http/handlers/providers.go
  • transports/bifrost-http/handlers/providers_test.go

Comment on lines +217 to +219
if requireGenuineAuthForEndpointChange(ctx, baseProvider) {
return
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Allow bypassed updates that do not change an endpoint.

At Line 217, requireGenuineAuthForEndpointChange receives only baseProvider. It rejects every Ollama, SGL, VLLM, or Azure key update during auth bypass. At Line 505, the provider guard similarly rejects every update that retains a non-empty BaseURL.

Compare the persisted endpoint with the merged requested endpoint. Return 403 only when the endpoint value changes. Otherwise, bypassed callers cannot update unrelated fields such as key weight or provider concurrency when a full PUT payload retains an existing endpoint.

  • transports/bifrost-http/handlers/provider_keys.go#L217-L219: pass endpoint-change state derived from oldRawKey and mergedKey to the guard.
  • transports/bifrost-http/handlers/providers.go#L505-L509: compare nc.BaseURL with the stored NetworkConfig.BaseURL before rejecting.
  • transports/bifrost-http/handlers/providers_test.go#L197-L246: add a bypassed update that preserves the base URL and changes a non-endpoint field.
  • transports/bifrost-http/handlers/provider_keys_test.go#L500-L535: add a bypassed update that preserves the endpoint and changes a non-endpoint field.

Based on PR objectives, endpoint changes require genuine authentication, not unrelated provider configuration updates.

📍 Affects 4 files
  • transports/bifrost-http/handlers/provider_keys.go#L217-L219 (this comment)
  • transports/bifrost-http/handlers/providers.go#L505-L509
  • transports/bifrost-http/handlers/providers_test.go#L197-L246
  • transports/bifrost-http/handlers/provider_keys_test.go#L500-L535
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@transports/bifrost-http/handlers/provider_keys.go` around lines 217 - 219,
Allow bypassed updates when the merged endpoint matches the persisted endpoint,
and require genuine authentication only for endpoint changes. In
transports/bifrost-http/handlers/provider_keys.go:217-219, pass endpoint-change
state derived from oldRawKey and mergedKey to
requireGenuineAuthForEndpointChange; in
transports/bifrost-http/handlers/providers.go:505-509, compare nc.BaseURL with
the stored NetworkConfig.BaseURL before rejecting. Add coverage in
transports/bifrost-http/handlers/providers_test.go:197-246 and
transports/bifrost-http/handlers/provider_keys_test.go:500-535 for bypassed
updates preserving the endpoint while changing a non-endpoint field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants