[SERVER-71049] crypt_shared emits log messages to stdout when loaded by libmongocrypt Created: 03/Nov/22  Updated: 29/Oct/23  Resolved: 23/Nov/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.3.0-rc0, 6.0.5

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Erwin Pe
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
causes PHPC-2156 Encryption tests on MongoDB latest fa... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.2, v6.0
Sprint: Security 2022-11-28
Participants:

 Description   

Several drivers have noticed unexpected output when running some CSFLE tests with crypt_shared on the "latest" server version (6.2-dev). From my own tests related to PHPC-2156, I observed several log emitted to stdout when libmongocrypt was initialized (and crypt_shared linked) and once again when the process terminated.

Consider the following script:

<?php
 
define('CSFLE_LOCAL_KEY', base64_decode('Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk'));
 
$driverOptions = [
  'autoEncryption' => [
    'keyVaultNamespace' => 'encryption.__keyVault',
    'kmsProviders' => ['local' => ['key' => new MongoDB\BSON\Binary(CSFLE_LOCAL_KEY, 0)]],
    'extraOptions' => ['cryptSharedLibPath' => getenv('CRYPT_SHARED_LIB_PATH')],
  ],
];
 
echo "A\n";
new MongoDB\Driver\Manager(getenv('MONGODB_URI'), [], $driverOptions);
echo "B\n";

Executing this against 6.2.0-dev produced the following output:

A
{"t":{"$date":"2022-11-03T09:11:38.035Z"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
B
{"t":{"$date":"2022-11-03T09:11:38.037Z"},"s":"I",  "c":"ASIO",     "id":6529201, "ctx":"main","msg":"Network interface redundant shutdown","attr":{"state":"Stopped"}}
{"t":{"$date":"2022-11-03T09:11:38.037Z"},"s":"I",  "c":"ASIO",     "id":22582,   "ctx":"main","msg":"Killing all outstanding egress activity."}

The exact version of mongod and crypt_shared used to reproduce this is as follows:

Specific version info from the mongod's buildInfo:

version: '6.2.0-alpha-1387-g2e4717a',
gitVersion: '2e4717ad14a2d6ce480c34d262476dd6cc11759c',



 Comments   
Comment by Andreas Braun [ 01/Feb/23 ]

erwin.pe@mongodb.com the issue still poses a problem for us, as any PHP user using crypt_shared older than 6.3 will have log output sent to STDOUT. Since PHP sends STDOUT to the client, this can cause a number of issues, from log output in a rendered web page to more severe errors related to HTTP header sending.
Could we please have this backported to 6.0, 6.1, and 6.2?

Comment by Githook User [ 23/Nov/22 ]

Author:

{'name': 'Erwin Pe', 'email': 'erwin.pe@mongodb.com', 'username': 'erwee'}

Message: SERVER-71049 stop mongo_crypt shared library from logging to stdout when loaded
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/4b476c18c8083912a3a1ba2f6c9083d48015ee41

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