T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/__init__.py:213- Finding
Configured QMD Collection Scope Is Ignored
- Content
View full analysis
Vulnerability Details
File Location:
scripts/__init__.py:121-123, 213-218
Vulnerability Type: Authorization scope bypass
Risk Level: MediumVulnerable Code
python self.mflow_memory = mflow_memory self.qmd_searcher = QMDSearcher() self.qmd_collections = qmd_collections self.merge_strategy = merge_strategypython qmd_results = self.qmd_searcher.search( query=query, top_k=top_k, collection=None # Search all collections )Technical Analysis
The constructor accepts
qmd_collections, which indicates that callers can configure the collections the pipeline is permitted or intended to search. Although this value is retained inself.qmd_collections, it is not used by_search_qmd.Instead, every search explicitly passes
collection=None. InQMDSearcher.search, a null collection causes the collection predicate to be omitted, resulting in a query across every active collection in the database.This creates an authorization and data-isolation weakness when collection configuration represents a tenant, user, project, or confidentiality boundary. The API gives callers the appearance that retrieval can be scoped, while the actual database operation is unrestricted.
Attack Path
- An application creates
DualRetrievalPipelinewithqmd_collectionsrestricted to one or more authorized collections. - A user submits a query containing terms likely to occur in documents outside the authorized scope.
_search_qmdignores the configured collection list and passescollection=None.QMDSearcher.searchsearches every active collection.- Matching content and metadata from other collections are returned in
qmd_resultsand may be included inmerged_results. - The unauthorized content may subsequently be displayed, logged, or written into a generated report.
Impact Assessment
A user able to invoke the retrieval pipeline may obtain docum ...[truncated 415 chars]
- An application creates
- Remediation
View remediation
Remediation Suggestions
- Enforce
self.qmd_collectionsin_search_qmdrather than passingcollection=None. - If multiple collections are supported, execute a parameterized query for each authorized collection or extend
QMDSearcher.searchto accept a collection list and generate parameter placeholders safely. - Reject searches when a collection scope is required but no authorized collections are configured.
- Do not silently interpret an empty collection list as permission to search all collections.
- Apply authorization at the database-query layer so callers cannot bypass it through an alternate pipeline path.
- Add tests proving that documents from unauthorized collections never appear in direct, merged, logged, or report output.
- Consider associating collection permissions with an authenticated caller identity rather than accepting scope solely from caller-controlled input.
- Enforce
