summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@mongodb.com>2019-10-21 13:56:39 +0000
committerevergreen <evergreen@mongodb.com>2019-10-21 13:56:39 +0000
commit0d740a44335d3835ad0e947115c6fc8cf5e2122f (patch)
treede4a06e5a61e92c3ec53e7add4d041a8b9f29de0 /src/mongo
parent958f8cabe81a9782247a96ccd96b08377afa9005 (diff)
downloadmongo-0d740a44335d3835ad0e947115c6fc8cf5e2122f.tar.gz
SERVER-43287 Prevent from outputting to system collections
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/pipeline/document_source_merge.cpp8
-rw-r--r--src/mongo/db/pipeline/document_source_out.cpp4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_merge.cpp b/src/mongo/db/pipeline/document_source_merge.cpp
index 119219b9e7b..a804dc921f9 100644
--- a/src/mongo/db/pipeline/document_source_merge.cpp
+++ b/src/mongo/db/pipeline/document_source_merge.cpp
@@ -377,6 +377,14 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceMerge::create(
"{} cannot be used with a 'linearizable' read concern level"_format(kStageName),
readConcernLevel != repl::ReadConcernLevel::kLinearizableReadConcern);
+ uassert(31319,
+ "Cannot {} to special collection: {}"_format(kStageName, outputNs.coll()),
+ !outputNs.isSystem());
+
+ uassert(31320,
+ "Cannot {} to internal database: {}"_format(kStageName, outputNs.db()),
+ !outputNs.isOnInternalDb());
+
if (whenMatched == WhenMatched::kPipeline) {
if (!letVariables) {
// For custom pipeline-style updates, default the 'let' variables to {new: "$$ROOT"},
diff --git a/src/mongo/db/pipeline/document_source_out.cpp b/src/mongo/db/pipeline/document_source_out.cpp
index 1208bcea38b..860d9028bec 100644
--- a/src/mongo/db/pipeline/document_source_out.cpp
+++ b/src/mongo/db/pipeline/document_source_out.cpp
@@ -199,6 +199,10 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceOut::create(
"Can't {} to special collection: {}"_format(kStageName, outputNs.coll()),
!outputNs.isSystem());
+ uassert(31321,
+ "Can't {} to internal database: {}"_format(kStageName, outputNs.db()),
+ !outputNs.isOnInternalDb());
+
return new DocumentSourceOut(std::move(outputNs), expCtx);
}