#11154·MISP

Bug: MISP 2.5.46 server pull stops pagination early when protected events are filtered from a page

Author: thilseCreated Sep 23, 2026Updated Sep 23, 2026
Labelsneeds triage

Actual behavior

MISP 2.5.46 server pull stops pagination early when protected events are filtered from a page

Expected behavior

A full description can be found in "Steps to reproduce"

Steps to reproduce

Steps to reproduce

  1. Set up two MISP instances, both running MISP 2.5.46:

    • Remote MISP: source of the events
    • Local MISP: configured to pull events from the remote instance
  2. Configure a server pull on the local instance and perform a full pull using:

    bash
    sudo -u www-data /var/www/MISP/app/Console/cake Server pull <sync-user-id> <server-id>
  3. On the remote MISP, ensure that there are more than 10,000 published events.

  4. Ensure that at least one event within the first 10,000 events returned by the following request is protected (Event.protected = 1) and is not accessible to the pulling instance.

    The relevant endpoint is:

    POST /events/index

    with parameters equivalent to:

    minimal=1
    published=1
    page=1
    limit=10000
    sort=id
    direction=asc
  5. On the remote MISP, the request is handled by:

    /var/www/MISP/app/Controller/EventsController.php

    in the subroutine:

    php
    private function __indexRestResponse(array $passedArgs)

    In MISP 2.5.46, the initial database query is performed around line 934:

    php
    $events = $absoluteTotal === 0 ? [] : $this->Event->find('all', $rules);

    With the above parameters, this query returns 10,000 events.

  6. Because minimal=1, the events are subsequently processed in the else { // minimal } block around line 1036.

    Protected events are removed around lines 1038–1041:

    php
    if ($event['Event']['protected'] && !isset($protectedEventsByInstanceKey[$event['Event']['id']])) {
        unset($events[$key]);
        continue;
    }

    If exactly one of the 10,000 events is protected, the resulting REST response therefore contains 9,999 events.

  7. On the local MISP, the response is processed by:

    /var/www/MISP/app/Model/Server.php

    in:

    php
    private function getEventIdsFromServer(
        ServerSyncTool $serverSync,
        $all = false,
        $ignoreFilterRules = false,
        $force = false
    )

    In MISP 2.5.46, the paginated request is made around line 1143:

    php
    $eventArray = $this->getEventIndexFromServer(
        $serverSync,
        $ignoreFilterRules,
        ['page' => $page, 'limit' => $pageSize]
    );

    The number of received events is then determined around line 1144:

    php
    $fetched = count($eventArray);
  8. With the protected event filtered out by the remote server, the local instance receives:

    fetched = 9999
  9. The pagination is then terminated around lines 1183–1185 because $fetched is smaller than $pageSize:

    php
    if ($remoteIgnoredPagination || $notAdvancing || $fetched < $pageSize) {
        break;
    }
  10. Consequently, page 2 and all subsequent pages are not requested, even though the remote instance still has additional events.

Observed result

For example, with:

page size:             10000
events returned by DB: 10000
protected events:          1
events returned via API: 9999

the local server interprets the response as the last page and stops pulling.

In my test case, the event I was looking for was located on page 83. It was not pulled before the fix because pagination stopped after page 1.

Workaround

The issue can be worked around by removing the $fetched < $pageSize condition from the pagination termination check in:

/var/www/MISP/app/Model/Server.php

subroutine:

php
private function getEventIdsFromServer(
    ServerSyncTool $serverSync,
    $all = false,
    $ignoreFilterRules = false,
    $force = false
)

around lines 1183–1185 in MISP 2.5.46.

Current code:

php
if ($remoteIgnoredPagination || $notAdvancing || $fetched < $pageSize) {
    break;
}

Tested workaround:

php
if ($remoteIgnoredPagination || $notAdvancing) {
    break;
}

Why this works

$fetched is the number of events remaining after the remote /events/index response has already been filtered.

Therefore, $fetched < $pageSize does not necessarily mean that the remote page was the last page.

For example:

Remote query:
    10,000 events

Protected events removed:
        1 event

Response received by local MISP:
    9,999 events

The existing code interprets 9,999 < 10,000 as the last page and stops pagination.

After removing this condition, pagination continues until one of the other two conditions is met:

php
$remoteIgnoredPagination

or:

php
$notAdvancing

The final page is correctly terminated by the existing check earlier in the loop:

php
if ($fetched === 0) {
    break;
}

Verification

With the workaround applied, the same server pull proceeded as follows:

page=1  fetched=9999
page=2  fetched=10000
page=3  fetched=10000
...
page=83 fetched=5981
page=84 fetched=0

The previously missing event was located on page 83 and was successfully included in the pull.

No other changes to the server synchronization configuration were required.

Suggested permanent fix

The pagination logic should not use the number of events remaining after response-side filtering ($fetched) as an indication that the remote page was the last page.

A permanent fix should retain a reliable indication of whether the remote result set itself reached the requested page size, independently of events subsequently removed by filtering.

Version

2.5.46

Operating System

Ubuntu

Operating System version

24.04

PHP version

8.3

Browser

No response

Browser version

No response

Relevant log output

bash

Extra attachments

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct