[SERVER-65033] Invalid currentOp commands are run without validation Created: 29/Mar/22  Updated: 06/Apr/23  Resolved: 06/Apr/23

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

Type: Improvement Priority: Minor - P4
Reporter: Kevin Mas Ruiz Assignee: Michael Gargiulo
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Participants:

 Description   

It seems that the server is not validating the format of the currentOp command, thus sometimes resolving to an unexpected behaviour for the client.

The behaviour is easily reproducible using pymongo 4.0.2 and mongo 5.0.6 as follows:

1. Start a new mongod instance and insert some sample data.

2. Run the following Python snippet:

client = MongoClient(uri)
db = client['admin']
 
db.command('currentOp')

3. See there are a few operations that ran.

4. Run the following Python snippet, now with an invalid command format. 

client = MongoClient(uri)
db = client['admin']
 
db.command('currentOp', { 'secs_running': { '$gt': 10 }})

5. It should show similar results to the previous run, even if the $gt filter is ignored (the format of the command is invalid).

What the server received is an invalid command with the following format

{currentOp: { 'secs_running': { '$gt': 10 }}}

And the behaviour seems to run the currentOp command without filters.



 Comments   
Comment by Spencer Jackson [ 08/Apr/22 ]

My apologies, the above two commits were backports intended to be labelled as SERVER-65032.

Comment by Githook User [ 08/Apr/22 ]

Author:

{'name': 'Shreyas Kalyan', 'email': 'shreyas.kalyan@10gen.com', 'username': 'shreyaskalyan'}

Message: SERVER-65033

(cherry picked from commit f909fbe1731e0e04a3a4e48edc032530ac6499ea)
Branch: v5.0
https://github.com/mongodb/mongo/commit/3a2d3b25675702f89e2280d3e78e743660b66616

Comment by Githook User [ 08/Apr/22 ]

Author:

{'name': 'Shreyas Kalyan', 'email': 'shreyas.kalyan@10gen.com', 'username': 'shreyaskalyan'}

Message: SERVER-65033

(cherry picked from commit f909fbe1731e0e04a3a4e48edc032530ac6499ea)
(cherry picked from commit 2bbc15e7a70cde042c6d23954a7a3032275ddfc4)
Branch: v4.4
https://github.com/mongodb/mongo/commit/e53fc6ec067e9787a2dc2a8975e819d8a781f8bd

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