Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

17.5 KB
Raw Blame

ServerKit security and product review — 2026-09-05

Reviewed checkout: 6c2220c5. Scope: authentication and MFA, API-key scopes, Socket.IO, AI tools and redaction, representative authorization tests, subprocess patterns, CI, and Settings table implementation.

The largest gap is consistent authorization across entry points. REST routes, API keys, sockets, and AI tools do not always enforce the same policy. Several bypasses below were reproduced locally with disposable database records. These are more urgent than adding features or redesigning the interface.

This was a source review with isolated Flask/Socket.IO tests, not a penetration test of the production deployment. No production accounts, credentials, services, or AI providers were used. Application source was not changed. Local frontend/backend servers were unavailable on the configured ports, so UI findings are based on source and compiled styles rather than a live visual walkthrough.

Fix first

1. High: an MFA-pending administrator can obtain a full session without completing MFA

Evidence: backend/app/__init__.py:455, backend/app/api/auth.py:294, backend/app/api/auth.py:325, backend/app/api/auth.py:395.

The pending-token guard exempts any path containing /auth/login. This also exempts /auth/login-links. An admin's valid password produces a 2fa_pending token; that token passes the login-link route's admin check and can mint a link. Redeeming that link returns ordinary access and refresh tokens without a second-factor challenge.

Local proof: real password login for a synthetic MFA-enabled admin; the temporary token got 403 on /auth/me, but 201 on login-link creation. Redemption returned 200, and the resulting access token successfully accessed /api/v1/admin/users. No TOTP or backup code was supplied.

There is a related expiry defect: expires_delta=False disables expiration. The comment says it uses a short default expiry, but the actual temporary token has no exp claim. This was verified against the installed library and the token generated by the login route; the library documentation confirms the semantics.

Fix: use exact endpoint allowlists for MFA challenges; require completed authentication for login-link administration; give pending tokens an explicit short lifetime. Review redemption as an authentication method, including the target user's MFA policy. Add an end-to-end regression for this complete chain, not just a role check on link creation.

Effort: small emergency patch plus focused tests; follow with a broader authentication-boundary review.

2. High: an admin-owned read-only API key can become a full browser session

Evidence: backend/app/middleware/rbac.py:27, backend/app/middleware/api_key_auth.py:8, backend/app/api/auth.py:325, backend/app/middleware/api_scope_middleware.py:81.

admin_required accepts API keys, but does not enforce their scopes. Login-link creation has no separate scope gate. An admin-owned key limited to apps:read can therefore mint and redeem a login link, yielding access and refresh tokens outside the original scope restriction. The role prerequisite matters: this is escalation of an admin-owned restricted key, not promotion of a viewer-owned key to admin.

Local proof: created a synthetic apps:read key, verified it lacked write, then obtained 201 from login-link creation and 200 with fresh session credentials from redemption.

Fix: make credential/session minting require an explicit authentication-method decision and appropriate recent authentication. Audit every API-key-capable route for scope enforcement. Add a test matrix using restricted keys against real routes. Preserve deliberately JWT-only routes; do not mechanically convert their decorators to API-key-capable ones.

Effort: small fix to close this chain; medium effort to finish scope coverage across the API.

3. High: Socket.IO accepts the wrong tokens and allows cross-user room subscriptions

Evidence: backend/app/sockets.py:162, backend/app/sockets.py:181, backend/app/sockets.py:372.

Two independent problems exist:

  • Connection authentication decodes a JWT and checks that its user is active, but does not reject 2fa_pending tokens or refresh tokens. Both connected successfully in local Socket.IO tests.
  • The generic join_room event accepts arbitrary room names, with a special role check only for terminal rooms. A viewer can join user_<another-user-id>, bypassing the intended per-user notification boundary.

Local proof: a viewer joined a synthetic admin's user room and received a harmless test event sent only to that room. This proves cross-user delivery without reading anybody's real notifications. It does not establish the sensitivity of every production event payload.

Roles are also cached at connection time. Account and privilege changes need a defined policy for existing connections.

Fix: apply full access-token validation to socket connections; reject incomplete MFA and refresh-token use; replace arbitrary room joins with authorized, resource-specific subscriptions. Recheck ownership and privileges when subscribing, and disconnect or revalidate sessions after revocation. This matches OWASP's WebSocket guidance on message authorization and session handling.

Effort: medium, because all consumers of the generic room event need to be inventoried.

4. High in shared panels: the AI can reveal applications hidden by REST authorization

Evidence: backend/app/services/ai_tools_builtin.py:56, backend/app/services/ai_service.py:379, backend/app/services/ai_tool_registry.py:53, backend/app/api/apps.py:723.

The AI's list_applications tool returns Application.query_active().all(). Its wrapper checks feature-level read permission, not app ownership, workspace membership, or resource grants. Viewers have application-read permission by default.

Local proof: a viewer received 403 for another user's app through the real REST detail endpoint. Calling the actual AI read wrapper with the same viewer returned that app. This tests the backend tool boundary; no live model was asked to disclose data.

The returned shape is broader than the tool description's name/status/type/port summary: it includes infrastructure and configuration metadata such as paths, identifiers, repository/build configuration, and private routing fields. The fleet/database listing tools deserve the same policy comparison, although this review's demonstrated cross-owner case is applications.

Fix: pass caller identity into tools and reuse the existing resource visibility services. Return a deliberately selected set of safe fields. Test that REST and AI show the same resources for owner, member, viewer, foreign user, and admin. This is an object-level authorization problem, not something a prompt-injection detector can fix.

Effort: small-to-medium for application listing; medium for consistent tool coverage.

5. High: password changes and account disablement do not consistently invalidate access

Evidence: backend/app/api/auth.py:477, backend/app/api/auth.py:493, backend/app/api/auth.py:523, backend/app/api/auth.py:546, backend/app/models/user.py:139, frontend/src/services/api/auth.js:39.

The self-service password endpoint accepts a new password using an existing access token, without the old password or another recent authentication proof. Changing the password does not invalidate an already-issued refresh token. Refresh tokens default to 30 days. Logout only clears browser tokens.

Account disablement blocks password login and refresh, and role decorators check activity, but JWT-only routes do not uniformly check it. A disabled user's existing access token still read /auth/me and an owned application's details in the local tests. Production access tokens normally expire after 15 minutes; that is a residual-access window, not immediate offboarding.

Local proof: changed a synthetic user's password without providing the old one, then successfully refreshed with the token issued before the change. Separately disabled a synthetic account and verified continued reads with its existing access token.

Fix: require recent authentication for credential changes; add a server-side session/version or revocation mechanism checked consistently by REST and sockets. Revoke affected sessions on password reset, account disablement, and explicit logout/revoke actions. Existing JWT-only routes can gain activity/revocation checks without granting API-key access.

Effort: medium; schema changes require a migration.

6. Medium: the AI redaction toggle overstates its coverage

Evidence: backend/app/services/ai_service.py:300, backend/app/services/ai_service.py:309, backend/app/services/ai_service.py:388, frontend/src/components/settings/AISettingsTab.jsx:199.

The UI promises redaction of messages and tool output. _maybe_redact_result returns dictionary/list results untouched, while built-in tools commonly return exactly those types. Write-tool results also return directly. Input redaction returns the original text if the redactor raises, and prompt-injection detection treats detector failure as no detection.

Local proof: with redaction enabled, a nested synthetic dictionary containing an email and password reached the return boundary unchanged; the redactor was never invoked. No external transmission was performed, so this is a demonstrated coverage defect rather than a claim that a real secret was sent.

Fix: recursively scrub structured data, apply deterministic secret filtering before model calls, sanitize both read and write results, and define a visible failure policy when enabled protection cannot run. Treat injection detection as supplemental; authorization and confirmation must remain enforceable without it.

Effort: small-to-medium.

Quick UI and product improvements

7. Confirmed CSS defect: Users and Invitations lose their table background

Evidence: frontend/src/styles/pages/_settings.scss:164, frontend/src/styles/components/_users.scss:75, frontend/src/components/settings/UsersTab.jsx:392, frontend/src/components/settings/InvitationsTab.jsx:319.

Settings normally gives .sk-dtable-wrap a background. A more-specific rule removes it under .users-table-container, assuming that outer wrapper already supplies a surface. The outer wrapper only has overflow, a border, and a radius. Active rows have no resting background; hover and disabled-row styles add color, explaining why the background can appear to come and go.

Fix: give the outer wrapper the shared surface token, or let the shared table wrapper own the surface and remove the redundant shell. Verify Users and Invitations in light/dark themes with active, disabled, empty, loading, and filtered states. Keep this in SCSS.

Effort: very small implementation; short visual check.

8. Make Users a useful access-review screen

The API already returns totp_enabled, passkey_enabled, and auth_provider; the Users table does not expose them. An MFA/passkey/auth-method column and an “Admins without MFA” saved view would make security debt visible using data already available.

Users also hardcodes en-US date formatting, renders status values directly in English, keeps page-local delete-confirmation state, and lacks a pending-state guard around delete/enable/disable actions. Reuse the existing locale, confirmation, and async-action primitives. These are targeted improvements rather than reasons to replace the design system.

Effort: small, well suited to one focused Settings polish change after the security fixes.

9. The frontend needs rendered-state coverage, not just more static rules

The frontend build and all 159 Node tests passed. Lint passed with 0 errors and 923 warnings, including 96 hook-dependency warnings. The style-ownership checker reports 114 shared definitions across 50 class names, accepted by the current ceiling.

The existing checks are useful, but none of those successful checks caught the table-surface contradiction. The inspected frontend CI runs lint and pure-logic Node tests; it has no rendered Settings regression job.

Fix: add a small browser suite for critical Settings states and authentication flows. Start with Users/Invitations/API keys, light/dark themes, errors, and loading states. Review hook warnings where they affect data freshness or permissions; do not spend a sprint mechanically fixing all 923 warnings. A warning ceiling can prevent growth while fixing the backlog gradually.

Effort: small-to-medium initial setup, then add coverage when real regressions justify it.

Hardening backlog, after the demonstrated bypasses

  • AI resource limits: there is a per-conversation cost ceiling and tool-round limit, but the inspected routes do not enforce an aggregate per-user/panel spend quota or an explicit concurrent-stream cap. A new conversation gets a new budget. Add bounded concurrent work, request-size limits appropriate to chat, cancellation-aware queue writes, and aggregate spend accounting. No billing or load stress test was performed.
  • CSP: production permits both unsafe-inline and unsafe-eval in script-src. Inventory extension/runtime requirements, then move toward hashes/nonces and remove unnecessary eval permission. This weakens defense in depth; it is not evidence of a standalone XSS exploit.
  • Security CI scope: the inspected security workflow scans backend Python and requirements, has no schedule, and excludes entire Bandit categories (B602, B402, B321, B202) from its strict gate. Use narrow documented exceptions and include relevant extension sources and dependency manifests. Add periodic dependency scanning so new advisories are checked even without code changes. This review did not run a fresh dependency-advisory audit and makes no claim that current dependencies are vulnerable or clean.
  • Authorization tests: the existing mutation sweep explicitly notes that 404s can hide missing authorization. Add real foreign-owned records and valid payloads, plus restricted keys, pending MFA, disabled users, refresh tokens, sockets, and AI tool calls. The missing dimension is cross-entry-point behavior, not simply the number of tests.

What is already helping

The repo has explicit authorization decorators and ownership helpers, static mutation coverage, tests for scoping and secret filtering, brute-force controls, trusted-proxy handling, security headers, encrypted provider-key storage, and a server-side AI write-confirmation mechanism. Shared SCSS primitives and frontend integrity checks also exist. Build on those mechanisms rather than adding another parallel policy system.

The subprocess spot-check found extensive use of centralized execution helpers; the raw subprocess.run census under backend/app/services found one call, an explicitly documented operator-authored backup hook. The examined archive restores generally use data filters or custom validation. This is not a claim that every subprocess, path validator, installer, extension, or Linux distribution was audited.

Suggested order

Order Work Why
1 Close MFA/login-link and API-key/session-minting chains Direct compromise of intended authentication boundaries
2 Enforce socket token types and room ownership Confirmed cross-user real-time delivery
3 Scope AI tools and fix structured redaction Prevent the assistant from bypassing existing REST visibility
4 Implement session revocation and recent authentication Make password changes and offboarding effective
5 Repair Settings surfaces and expose MFA status Cheap, visible improvement with an operational security benefit
6 Add boundary/visual regressions and targeted hardening Prevent recurrence without another broad rewrite

Validation record

  • Initial targeted backend suite: 31 passed (mutation authorization/static boundaries, JWT-only ratchet, setup security policy, app read scoping, socket protocol contract).
  • Eight temporary isolated review probes: 8 passed, meaning the probes successfully reproduced the current defects. These are not eight passing security protections. They covered the two login-link chains, AI foreign-app disclosure, disabled-user access, password/refresh behavior, structured redaction, socket token types, and cross-user room delivery.
  • Frontend tests: 159 passed.
  • Frontend lint: passed, 0 errors / 923 warnings; project-specific integrity checks passed.
  • Frontend production build: passed; emitted large-chunk warnings. These warnings alone do not establish a runtime performance regression.
  • Extended backend validation: 157 passed in 130.17 seconds (API scopes, AI assistant/attachments, login links, brute force, headers, subprocess ratchet, raw-infrastructure authorization, files RBAC, and trusted client IP). Combined with the initial suite, 188 existing backend tests passed.

Reproduction source is preserved alongside this report as 2026-09-05-security-probes.py, outside the normal test suite. Its module docstring explains how to run it with the existing backend fixtures. After remediation, convert relevant probes into negative security regressions; do not preserve assertions that expect a bypass to succeed.

The temporary reproduction tests use synthetic values only. Production exposure depends on the deployed version and configuration; this review establishes behavior in the inspected checkout, not whether anyone has exploited it.