[SERVER-14739] Escape control characters in log messages Created: 31/Jul/14  Updated: 31/Aug/20  Resolved: 31/Aug/20

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: 2.6.3, 2.7.4
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Gianfranco Palumbo Assignee: Spencer Jackson
Resolution: Duplicate Votes: 1
Labels: move-sec
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-44623 Implement Extended Relaxed JSON 2.0 a... Closed
Related
is related to SERVER-16620 escape double quotes \" when printing... Closed
Operating System: ALL
Steps To Reproduce:

map reduce example

db.things.insert( { _id : 1, tags : ['dog', 'cat'] } );
db.things.insert( { _id : 2, tags : ['cat'] } );
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } );
db.things.insert( { _id : 4, tags : []  } );
 
var map = function() {
  var things = this;
  things.tags.forEach( function(elem) {
      emit( elem , { count : 1 } );
    }
  );
};
 
var reduce = function( key , values ) {
  var total = 0;
  for ( var i=0; i<values.length; i++ ) {
    total += values[i].count;
  }
  return { count : total };
};
var res = db.things.mapReduce(map, reduce, { out : "myoutput" } );

insert example

db.things.insert( { a : 'asdf\n  asdf' } );

master (f7df4c7)

$ mongod --v
2014-07-31T10:56:53.753+0100 I COMMANDS [conn1] command test.$cmd command: mapReduce { mapreduce: "things", map: function () {
  var things = this;
  things.tags.forEach( function(ele..., reduce: function ( key , values ) {
  var total = 0;
  for ( var i=0; i<values..., out: "myoutput" } planSummary: COLLSCAN keyUpdates:0 numYields:0 locks(micros) r:2756 w:1818 reslen:205 24ms
 
2014-07-31T10:57:30.833+0100 I COMMANDS [conn1] insert test.things query: { _id: ObjectId('53da130a998eaf05e7f22c7c'), a: "asdf
  asdf" } ninserted:1 keyUpdates:0 numYields:0 locks(micros) w:81 0ms

2.6.3

$ mongod --v
 
2014-07-31T10:39:52.109+0100 [conn1] command test.$cmd command: mapReduce { mapreduce: "things", map: function () {
  var things = this;
  things.tags.forEach( function(ele..., reduce: function ( key , values ) {
  var total = 0;
  for ( var i=0; i<values..., out: "myoutput" } planSummary: COLLSCAN keyUpdates:0 numYields:0 locks(micros) r:6729 w:5992 reslen:175 71ms
 
2014-07-31T10:40:00.955+0100 [conn1] insert test.things query: { _id: ObjectId('53da0ef0998eaf05e7f22c7a'), a: "asdf
  asdf" } ninserted:1 keyUpdates:0 numYields:0 locks(micros) w:83 0ms

Sprint: Security 2020-09-07
Participants:

 Description   

We should consider escaping control characters in user-supplied data when it is printed in the server log.



 Comments   
Comment by Spencer Jackson [ 31/Aug/20 ]

This issue is resolved in 4.4.0 by Structured Logging.

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