fix(page): server-side cycle check in movePage (RT-21) #67

Closed
opened 2026-06-21 01:56:56 +03:00 by Ghost · 0 comments

Источник: red-team-аудит, RT-21 (docs/red-team-report.md).

Что происходит

Серверный movePage (apps/server/src/core/page/page.service.ts:949-965) не проверяет, что страницу не двигают внутрь её собственного поддерева. Через MCP/REST/агента (или быстрый drag) можно создать циклическую структуру, которая персистится и рассылается всем.

Фикс

Перед updatePage пройти предков target вверх; если встретили перемещаемую страницу — reject (реюз ancestor-CTE из getPageBreadCrumbs):

// page.service.ts (movePage) — reject a move that would put a page under itself.
// Walk ancestors of the target up to the root; if we hit the moved page, it's a cycle.
if (dto.parentPageId === dto.pageId || ancestorsOf(dto.parentPageId).includes(dto.pageId))
  throw new BadRequestException('Cannot move a page into its own subtree');

Цена / приоритет

+1 ancestor-CTE на move; проверка в сервисе авторитетна для всех путей записи.

**Источник:** red-team-аудит, RT-21 (`docs/red-team-report.md`). ### Что происходит Серверный `movePage` (`apps/server/src/core/page/page.service.ts:949-965`) не проверяет, что страницу не двигают **внутрь её собственного поддерева**. Через MCP/REST/агента (или быстрый drag) можно создать циклическую структуру, которая персистится и рассылается всем. ### Фикс Перед `updatePage` пройти предков target вверх; если встретили перемещаемую страницу — reject (реюз ancestor-CTE из `getPageBreadCrumbs`): ```ts // page.service.ts (movePage) — reject a move that would put a page under itself. // Walk ancestors of the target up to the root; if we hit the moved page, it's a cycle. if (dto.parentPageId === dto.pageId || ancestorsOf(dto.parentPageId).includes(dto.pageId)) throw new BadRequestException('Cannot move a page into its own subtree'); ``` ### Цена / приоритет +1 ancestor-CTE на move; проверка в сервисе авторитетна для всех путей записи.
Ghost added the bugsecurity labels 2026-06-21 02:27:18 +03:00
Ghost closed this issue 2026-06-21 14:10:30 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vvzvlad/gitmost#67