Skip to content

Security 5 9 1 Access Fixes

Ed Mozley edited this page Nov 22, 2026 · 1 revision

Security: two access fixes in 5.9.1

Fixed in 5.9.1 Β· Reported privately by @M4ru-0x03 (GHSA-p5pp-7cqw-rcmc, GHSA-33pg-6935-h22c) Β· Modules: Tickets, Assets, REST API


Timeline

Date What happened
19 November 2026 Reported privately through GitHub by @M4ru-0x03 - two advisories, each with a proof of concept and a suggested fix.
22 November 2026 Reproduced on a test install, fixed, and released in 5.9.1 the same day.
22 November 2026 A second researcher reported the asset problem independently by email - the same fault, already fixed.
22 November 2026 The advisories and this write-up published, after the release.

Upgrading to 5.9.1 is the fix. Nothing else needs doing.

Affected Not affected
Ticket writes ignored the department rule 5.1.0 to 5.9.0 - the department rule itself arrived in 5.1.0 5.9.1 and later; administrators; analysts in no team; installs where no team is linked to a department
Asset custom fields crossed companies Every release with custom asset fields, up to 5.9.0, on multi-company installs 5.9.1 and later; single-company installs; analysts who may reach every company

1. Ticket writes ignored the department rule

The short version

Since 5.1.0, an analyst who belongs to a team only sees the tickets of that team's departments (plus tickets with no department, tickets they own, tickets assigned to one of their teams and tickets they watch). That is how a service desk keeps, say, HR or legal tickets away from everybody else - the confidential sensitivity relies on it too.

Seeing a ticket was checked properly. Changing one was not. An analyst who knew - or guessed, since numbers are sequential - another department's ticket number could still reassign it, change its department or sensitivity, add notes and time, split it, delete it and restore it, from the screens or the REST API.

And because a ticket's owner can always see it, a change was also a way to read: make yourself the owner of a confidential HR ticket, and the whole conversation opens.

What was wrong

FreeITSM has two ways to ask "may this person reach this ticket?":

  • analystCanAccessTicket() (includes/tenancy.php) and the REST API's apiKeyCanAccessTicket() check the company and the department. Every screen that shows a ticket uses them.
  • TicketsService::loadTicket() (includes/services/tickets.php) - the one door every change goes through - checked the company only.

When 5.1.0 added the department rule, it was added to the first pair and to about twenty list queries. The service was not changed, and nothing failed: a missing check never throws an error, it just lets more through. The endpoints that change tickets check module access and then trust the service:

Through loadTicket() Screens REST API
Update (status, department, sensitivity, team, analyst...) assign_ticket.php, bulk_update_tickets.php PATCH /tickets/{id}
Owner, schedule update_ticket_owner.php, schedule_ticket.php
Notes, time save_note.php, save_time_entry.php POST /tickets/{id}/notes
Delete, restore delete_ticket.php, restore_ticket.php, bulk_delete_tickets.php DELETE /tickets/{id}, POST /tickets/{id}/restore
Custom fields, closure checks, split, merge save_ticket_custom_fields.php, get_mandatory_fields_check.php, split_ticket.php

The REST PATCH had a second twist: it checked access after writing, so a refused request still changed the ticket and only then answered 404.

The fix

The rule now lives inside the service, so every adapter - screen, REST, split, merge - inherits it:

// includes/services/tickets.php - in loadTicket() and canAccessTicket()
if (!self::departmentAllows($conn, $ctx, $ticketId)) {
    throw new ServiceError('not_found', 'not_found', 'Ticket not found.');
}

private static function departmentAllows(PDO $conn, ActorContext $ctx, int $ticketId): bool
{
    if ($ctx->actorId <= 0 || !in_array($ctx->source, ['ui', 'api'], true)) {
        return true;
    }
    require_once __DIR__ . '/../ticket_department_scope.php';
    return ticketDepartmentAllows($conn, $ctx->actorId, $ticketId);
}

And the REST PATCH asks first:

// api/v1/resources/tickets.php - apiTicketsUpdate()
apiLoadTicket($conn, $apiKey, $params[0]);   // a ticket the key may not see is refused before anything is written

The fix that would have broken things

The suggested fix applied the rule to every caller with an analyst id. That looks complete, and it is what most people would write. But several callers act in an analyst's name without being that analyst sitting at a screen:

  • the 3CX integration adds a call note as the analyst who took the call, to the caller's open ticket - which may be in any department;
  • a planned status incident records the analyst who scheduled it;
  • workflows and the self-service portal use actor 0.

These decided which ticket on their own, by their own rules. Narrowing them by the analyst's departments would have made a phone call's note quietly fail to save. So the rule applies to source ui and api - a person, through the screens or their API key - and the comment on the method says why.

2. Asset custom fields crossed companies

The short version

On a multi-company install, an analyst limited to some companies could read the custom field values of any other company's assets, overwrite them, and add or remove their field sets. Custom fields are where an install keeps what the built-in columns do not cover - serial numbers, licence keys, recovery keys, contract references - so this broke company isolation for exactly the details people least want shared.

What was wrong

Every per-asset endpoint calls analystCanAccessAsset() before touching an asset - disks, software, history, users, tickets, connections, the checkout log. The three custom field endpoints did not, and AssetFieldsService loads an asset by id with no company check of its own:

Endpoint Did
api/assets/get_asset_custom_fields.php returned every custom field value
api/assets/save_asset_custom_fields.php wrote values, logged to the other company's history
api/assets/set_asset_field_set.php attached or detached field sets

The REST API was not affected - it reads custom fields only after its own company check.

The fix

The same gate as their siblings:

// api/assets/save_asset_custom_fields.php (and the other two)
require_once '../../includes/tenancy.php';
if (!analystCanAccessAsset($conn, (int)$_SESSION['analyst_id'], (int)($data['asset_id'] ?? 0))) {
    throw new Exception('Asset not found');
}

Every other endpoint in api/assets/ that takes an id was checked at the same time. The rest either check the company already or work on install-wide settings (asset types, statuses, field definitions) rather than an asset.

πŸ“ Files

File Change
🟣 includes/services/tickets.php departmentAllows(), called from loadTicket() and canAccessTicket()
🟣 api/v1/resources/tickets.php PATCH checks access before writing
🟣 api/assets/get_asset_custom_fields.php, save_asset_custom_fields.php, set_asset_field_set.php analystCanAccessAsset()
πŸ§ͺ tests/ticket-department-scope.php Writes refused, over the screens and the REST API (24 checks)
πŸ§ͺ tests/asset-custom-fields-company.php Read, overwrite and detach refused across companies; own company still works (8 checks)

How it was verified

Both tests drive the real endpoints over HTTP on a test install, with throwaway departments, teams, analysts, companies and assets that remove themselves afterwards.

Control first. Each test was run against the code before the fix and failed the way the reports described: an analyst in the Facilities team made themselves owner of an HR ticket and then read its thread; a company-limited analyst read, changed and detached another company's custom fields. With the fix, every one is refused, and the controls still pass: their own department's ticket takes a note, their own company's asset saves a value, an administrator and an analyst in no team still see every department.

The other ticket tests were run too. The few that fail on that test install fail the same way on the old code - test-data and setup problems, not this change.

What this means for you

Upgrade to 5.9.1.

If you use departments to keep tickets apart, the ticket's audit trail shows every owner, department and sensitivity change with who made it - worth a look on sensitive tickets if you want to be sure nothing happened. For assets, each custom field change is in the asset's History with the analyst's name.

Related

FreeITSM

Getting Started

Modules

Multi-tenancy (planned)

Responses to feedback

Blue sky thinking

Bugs resolved

Pull requests

Links

Clone this wiki locally