api-mongo-agg-facet-bypass
Installation
SKILL.md
MongoDB aggregation injection — $facet allowlist bypass → cross-collection read
When it applies
- An API runs a user-controlled aggregation pipeline on a fixed collection
(
db.collection('x').aggregate(userPipeline)), usually exposed as apipelinequery/body parameter for "advanced" search. - The server defends with a stage allowlist — only screens the top-level stage
names (
$match/$project/$sort/$limit/$facetallowed;$lookup/$unionWith/$group/…rejected with something like"invalid or disallowed pipeline stage"). - Tell-tale that a
pipelineparam even exists: sending the normal search term as a Mongo operator object (?q[$ne]=x) returns a hint such as"Operator-form queries not accepted on 'q'. Use the 'pipeline' parameter…".