Skip to content

fix: fail closed when admin key is unset - #8401

Closed
JustSamyog wants to merge 2 commits into
modrinth:mainfrom
JustSamyog:fix/admin-key-fail-closed
Closed

JustSamyog wants to merge 2 commits into
modrinth:mainfrom
JustSamyog:fix/admin-key-fail-closed

Conversation

@JustSamyog

Copy link
Copy Markdown

admin_key_guard compares the Modrinth-Admin header against LABRINTH_ADMIN_KEY with no check that a key is configured. The env default is the empty string, so when no key is set an attacker can pass the guard by simply sending an empty Modrinth-Admin header (empty bytes match empty bytes in the constant-time comparison). Every route protected by this guard (internal search tasks, privacy, force reindex, Delphi ingest/file, blocked users, pprof, project creation override) is then reachable without a secret.

Mirror subscriptions_key_guard and fail closed when the configured key is empty: the guard now returns false before comparing, so the routes are unmatched (404) until a real key is configured.

CI and local test environments set LABRINTH_ADMIN_KEY=feedbeef (.env.local), and the test API helpers send that same value as the header, so existing tests are unaffected.

@github-actions

Copy link
Copy Markdown
Contributor

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

@mergify

mergify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

This pull request is closed, so it cannot be queued. Reopen it to get the box back.

@JustSamyog JustSamyog closed this by deleting the head repository Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant