Repository navigation
fix: harden chat workspace file upload input validation - #30184
Merged
Merged
Conversation
- Align the server workspace upload name sanitizer with the frontend
sanitizeChatFileName character set so direct API callers cannot land
shell, quote, or bracket characters in workspace file names.
- Strictly validate workspace_file_media_type on workspace-file-reference
parts (parseable type/subtype, no control characters, at most 255
bytes) and persist the parsed base type. The upload endpoint returns
application/octet-stream for an unparseable Content-Type so its
response always passes message validation.
- Rate limit POST /chats/{chat}/workspace-files per caller across all
chats with a new httpmw.RateLimitPerCaller instead of per path.
The frontend review flagged the JSDoc for pinning coderd's filename rules, which change without touching this file.
Collaborator
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
ibetitsmike
marked this pull request as ready for review
October 27, 2026 00:48
ThomasK33
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hardens the chat workspace-file upload surface (
POST /api/v2/chats/{chat}/workspace-filesand theworkspace-file-referencemessage parts that point at its uploads) against direct API and SDK callers. These are follow-ups from a security review of the upload stack.chatfiles.SanitizeWorkspaceUploadNamenow also replaces( ) [ ] { } ' ` ; , & # $. Together with its existing basename step, it covers the frontendsanitizeChatFileNameset, soa$(b);c'd.txtis stored asa_b_c_d.txt. A provided name that has nothing usable left ($(),CON.txt) now gets "Filename is unusable." instead of the missing-header error.workspace_file_media_typemust be a parseabletype/subtypeof at most 255 bytes with no control characters (newchatfiles.ParseBaseMediaType), and the parsed base type is what gets persisted. The upload endpoint falls back toapplication/octet-streamfor an empty or invalidContent-Type, so themedia_typeit returns always passes message validation.httpmw.RateLimitPerCaller, which ignores the request path. The files budget (12 per minute by default) is therefore per user across all chats, instead of per chat ID or UUID spelling. Owner bypass and IP fallback matchhttpmw.RateLimit.Parts saved earlier through direct API calls with names or media types that are now rejected fail validation if resent through the edit path. The UI never produced such values, so there is no migration. The only frontend change is a JSDoc correction.
Validation
coderd/x/chatfiles,coderd/httpmw,agent/agentfiles, and the coderd workspace-file tests. Each new assertion fails with its production change reverted.ca88295f44band again on7a8c8bb795a: unsafe names over the API, media-type rejects and accepts, theContent-Typefallback, 429 after 12 uploads across two chats, and a UI.zipupload that renders its workspace file chip. The head adds only the JSDoc edit (6335f5d491f), which UAT did not exercise.Review record
coder-frontend-review(8 roles) on the site diff: CD4 and CD5 flagged the JSDoc for listing server rules. Fixed, and the CD re-run passes.test-auditon the branch tests: no changes needed.6335f5d491f, no major issues and no review threads.codex-review-looprequest authorizes.