[PR #3821] [CLOSED] Fix Uncontrolled data used in path expression #4420

Closed
opened 2026-02-22 18:35:47 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/3821
Author: @odaysec
Created: 5/13/2025
Status: Closed

Base: masterHead: patch-2


📝 Commits (2)

📊 Changes

1 file changed (+20 additions, -11 deletions)

View changed files

📝 server/utils/files/index.js (+20 -11)

📄 Description

Pull Request Type

https://github.com/Mintplex-Labs/anything-llm/blob/388960e79cfbe6f0726b6e80d8f0542415606f28/server/utils/files/index.js#L180-L190

fix the issue need to ensure that the filename input is properly sanitized and validated before constructing the file path. Specifically:

  1. Use the path.resolve function to normalize the path and remove any .. segments.
  2. Verify that the resolved path starts with the documentsPath to ensure it is confined to the intended directory.
  3. Throw an error or return early if the validation fails.

The normalizePath function should also be updated to provide stricter sanitization, ensuring that the resulting path is safe to use.


  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/3821 **Author:** [@odaysec](https://github.com/odaysec) **Created:** 5/13/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `patch-2` --- ### 📝 Commits (2) - [`4be6d46`](https://github.com/Mintplex-Labs/anything-llm/commit/4be6d46b361f6ff4be9f2e62737025a2c9916728) Update index.js - [`a40988e`](https://github.com/Mintplex-Labs/anything-llm/commit/a40988ee5e995eac6c0c7ed9c217c6362d6b2315) Merge branch 'master' into patch-2 ### 📊 Changes **1 file changed** (+20 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `server/utils/files/index.js` (+20 -11) </details> ### 📄 Description ### Pull Request Type https://github.com/Mintplex-Labs/anything-llm/blob/388960e79cfbe6f0726b6e80d8f0542415606f28/server/utils/files/index.js#L180-L190 fix the issue need to ensure that the `filename` input is properly sanitized and validated before constructing the file path. Specifically: 1. Use the `path.resolve` function to normalize the path and remove any `..` segments. 2. Verify that the resolved path starts with the `documentsPath` to ensure it is confined to the intended directory. 3. Throw an error or return early if the validation fails. The `normalizePath` function should also be updated to provide stricter sanitization, ensuring that the resulting path is safe to use. --- - [ ] ✨ feat - [x] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:35:47 -05:00
yindo closed this issue 2026-02-22 18:35:47 -05:00
yindo changed title from [PR #3821] Fix Uncontrolled data used in path expression to [PR #3821] [CLOSED] Fix Uncontrolled data used in path expression 2026-06-05 15:18:28 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4420