Skip to content

fix(hub): rotate coolify webhook secret accepts user auth#68

Merged
finedesignz merged 1 commit into
mainfrom
fix/rotate-401
May 26, 2026
Merged

fix(hub): rotate coolify webhook secret accepts user auth#68
finedesignz merged 1 commit into
mainfrom
fix/rotate-401

Conversation

@finedesignz
Copy link
Copy Markdown
Owner

Root cause

PR #67 fixed 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.

Fix

Remove the requireRecentAuth() gate on rotate. The route still has:

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-keys POST/DELETE and error-projects DELETE 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.
  • Post-deploy: rotate from Settings UI returns 200 with new webhook_url.

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).
@finedesignz finedesignz merged commit 1fb7581 into main May 26, 2026
1 check passed
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.

1 participant