[FIX] helpdesk_mgmt: enforce access control on /ticket/close (portal can change arbitrary tickets) - #1089
Open
gmaOCR wants to merge 1 commit into
Open
[FIX] helpdesk_mgmt: enforce access control on /ticket/close (portal can change arbitrary tickets)#1089gmaOCR wants to merge 1 commit into
gmaOCR wants to merge 1 commit into
Conversation
The support_ticket_close controller fetched the ticket with sudo() and only checked the target stage's close_from_portal flag, not the caller's right on the ticket. Any portal or internal user could change the stage of arbitrary tickets (cross-tenant) by passing another ticket_id, even for tickets they cannot read. Fetch the ticket as the current user so record rules apply; keep sudo() only for the stage write, after access to the record has been established. Add a regression test covering both the blocked cross-tenant close and the preserved legitimate 'close my own ticket' flow.
gmaOCR
force-pushed
the
fix-ticket-close-acl
branch
from
August 17, 2026 21:20
8a1d7bb to
1042d7a
Compare
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.
[FIX] helpdesk_mgmt: enforce access control on
/ticket/closeSecurity impact
Broken access control / IDOR (CWE-639) in the
/ticket/closeportal controller.The
support_ticket_closecontroller fetches the ticket withsudo(), whichbypasses the
helpdesk.ticketrecord rules (portal "own tickets" and themulti-company rule), and then gates the write only on the target stage's
close_from_portalflag - not on whether the caller may act on that ticket:As a result, any authenticated portal or internal user can change the stage
of any other tenant's ticket by passing an arbitrary
ticket_idtogetherwith a
stage_idwhoseclose_from_portalisTrue(the defaultDone,CancelledandRejectedstages qualify), even for tickets they cannot read.The exploit is a plain
GET /ticket/close?ticket_id=<any>&stage_id=<close>.Fix
Fetch the ticket as the current user so record rules constrain which tickets
the caller can act on; keep
sudo()only for the stage write, once access tothe record has been established (so a portal user without write permission can
still close a ticket they legitimately own).
Tests
Adds
test_helpdesk_ticket_close_acl.py:Affected versions
Same vulnerable route on 16.0, 17.0, 18.0, 19.0. This PR targets 19.0; I am
happy to port it to the other branches.