[SERVER-23670] Prevent creation of database "Admin" or any combination of upper/lowercase letters other than "admin" Created: 13/Apr/16  Updated: 25/Jun/18  Resolved: 25/Jun/18

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 3.0.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Markus Thielsch Assignee: Ben Judd
Resolution: Done Votes: 1
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File SERVER-23670.js    
Issue Links:
Related
Operating System: ALL
Steps To Reproduce:

In order to reproduce follow these steps on a freshly created replica set:

replset:PRIMARY> rs.status()
{
	"set" : "replset",
	"date" : ISODate("2016-04-13T01:39:20.523Z"),
	"myState" : 1,
	"members" : [
		{
			"_id" : 0,
			"name" : "127.0.0.1:27017",
			"health" : 1,
			"state" : 1,
			"stateStr" : "PRIMARY",
			"uptime" : 8,
			"optime" : Timestamp(1460511552, 1),
			"optimeDate" : ISODate("2016-04-13T01:39:12Z"),
			"electionTime" : Timestamp(1460511556, 1),
			"electionDate" : ISODate("2016-04-13T01:39:16Z"),
			"configVersion" : 1,
			"self" : true
		},
		{
			"_id" : 1,
			"name" : "127.0.0.1:27018",
			"health" : 1,
			"state" : 5,
			"stateStr" : "STARTUP2",
			"uptime" : 8,
			"optime" : Timestamp(0, 0),
			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
			"lastHeartbeat" : ISODate("2016-04-13T01:39:18.523Z"),
			"lastHeartbeatRecv" : ISODate("2016-04-13T01:39:18.523Z"),
			"pingMs" : 0,
			"configVersion" : 1
		},
		{
			"_id" : 2,
			"name" : "127.0.0.1:27019",
			"health" : 1,
			"state" : 5,
			"stateStr" : "STARTUP2",
			"uptime" : 8,
			"optime" : Timestamp(0, 0),
			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
			"lastHeartbeat" : ISODate("2016-04-13T01:39:18.523Z"),
			"lastHeartbeatRecv" : ISODate("2016-04-13T01:39:18.523Z"),
			"pingMs" : 0,
			"configVersion" : 1
		}
	],
	"ok" : 1
}
replset:PRIMARY> db.version()
3.0.11
replset:PRIMARY> use Admin
switched to db Admin
replset:PRIMARY> db.Admin.insert({1:1})
WriteResult({ "nInserted" : 1 })
replset:PRIMARY> use gotham
switched to db gotham
replset:PRIMARY> db.arkham.insert({1:1})
WriteResult({ "nInserted" : 1 })
replset:PRIMARY> db.arkham.renameCollection("test")
{ "ok" : 1 }
replset:PRIMARY> rs.status()
2016-04-13T11:40:27.514+1000 I NETWORK  DBClientCursor::init call() failed
2016-04-13T11:40:27.523+1000 E QUERY    Error: error doing query: failed
    at DBQuery._exec (src/mongo/shell/query.js:83:36)
    at DBQuery.hasNext (src/mongo/shell/query.js:240:10)
    at DBCollection.findOne (src/mongo/shell/collection.js:187:19)
    at DB.runCommand (src/mongo/shell/db.js:58:41)
    at DB.adminCommand (src/mongo/shell/db.js:66:41)
    at Function.rs.status (src/mongo/shell/utils.js:937:37)
    at (shell):1:4 at src/mongo/shell/query.js:83
2016-04-13T11:40:27.524+1000 I NETWORK  trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2016-04-13T11:40:27.525+1000 I NETWORK  reconnect 127.0.0.1:27017 (127.0.0.1) ok
replset:SECONDARY> rs.status()
{
	"set" : "replset",
	"date" : ISODate("2016-04-13T01:40:31.705Z"),
	"myState" : 2,
	"members" : [
		{
			"_id" : 0,
			"name" : "127.0.0.1:27017",
			"health" : 1,
			"state" : 2,
			"stateStr" : "SECONDARY",
			"uptime" : 79,
			"optime" : Timestamp(1460511624, 1),
			"optimeDate" : ISODate("2016-04-13T01:40:24Z"),
			"configVersion" : 1,
			"self" : true
		},
		{
			"_id" : 1,
			"name" : "127.0.0.1:27018",
			"health" : 0,
			"state" : 8,
			"stateStr" : "(not reachable/healthy)",
			"uptime" : 0,
			"optime" : Timestamp(0, 0),
			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
			"lastHeartbeat" : ISODate("2016-04-13T01:40:30.642Z"),
			"lastHeartbeatRecv" : ISODate("2016-04-13T01:40:24.625Z"),
			"pingMs" : 0,
			"lastHeartbeatMessage" : "Failed attempt to connect to 127.0.0.1:27018; couldn't connect to server 127.0.0.1:27018 (127.0.0.1), connection attempt failed",
			"configVersion" : -1
		},
		{
			"_id" : 2,
			"name" : "127.0.0.1:27019",
			"health" : 0,
			"state" : 8,
			"stateStr" : "(not reachable/healthy)",
			"uptime" : 0,
			"optime" : Timestamp(0, 0),
			"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
			"lastHeartbeat" : ISODate("2016-04-13T01:40:30.641Z"),
			"lastHeartbeatRecv" : ISODate("2016-04-13T01:40:24.625Z"),
			"pingMs" : 0,
			"lastHeartbeatMessage" : "Failed attempt to connect to 127.0.0.1:27019; couldn't connect to server 127.0.0.1:27019 (127.0.0.1), connection attempt failed",
			"configVersion" : -1
		}
	],
	"ok" : 1
}
replset:SECONDARY> 

Regards,
Markus

Sprint: Storage NYC 2018-07-02
Participants:
Case:

 Description   

When creating a database called "Admin" (or any upper/lowercase letter combination of "Admin" other than "admin") and then executing db.collection.renameCollection() on a different collection crashes all secondaries in a replica set.



 Comments   
Comment by Eric Milkie [ 25/Jun/18 ]

3.0 was the latest version where this was an issue, and 3.0 is no longer supported.

Comment by Ben Judd [ 22/Jun/18 ]

Could not reproduce in latest development version, with either the script above or manual checking. Are we ok closing this?

Comment by Eric Milkie [ 14/Nov/16 ]

In 3.4, the admin database will have been created for new instances before mongod starts listening for connections, so there will be no way to create an Admin database. This is due to writing a featureCompatibilityVersion document into admin.system.version.

Comment by Asya Kamsky [ 21/Jun/16 ]

confirmed this does not cause a crash in 3.2.x

Comment by Markus Thielsch [ 14/Apr/16 ]

I attached a simple jstest for easy replication of the problem.

Generated at Thu Feb 08 04:04:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.