Skip to content

Reference uploads by server filename instead of absolute host path - #159

Open
craig-b wants to merge 1 commit into
zhongkaifu:mainfrom
craig-b:fix/upload-path-leak
Open

Reference uploads by server filename instead of absolute host path#159
craig-b wants to merge 1 commit into
zhongkaifu:mainfrom
craig-b:fix/upload-path-leak

Conversation

@craig-b

@craig-b craig-b commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

/api/upload returns the saved file's absolute host path as path (and extracted video/PDF page images as framePaths), and the Web UI round-trips those into /api/chat, /api/image-edit, and /api/video-generate. That leaks the server's filesystem layout (install location, user name, OS) to every client for no functional reason.

The upload response now carries file — the server-assigned filename — alongside the existing frames names; path and framePaths are gone. On the accept side, a shared UploadFileReference resolver handles all three sites (chat attachments, image-edit imagePath(s), Wan i2v conditioning image): the canonical form is the bare filename joined under the upload directory, and absolute paths from older clients are still accepted when they resolve inside the upload directory — the same containment rule as #146/#152, which this builds on.

API contract change: clients reading path/framePaths from the upload response must switch to file/frames. The accept side stays backward-compatible. Both API_EXAMPLES documents are updated.

Verified locally: new UploadFileReferenceTests + updated guard tests; environment-independent lane 1156 passed / 0 failed on current main.

Touches some of the same server files as #160/#161 (opened alongside) — happy to rebase promptly as the others land.

/api/upload returned the saved file's absolute host path as 'path' (and
extracted video/PDF page images as 'framePaths'), and the Web UI round-
tripped those into /api/chat, /api/image-edit, and /api/video-generate.
That leaked the server's filesystem layout (install location, user name,
OS) to every client for no functional reason: the server can resolve its
own upload directory.

The upload response now carries 'file' — the server-assigned filename —
and the existing 'frames' names; 'path' and 'framePaths' are gone. On
the accept side a shared UploadFileReference resolver handles chat
attachments (imagePaths/audioPaths/textFilePaths), image-edit
imagePath(s), and the Wan i2v conditioning image: the canonical form is
the bare filename, joined under the upload directory; absolute paths
from older clients are still accepted when they resolve inside the
upload directory (the same containment rule as PR zhongkaifu#146, which this
builds on). ChatMessageParser.ValidateAttachmentPaths becomes
ResolveAttachmentPaths — it now rewrites the lists to resolved full
paths rather than only validating.

The Web UI sends the returned filenames, and both API_EXAMPLES docs
describe the new contract.

Verified: /api/upload returns no absolute paths; resolver unit tests
cover filename/absolute/traversal/sibling-prefix cases for chat and the
Wan parser; inner-loop suite 1395 green.
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