The vulnerability is an information disclosure flaw in ApostropheCMS's REST API, affecting both piece-types and pages. The root cause is that the choices and counts query parameters trigger a data retrieval path that does not respect the security restrictions configured for the main API endpoint. Specifically, the after handler for the choices query builder (located in @apostrophecms/doc-type/index.js) would fetch distinct values for any requested schema field using MongoDB's distinct operation. This operation inherently ignores projections, meaning the publicApiProjection intended to limit publicly visible fields was bypassed. Additionally, the handler did not perform any checks for viewPermission on fields.
The vulnerable flow starts in the getRestQuery methods of the @apostrophecms/piece-type and @apostrophecms/page modules. These methods set up the main query and apply the publicApiProjection but, prior to the patch, failed to pass the projection information to the query object for other parts of the system to use. The choices builder's after handler, therefore, had no awareness of the projection and proceeded to fetch and return distinct values for fields that should have been protected.
The patch addresses this by modifying getRestQuery in both modules to store the publicApiProjection on the query object. Then, the choices builder's after handler is updated to use this information to explicitly check if a field is allowed by the projection and by any viewPermission before attempting to retrieve its distinct values. My analysis identified these three functions as the key components of the vulnerable execution path.