Skip to content

fix(envoy): only accept asymmetric api keys when sb translation is enabled - #45195

Merged
aantti merged 1 commit into
supabase:masterfrom
luizfelmach:fix/envoy-keys
Apr 24, 2026
Merged

aantti merged 1 commit into
supabase:masterfrom
luizfelmach:fix/envoy-keys

Conversation

@luizfelmach

@luizfelmach luizfelmach commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Bug fix (Envoy API key validation behavior)

What is the current behavior?

When SUPABASE_PUBLISHABLE_KEY / SUPABASE_SECRET_KEY are not configured (translation mode disabled), requests can still pass API key validation using ANON_KEY_ASYMMETRIC or SERVICE_ROLE_KEY_ASYMMETRIC if those values are set.
This allows asymmetric internal JWTs to be accepted directly as API keys outside the intended sb_* -> internal JWT translation flow.

What is the new behavior?

Asymmetric keys are now accepted by the 401 API key validation filter only when translation mode is enabled (all required translation env vars are present).

  • If translation is disabled, only legacy keys are accepted by that filter.
  • If translation is enabled, behavior remains the same for translated asymmetric values.

Additional context

This is a minimal, low-risk fix in docker/volumes/api/envoy/lds.template.yaml:

  • Added TRANSLATION_ENABLED check in the API key validation Lua filter.
  • Gated acceptance of ANON_KEY_ASYMMETRIC and SERVICE_ROLE_KEY_ASYMMETRIC behind that condition.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced authorization validation to ensure asymmetric key-based authentication requires proper Supabase configuration to be enabled. Requests using these authentication methods without the required configuration will now correctly return a 401 response.

@luizfelmach
luizfelmach requested review from a team as code owners April 24, 2026 00:30
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to Supabase! ❤️ Our team will review your PR.

A few tips for a smoother review process:

  • If you have a local version of the repo, run pnpm run format to make sure formatting checks pass.
  • Once we've reviewed your PR, please don't trivially merge master (don't click Update branch if there are no merge conflicts to be fixed). This invalidates any pre-merge checks we've run.

@vercel

vercel Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Apr 24, 2026 10:14am
docs Ready Ready Preview, Comment, Open in v0 Apr 24, 2026 10:14am
learn Ready Ready Preview, Comment Apr 24, 2026 10:14am
studio-self-hosted Ready Ready Preview, Comment Apr 24, 2026 10:14am
studio-staging Ready Ready Preview, Comment Apr 24, 2026 10:14am
ui-library Ready Ready Preview, Comment Apr 24, 2026 10:14am
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Apr 24, 2026 10:14am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Apr 24, 2026 10:14am

Request Review

@vercel

vercel Bot commented Apr 24, 2026

Copy link
Copy Markdown

@luizfelmach is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b2b0348a-209d-4534-882a-ab7a6ac6cf72

📥 Commits

Reviewing files that changed from the base of the PR and between 1f31858 and 37459c4.

📒 Files selected for processing (1)
  • docker/volumes/api/envoy/lds.template.yaml

📝 Walkthrough

Walkthrough

The Lua 401-validation logic for protected routes in Envoy's configuration now checks for both Supabase keys and asymmetric JWT keys to determine translation enablement. When translation prerequisites are not satisfied, asymmetric API key values are rejected during authorization validation.

Changes

Cohort / File(s) Summary
Lua Authorization Validation
docker/volumes/api/envoy/lds.template.yaml
Modified Lua 401-validation to read Supabase keys, compute a TRANSLATION_ENABLED boolean, and conditionally gate asymmetric-key-based authorization (SERVICE_ROLE_KEY_ASYMMETRIC and ANON_KEY_ASYMMETRIC) based on prerequisite satisfaction. Asymmetric keys now only pass validation when translation prerequisites are met.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🔐 Keys once wild now gated tight,
Asymmetric dreams need translation's light,
Supabase keys unlock the way,
Prerequisites enforced today! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: gating acceptance of asymmetric API keys behind a Supabase translation-enabled check in Envoy.
Description check ✅ Passed The description comprehensively follows the template with all required sections completed: confirms reading CONTRIBUTING.md, specifies bug fix type, explains current problematic behavior, details new behavior, and provides relevant implementation context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@aantti aantti self-assigned this Apr 24, 2026
@aantti
aantti merged commit 5306016 into supabase:master Apr 24, 2026
19 of 20 checks passed
@luizfelmach
luizfelmach deleted the fix/envoy-keys branch April 24, 2026 10:18
@github-actions

github-actions Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1777025973)

Score Average Improvements Regressions
Completeness 90.7% (-4pp) 2 🟢 3 🔴
Conciseness 30.6% (+3pp) 5 🟢 5 🔴
Docs Faithfulness 56.9% (-6pp) 3 🟢 6 🔴
Goal Completion 81.5% (-6pp) 2 🟢 6 🔴
Knowledge Usage 93.3% (-3pp) - 1 🔴
Tool Usage 73.8% (+0pp) - -
Correctness 80% (-13pp) 1 🟢 3 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
URL Validity 100% (+0pp) - -
Time_to_first_token 0.01tok (0tok) 10 🟢 8 🔴
Llm_calls 10.76 (-0.04) 7 🟢 8 🔴
Tool_calls 3.81 (-0.15) 9 🟢 7 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 26563.48tok (+211.43tok) 8 🟢 10 🔴
Prompt_cached_tokens 6466.37tok (+692.15tok) 11 🟢 7 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Completion_tokens 609.63tok (-18.94tok) 9 🟢 9 🔴
Completion_reasoning_tokens 111.11tok (-1.24tok) 9 🟢 9 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 27173.11tok (+192.48tok) 8 🟢 10 🔴
Estimated_cost 0$ (0$) 7 🟢 9 🔴
Duration 17.48s (+2.51s) 4 🟢 14 🔴
Llm_duration 12.45s (+2.09s) 4 🟢 14 🔴

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.

2 participants