[Enhancement]: Allow arbitrary file types for “Upload to Code Environment” without broadening other upload paths
What features would you like to see added?
LibreChat should support uploading arbitrary file types through Upload to Code Environment, independently of the MIME restrictions used by:
- Upload to Provider
- Upload as Text
- File Search
- OCR and speech processing
Code execution sandboxes are intended to process files using runtime packages selected by the user or model. Valid sandbox inputs may therefore include formats LibreChat does not parse or send natively to model providers, such as:
- MATLAB
.mscripts - MATLAB
.matdata - Apache Parquet
- domain-specific binary formats
- files with unknown or vendor-specific extensions
At present, these uploads may fail before the file reaches the code environment.
Current behavior
There appear to be two relevant client-side restrictions:
validateFiles()rejects a file wheninferMimeType()cannot determine its MIME type:Unable to determine file type for: filename.matgetViableUploadOptions()only offersexecute_codewhen every file matchescodeInterpreterMimeTypes.
The normal endpoint supportedMimeTypes allowlist is also applied during validation, even when the selected destination is execute_code.
Using this configuration is not an adequate workaround:
fileConfig:
endpoints:
custom:
supportedMimeTypes:
- ".*"It has broader endpoint/provider consequences and still does not resolve files for which the browser supplies no MIME type and inferMimeType() has no extension mapping.
This is the same general MIME-inference limitation described in issues such as #13988 and #11092, but adding extensions individually does not scale for a general-purpose code sandbox.
Desired behavior
When the selected upload destination is specifically:
tool_resource = execute_codeLibreChat should:
- Allow files even when their MIME type cannot be inferred.
- Use
application/octet-streamas the fallback MIME type. - Preserve the original sanitized filename and extension.
- Forward the original bytes to the configured Code Environment.
- Continue enforcing:
- per-file size limits
- total-size limits
- file-count limits
- empty-file checks
- duplicate-file checks
- filename sanitization
- Code Execution capability and authorization checks
Other upload destinations should retain their existing behavior and MIME restrictions.
In particular, this change should not make arbitrary files eligible for provider upload, text extraction, OCR, File Search, or speech processing.
Suggested implementation direction
For toolResource === EToolResources.execute_code only:
- In
validateFiles(), fall back toapplication/octet-streamwheninferMimeType()returns an empty value. - Skip the endpoint MIME allowlist check while retaining all size, count, duplicate, and empty-file validation.
- In
getViableUploadOptions(), consider Code Environment viable even when the MIME type is unknown. - Keep the existing MIME-based eligibility checks for provider, context, OCR, and File Search destinations.
- Ensure server-side upload filtering makes the same destination-specific distinction.
If allowing arbitrary Code Environment uploads by default is considered too broad, an opt-in setting could be introduced, for example:
fileConfig:
code:
allowAllFileTypes: trueThis setting should affect only execute_code.
Acceptance criteria
Given Run Code is enabled:
- A
.matfile with no browser-provided MIME type can be uploaded using Upload to Code Environment. .m,.mat,.parquet,.bin, and an unknown extension such as.researchdatareach the sandbox byte-for-byte.- The files are visible under the sandbox working directory and can be read by Python or another supported runtime.
- The same unknown files remain unavailable through Upload as Text, File Search, and Upload to Provider unless those paths are independently configured to support them.
- Drag/drop, paste, and the attachment menu behave consistently.
- Existing file-size, count, authorization, and filename-safety controls remain enforced.
Security considerations
MIME or filename-extension filtering is useful for choosing parsers and provider routes, but it is not a strong security boundary for a code execution sandbox. The sandbox can already create and manipulate arbitrary byte sequences through executed code.
The security boundary should remain the Code Environment’s isolation, authentication, resource limits, network restrictions, filename sanitization, and blocked filename-pattern controls.
Related work
- #11675 added Parquet MIME support.
- #10908 expanded developer-file MIME inference mappings.
- #13988 / #13989 addressed
.emlthrough another format-specific mapping. - #11092 proposes another individual mapping for
.conf. - #12596 and #14186 support permissive endpoint MIME configuration, but do not provide Code Environment-specific arbitrary-file handling.
Which components are impacted by your request?
- File upload
- Agents / Run Code
- Self-hosted Code Interpreter integration
Code of Conduct
- I agree to follow this project's Code of Conduct
Source: danny-avila/LibreChat