Skip to content

fix: restrict host-level schedule creation to owners and admins - #22

Merged
agentHits merged 1 commit into
AgentHits-Devfrom
fix/schedule-create-host-access
Oct 7, 2026
Merged

agentHits merged 1 commit into
AgentHits-Devfrom
fix/schedule-create-host-access

Conversation

@agentHits

Copy link
Copy Markdown
Collaborator

What is this PR about?

schedule.create did not call assertHostScheduleAccess for schedules without a service (dokploy-server and server types), while update, delete, runManually and list already do. The base member role has schedule.create, so any member could create a dokploy-server schedule. Its script runs as root inside the Dokploy container, which has the Docker socket, /etc/dokploy and the panel's environment, so every secret on the host is reachable. A server schedule ran its script over SSH on the server.

#9 restored dokploy-server schedule runs, which made this exploitable again.

The fix adds the same assertHostScheduleAccess(ctx, scheduleType, input.serverId) call to create: owners and admins only, and no dokploy-server schedules in cloud. Application and compose schedules are unchanged.

Checks

  • New tests in __test__/schedule/schedule-router-boundary.test.ts: a member creating a dokploy-server or server schedule gets FORBIDDEN and nothing is written (both fail on the old code); an admin can still create a dokploy-server schedule.
  • __test__/schedule: 32 tests pass.
  • Full vitest run: 2096 pass, 1 skipped; the 8 failures are only in *.real.test.ts (no local Docker socket).
  • bun run typecheck: 4/4 packages pass. Biome: no errors in the changed files.

Rollout notes

Members can no longer create server-level schedules; owners and admins can. Existing schedules are not touched.

🤖 Generated with Claude Code

Что:
- schedule.create для расписаний без сервиса (типы dokploy-server и server) теперь вызывает assertHostScheduleAccess, как уже делают update, delete, runManually и list.
- Тесты: участник не может создать расписание dokploy-server или server (FORBIDDEN, в базу ничего не пишется); админ может создать dokploy-server.
Зачем:
- Роль member по умолчанию имеет schedule.create. Без этой проверки любой участник мог создать расписание dokploy-server, и его скрипт запускался от root в контейнере Dokploy с доступом к Docker-сокету, /etc/dokploy и переменным панели, то есть ко всем секретам. Для типа server скрипт запускался по SSH на сервере.
- После восстановления запуска расписаний dokploy-server (PR #9) это стало реально исполнимым.
Риски:
- Участники без роли owner/admin больше не могут создавать расписания уровня сервера. Расписания приложений и compose не меняются.
Проверки:
- Команды и результаты: CI=true bunx vitest run --config __test__/vitest.config.ts __test__/schedule/schedule-router-boundary.test.ts - на старом коде 2 новых теста падают (участник создаёт расписание), после правки проходят; все тесты __test__/schedule: 32 прошли. Полный прогон: 2096 прошли, 1 пропущен, 8 упали только в *.real.test.ts (нет сокета Docker Desktop). bun run typecheck - 4/4 без ошибок. bunx biome check для изменённых файлов - 0 ошибок.
- Ограничения: на dev ещё не выкатывалось.

What:
- schedule.create for schedules without a service (dokploy-server and server types) now calls assertHostScheduleAccess, as update, delete, runManually and list already do.
- Tests: a member cannot create a dokploy-server or server schedule (FORBIDDEN, nothing is written); an admin can create a dokploy-server schedule.
Why:
- The member role has schedule.create by default. Without this check any member could create a dokploy-server schedule, and its script ran as root in the Dokploy container with access to the Docker socket, /etc/dokploy and the panel's environment, that is, to every secret. For the server type the script ran over SSH on the server.
- Once dokploy-server schedule runs were restored (PR #9), this became exploitable.
Risks:
- Members without the owner/admin role can no longer create server-level schedules. Application and compose schedules are unchanged.
Checks:
- Commands and results: CI=true bunx vitest run --config __test__/vitest.config.ts __test__/schedule/schedule-router-boundary.test.ts - on the old code the 2 new tests fail (a member creates the schedule), after the fix they pass; all tests in __test__/schedule: 32 passed. Full run: 2096 passed, 1 skipped, 8 failed only in *.real.test.ts (no Docker Desktop socket). bun run typecheck - 4/4 clean. bunx biome check on the changed files - 0 errors.
- Limitations: not deployed to dev yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@agentHits
agentHits merged commit e644c31 into AgentHits-Dev Oct 7, 2026
8 checks passed
@agentHits
agentHits deleted the fix/schedule-create-host-access branch October 7, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant