Skip to content

fix(server): #323 block external access to file and internal actions - #327

Merged
moonrailgun merged 1 commit into
masterfrom
moonrailgun/v1.11.18-file-service-root-rce-jwt
Nov 25, 2026
Merged

moonrailgun merged 1 commit into
masterfrom
moonrailgun/v1.11.18-file-service-root-rce-jwt

Conversation

@moonrailgun

@moonrailgun moonrailgun commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #323

Summary by CodeRabbit

  • Bug Fixes
    • File save requests now require an authenticated user and a valid upload stream; invalid requests are rejected.
    • File actions are no longer available through Socket.IO or the /api gateway, and unpublished actions return 404 responses.
    • Upload requests without valid authentication return 401 responses. Uploads through supported HTTP routes remain available to authenticated users.
    • File upload logs no longer include authentication tokens.
    • Static file responses now include attachment and nosniff headers.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

File actions are excluded from Socket.IO and /api routes. The file service validates upload identity and stream shape, and integration tests cover route access, authentication, uploads, and static-file responses.

Changes: Gateway and file-action access control

Layer / File(s) Summary
Define action exposure boundaries
server/mixins/socketio.mixin.ts, server/mixins/__tests__/socketio.spec.ts, server/services/core/file.service.ts, server/services/core/gateway.service.ts, server/packages/sdk/src/services/lib/moleculer-web/index.ts, server/services/core/group/group.service.ts, server/services/openapi/app.service.ts
The Socket.IO blacklist and /api whitelist exclude file actions. file.save disables Socket.IO, and selected actions are explicitly marked public. Tests check rejection of file actions over Socket.IO.
Validate file uploads
server/services/core/file.service.ts, server/test/integration/file/file.spec.ts
file.save rejects requests without a user ID and invalid upload streams. Its metadata log omits the token and translation function. Tests check rejection behavior and confirm the save operation is not called for invalid requests.
Exercise gateway access and upload routes
server/test/integration/gateway/gateway.spec.ts, server/test/integration/gateway/gatewayAccessControl.spec.ts
Integration tests check responses for unpublished routes, upload authentication, authenticated uploads, static-file headers, and the published file action list.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: High

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Gateway
  participant FileService
  participant saveFileStream
  Client->>Gateway: Send upload request with token
  Gateway->>FileService: Forward authenticated upload
  FileService->>saveFileStream: Pass user ID and stream
  saveFileStream-->>FileService: Return result or error
Loading

Possibly related issues

  • msgbyte/tailchat#323: The issue reports external access to file reads and writes. This change blocks external routes to file actions, but does not establish that the additional impacts described in the issue are resolved.
Merge Risk: Minimal · up to cb778

This change blocks external Socket.IO and /api access to file actions and rejects uploads with no user identity or an invalid stream. It adds integration tests for route access, authentication and uploads. No concrete merge-blocking risk was found, though the tests have not been run.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: blocking external access to file actions and internal actions in the server. The changeset adds a blacklist entry for the file.* namespace in the Socket.IO mixin, bloc…
Full details: Title check

Explanation

The title names the main change: blocking external access to file actions and internal actions in the server. The changeset adds a blacklist entry for the file.* namespace in the Socket.IO mixin, blocks file.* routes under /api in the gateway, restricts file.save with new permission and stream checks, and adds tests for these controls. The title's '#323' reference does not match the PR objectives, which cite PR #327. That mismatch does not affect the title's relevance to the change, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c4e9b807-e21d-479a-9aa1-8d49f732f8bf
Commits

Reviewing files that changed from the base of the PR and between dee3553 and cb77882.

Files selected for processing: 10

  • server/mixins/__tests__/socketio.spec.ts
  • server/mixins/socketio.mixin.ts
  • server/packages/sdk/src/services/lib/moleculer-web/index.ts
  • server/services/core/file.service.ts
  • server/services/core/gateway.service.ts
  • server/services/core/group/group.service.ts
  • server/services/openapi/app.service.ts
  • server/test/integration/file/file.spec.ts
  • server/test/integration/gateway/gateway.spec.ts
  • server/test/integration/gateway/gatewayAccessControl.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@netlify

netlify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tailchat-nightly ready!

Name Link
🔨 Latest commit cb77882
🔍 Latest deploy log https://app.netlify.com/projects/tailchat-nightly/deploys/6b06fe8d53d8b6a3230c94f1
😎 Deploy Preview https://deploy-preview-327--tailchat-nightly.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@moonrailgun moonrailgun changed the title fix(server): block external access to file and internal actions fix(server): #323 block external access to file and internal actions Nov 25, 2026
@moonrailgun
moonrailgun merged commit 1f9e22c into master Nov 25, 2026
8 of 9 checks passed
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.

严重问题 (v1.11.18):file service 任意文件读写导致容器 root,RCE、持久化与 JWT 外泄

1 participant