Path traversal via stored raw docpath allows a manager to write/read files outside storage/documents
Résumé
Summary
AnythingLLM validates a document path at ingest using a normalized copy of the input, but
persists the original (un-normalized) string as the document's docpath. Background jobs and
document helpers later re-resolve that stored raw docpath against storage/documents **withou...
Description d'origine La description telle que publiée par la source (souvent en anglais).
Summary
AnythingLLM validates a document path at ingest using a normalized copy of the input, but
persists the original (un-normalized) string as the document's docpath. Background jobs and
document helpers later re-resolve that stored raw docpath against storage/documents without
any containment (isWithin) check. As a result, a user with the manager (or admin) role can
cause the server to write a document-JSON file to a chosen path outside storage/documents,
overwriting existing writable files on the host, and can cause reads outside the directory as well.
Details (root cause)
Verified against source at commit 65f83f3e47192843ded1228acdff86b00106c0cc (v1.16.1-era master):
server/models/documents.jsaddDocuments()validates viafileData(path)(which normalizes
and enforcesisWithin) at line 109, but then stores the rawpathintodocpathat
line 124 (docpath: path). The native embedder worker
server/jobs/embedding-worker.js:94stores the rawfilePaththe same way.server/jobs/sync-watched-documents.js:149passes the stored rawdocument.docpathinto
updateSourceDocument(...).server/jobs/helpers/index.jsupdateSourceDocument()does
path.resolve(documentsPath, docPath)(line 24) andfs.writeFileSync(...)(line 25)
with noisWithincheck (function body lines 23–28).- The read sink
server/utils/DocumentManager/index.js:38
(`path.resolve(this.documentSto…
Source: GitHub Repository Security Advisories (Game のスタック) GitHub Advisory OSV
Références
- GITHUB_REPO_ADVISORY Mintplex-Labs/anything-llm