Skip to content

Commit 3206241

Browse files
committed
SERVER-41919 Disallow specific types for explicit encryption
1 parent 53d3a9e commit 3206241

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

jstests/client_encrypt/fle_encrypt_decrypt_shell.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ load('jstests/ssl/libs/ssl_helpers.js');
5050
UUID(),
5151
ISODate(),
5252
new Date('December 17, 1995 03:24:00'),
53-
BinData(2, '1234'),
53+
BinData(0, '1234'),
54+
BinData(1, '1234'),
55+
BinData(3, '1234'),
56+
BinData(4, '1234'),
57+
BinData(5, '1234'),
58+
BinData(6, '1234'),
5459
new Timestamp(1, 2),
5560
new ObjectId(),
5661
new DBPointer("mongo", new ObjectId()),
@@ -67,7 +72,8 @@ load('jstests/ssl/libs/ssl_helpers.js');
6772
Code("function() { return true; }")
6873
];
6974

70-
const failTestCases = [null, undefined, MinKey(), MaxKey(), DBRef("test", "test", "test")];
75+
const failTestCases =
76+
[null, undefined, MinKey(), MaxKey(), DBRef("test", "test", "test"), BinData(2, '1234')];
7177

7278
const shell = Mongo(conn.host, clientSideFLEOptions);
7379
const keyVault = shell.getKeyVault();

src/mongo/shell/encrypted_dbclient_base.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ void EncryptedDBClientBase::encrypt(mozjs::MozJSImplScope* scope,
269269
scope->getProto<mozjs::DBRefInfo>().getJSClass() == jsclass) {
270270
uasserted(ErrorCodes::BadValue, "Second parameter cannot be MinKey, MaxKey, or DBRef");
271271
} else {
272+
if (scope->getProto<mozjs::BinDataInfo>().getJSClass() == jsclass) {
273+
mozjs::ObjectWrapper o(cx, args.get(1));
274+
auto binType = BinDataType(o.getNumberInt(mozjs::InternedString::type));
275+
uassert(ErrorCodes::BadValue,
276+
"Cannot encrypt BinData subtype 2.",
277+
binType != BinDataType::ByteArrayDeprecated);
278+
}
272279
if (scope->getProto<mozjs::NumberDecimalInfo>().getJSClass() == jsclass) {
273280
uassert(ErrorCodes::BadValue,
274281
"Cannot deterministically encrypt NumberDecimal type objects.",

0 commit comments

Comments
 (0)