fix(hub): rotate coolify webhook secret accepts user auth#68
Merged
Conversation
PR #67 cleared the csrf_failed 403 on POST /api/account/coolify-webhook-secret/rotate, but the request then hit the requireRecentAuth() gate at hub/src/index.ts:198 and 401'd. Two failure modes: - Legacy Bearer-JWT clients have no cookie session at all -> the gate returns {error: 're_auth_required', reason: 'no_cookie_session'} with no client- side recovery short of logout+login. - Cookie-auth users whose session is older than 5 min get re_auth_required even though their session is otherwise valid. Threat model for rotate: an attacker who already controls the user's session (or bearer JWT) can rotate the webhook secret -- but they already control the account. Re-auth on rotate alone buys nothing. The per-user mutation rate limit (10/min/user) at hub/src/index.ts:223 still applies. Sister re-auth gates on api-keys POST/DELETE and error-projects DELETE remain untouched -- those grant credential issuance / data destruction and the elevated friction is warranted. Verified: csrf + reauth test suites both green (33 pass).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
PR #67 fixed the
csrf_failed403 onPOST /api/account/coolify-webhook-secret/rotate, but the request then hit therequireRecentAuth()gate athub/src/index.ts:198and 401'd.Two failure modes:
{error: 're_auth_required', reason: 'no_cookie_session'}with no client-side recovery short of logout+login.re_auth_requiredeven though their session is otherwise valid.Fix
Remove the
requireRecentAuth()gate on rotate. The route still has:authMiddleware(cookie OR legacy Bearer JWT)csrfGuard(Bearer bypass + cookie self-heal from PR fix(hub): CSRF guard bypasses Bearer-auth requests (legacy JWT) #65/fix(web): rotate webhook secret call uses authed fetch (no CSRF fail) #67)userMutationLimit(10/min/user)Threat model: an attacker with the user's valid session/bearer can rotate the webhook secret -- but they already control the account. Re-auth on rotate alone buys nothing. Sister re-auth gates on
api-keysPOST/DELETE anderror-projectsDELETE remain untouched -- credential issuance and data destruction warrant the friction.Verification
bun test hub/test/csrf.test.ts hub/test/reauth.test.ts-> 33 pass, 0 fail.webhook_url.