[SERVER-41164] Change Stream pipeline regex matches wrong oplog docs when using '|' pipe in db name Created: 15/May/19 Updated: 29/Oct/23 Resolved: 21/Jun/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 4.0.9, 4.1.11 |
| Fix Version/s: | 4.0.11, 4.2.0-rc2, 4.3.1 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Scott Kurowski | Assignee: | Davis Haupt (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Operating System: | ALL | ||||||||||||
| Backport Requested: |
v4.2, v4.0
|
||||||||||||
| Sprint: | Query 2019-07-01 | ||||||||||||
| Participants: | |||||||||||||
| Case: | (copied to CRM) | ||||||||||||
| Linked BF Score: | 32 | ||||||||||||
| Description |
|
Fix for this ticket also fixes other issues with the following regex special characters: *,+,|,(,),^,?,[,],.,/,\,$. When a pipe is used in a db name, the change stream aggregation on the oplog can return documents for the wrong database or invalidate the stream when creating a collection in the same database. Repro 1 in python 3.7 pymongo 3.8 MongoDB 4.0, 4.1.10 causes an invalidate event to occur on the watched collection when creating a new collection on the same db. It appears to process the implicit create collection oplog entry shown below here,
Repro 2 in the 4.0, 4.1.10 shell on MongoDB 4.0, 4.1.10, the final output document shows a Change Stream on namespace has_a_|pipe.documents.documents match and return an insert from a different db, has_no_pipe.documents :
Both of these seem to be regex failures from unescaped pipes in the regex called here,
Using pipes in db names seems like a poor idea yet customers have tried it, and the risk of documents leaking across databases seems fix-worthy. |
| Comments |
| Comment by Githook User [ 24/Jun/19 ] |
|
Author: {'name': 'Mark Benvenuto', 'email': 'mark.benvenuto@mongodb.com', 'username': 'markbenvenuto'}Message: |
| Comment by Githook User [ 24/Jun/19 ] |
|
Author: {'name': 'Mark Benvenuto', 'username': 'markbenvenuto', 'email': 'mark.benvenuto@mongodb.com'}Message: |
| Comment by Githook User [ 24/Jun/19 ] |
|
Author: {'name': 'Davis Haupt', 'username': 'davish', 'email': 'davis.haupt@mongodb.com'}Message: |
| Comment by Githook User [ 21/Jun/19 ] |
|
Author: {'name': 'Davis Haupt', 'email': 'davis.haupt@mongodb.com', 'username': 'davish'}Message: |
| Comment by Githook User [ 21/Jun/19 ] |
|
Author: {'name': 'Davis Haupt', 'email': 'davis.haupt@mongodb.com', 'username': 'davish'}Message: |
| Comment by Davis Haupt (Inactive) [ 19/Jun/19 ] |
| Comment by Charlie Swanson [ 15/May/19 ] |
|
scott.kurowski thanks for the report. This definitely seems like a bug in the way the regex is being constructed and used. |