Our valued client, a leading healthcare provider, handles a large amount of sensitive data, including patient medical records and health information. With stricter data privacy regulations, securing this information is crucial for maintaining trust and compliance. To address this, we suggested using Protecting Sensitive Data: Queryable Encryption in MongoDB link
Challenges:
Yet another client, a leading financial services company, handles a large amount of sensitive data, including customer financial information and transaction records needed to secure their MongoDB database against potential data breaches while ensuring regulatory compliance. However, they were using an older version of MongoDB that doesn’t support queryable encryption. Traditional security measures were insufficient, so a more advanced solution was needed to protect sensitive data from unauthorized access. They required encrypted data that could still be queried securely.
Solution:
To meet the client’s needs, we proposed a data-masked, read-only view in MongoDB. MongoDB’s view functionality allows us to define data categories accessible to clients. By securing these views with role-based access controls (RBAC), only authorized users can view the data.
Implementation:
We identified Personally Identifiable Information (PII) such as social security numbers, card names, secret codes, and transaction details as the primary targets for masking. We designed a data-masked, read-only view to ensure this sensitive information is obfuscated and accessible only to authorized users.
Sample:
For example, we identified card_name, card_num, and card_sec_code as PII data. We mask these fields so they cannot be deciphered.
Rs0 [direct: primary] Bank> db.customers_info.find()[ { _id: ObjectId('6648829655fef720c5bde3ed'), card_name: 'Mr.Rexjo moj', card_num: '8765345728934565', card_expiry: ISODate('2024-12-13T08:58:42.920Z'), card_sec_code: '123', card_provider_name: 'Credit MasterCard Gold', card_type: 'CREDIT', transaction_id: 'ab2ty77836e8713656d9bf2debba8900', transaction_date: ISODate('2024-05-13T09:32:07.000Z'), transaction_amount: Decimal128('5000.98') }]Aggregation part of data masking
var MasksStage1 = { //TEXT REPLACEMENT WITH ASTERISK 'card_sec_code': '***', //TEXT OBFUSCATION RETAINING LAST NUMBER, eg: '1234567890123456' -> 'XXXXXXXXXXXX3456' 'card_num': {'$concat': [ 'XXXXXXXXXXXX', {'$substrCP': ['$card_num', 12, 4]}, ]}, //TEXT OBFUSCATION RETAINING LAST WORD, eg: 'Mrs. Jane A. Doe' -> 'Mx. Xxx Doe' (needs post-processing in a subsequent pipeline stage) 'card_name': {'$regexFind': {'input': '$card_name', 'regex': /(\S+)$/}},};var MasksStage2 = { //PARTIAL TEXT OBFUSCATION RETAINING LAST WORD (post processing from previous regex operation to pick out 'match') 'card_name': {'$concat': ['Mx. Xxx ', {'$ifNull': ['$card_name.match', 'Anonymous']}]},};//FULL PIPELINE var pipeline = [ {'$set': MasksStage1}, {'$set': MasksStage2},];Create a view with the masked data:
db.createView('customers_info_view', 'customers_info', pipeline);
Output of the masked data
Rs0 [direct: primary] Bank> db.customers_info_view.find()[ { _id: ObjectId('6648829655fef720c5bde3ed'), card_name: 'Mx. Xxx moj', card_num: 'XXXXXXXXXXXX4565', card_expiry: ISODate('2024-12-13T08:58:42.920Z'), card_sec_code: '***', card_provider_name: 'Credit MasterCard Gold', card_type: 'CREDIT', transaction_id: 'ab2ty77836e8713656d9bf2debba8900', transaction_date: ISODate('2024-05-13T09:32:07.000Z'), transaction_amount: Decimal128('5000.98') }]Here you can see card_name,card_num and card_sec_code fields are masked in a way that they cannot be deciphered.
Additional features that can be achieved through the data masking, which will be covered in the upcoming blogs.
Implementing data masking in MongoDB provides our client with a strong security measure to protect sensitive information and maintain regulatory compliance. Using MongoDB’s encryption capabilities, we ensure that customer data is protected from unauthorized access, strengthening trust in our client’s services.
At Mafiree, we are dedicated to delivering customized solutions to meet your specific security needs. For inquiries or assistance with data masking and enhancing data security in MongoDB, please contact us.
Miru IT Park, Vallankumaranvillai,
Nagercoil, Tamilnadu - 629 002.
Unit 303, Vanguard Rise,
5th Main, Konena Agrahara,
Old Airport Road, Bangalore - 560 017.
Call: +91 6383016411
Email: sales@mafiree.com