fix(security): harden privilege boundaries, ws auth and outbox ordering - #39
Merged
bbbbbbbbbbbbba merged 1 commit intoSep 9, 2026
Merged
Conversation
…and env aliasing - user_service: ResetPassword and AssignRoles can no longer touch super_admin targets or grant IsSystem roles unless the operator is a super_admin (was: any admin could escalate to super_admin in one request) - role_service: AssignPermissions refuses to rewrite built-in IsSystem roles (AssignRoles guard) unless the operator is a super_admin - ws_service: canSubscribeConversation now requires the same conversation.view permission the REST conversation endpoints gate with, closing a websocket read bypass of full message content - channel_message_outbox: ListPending only returns rows whose backoff elapsed (next_retry_at) ordered by next_retry_at, so a backlog of not-yet-due retries no longer starves newer pending sends - config: AGENT_DESK_* prefixed aliases are bound first so ambient legacy variables (PORT, DATABASE_URL) cannot silently override the documented configuration
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.
What
Security hardening for privilege boundaries, realtime authorization, webhook config and the outbound delivery queue. Contains no dependency or feature changes — 5 files, +59/−22.
Fixes
ResetPassword/ password change: an operator who is not a super_admin can no longer reset the password of a user that holds a super_admin role — previously a single admin request returned the super_admin plaintext passwordAssignRoles: system (IsSystem) roles can no longer be granted unless the operator is a super_admin — previously an admin could self-assignsuper_adminAssignPermissions: refuses to rewrite the permission set of built-inIsSystemroles (e.g.super_admin) unless the operator is a super_admin — matching the guardDeleteRolealready hadcanSubscribeConversation: staff websocket sessions now require the sameconversation.viewpermission the REST conversation endpoints gate with — previously any authenticated employee could subscribe toconversation:<id>topics and read full message contentListPendingonly returns outbox rows whosenext_retry_atbackoff has elapsed, ordered bynext_retry_at— a backlog of not-yet-due retries no longer starves newer pending sends every 5 sbindEnvironmentAliasesbinds the documentedAGENT_DESK_*aliases before the legacy names, so ambient variables likePORT/DATABASE_URLcannot silently override the YAML/prefixed configurationVerification
go build -tags dev ./internal/...— passgo vet— pass (no new findings)go test -count=1 -tags dev ./internal/services/... ./internal/repositories/... ./internal/pkg/...— all packages pass except the two pre-existinginternal/pkg/configtests that fail on machines exporting ambientPORT/DATABASE_URL(documented environment contamination — they pass on clean CI runners; thebindEnvironmentAliasesreordering in this PR is the documented-contract fix for the alias-precedence issue, and the remaining hermetic-test gap is tracked separately)Known follow-ups (not in this PR)
session_exchange(design change: server-issued anonymous identity)