Securely Storing Sensitive Data in OpenSearch - 05/01/2025

A comprehensive guide to protecting sensitive data like Bitlocker keys when migrating from SurrealDB to OpenSearch, featuring best practices and defense-in-depth strategies.

Introduction

Migrating sensitive data, such as Bitlocker keys or credentials, from systems like SurrealDB (where access might be tightly controlled via custom APIs) to OpenSearch requires careful planning. A primary concern is preventing unauthorized visibility or exposure of this data, especially through powerful tools like OpenSearch Dashboards.

This document outlines the best, most secure approaches to achieve robust data protection within the OpenSearch ecosystem, leveraging a defense-in-depth strategy.

Core Principle: No single feature is a silver bullet. The highest level of security comes from layering multiple controls effectively.


Approach 1: Highest Security - Application-Level Encryption + Layered Controls

This approach offers the maximum protection for sensitive data within OpenSearch, as the platform itself never handles the plaintext values of your most sensitive fields.

Concept: Your application encrypts the sensitive data before sending it to OpenSearch. OpenSearch stores only the ciphertext. Decryption happens outside OpenSearch in a controlled application environment.

Data Flow Diagram (Mermaid):

sequenceDiagram
    participant App as Application
    participant KMS as Key Management Service
    participant OS as OpenSearch Cluster
    participant SecApp as Secure Retrieval App/Tool

    App->>+KMS: Request Encryption Key
    KMS-->>-App: Provide Encryption Key
    App->>App: Encrypt Sensitive Data (e.g., Bitlocker Key)
    App->>+OS: Index Document (with Ciphertext Field)
    OS-->>-App: Confirm Indexing

    %% Data Retrieval Flow
    SecApp->>+KMS: Request Decryption Key (for specific data)
    KMS-->>-SecApp: Provide Decryption Key
    SecApp->>+OS: Query Document (by non-sensitive fields)
    OS-->>-SecApp: Return Document (with Ciphertext Field)
    SecApp->>SecApp: Decrypt Ciphertext Field
    SecApp->>User/System: Present Plaintext Data

Key Components:

Pros:

Cons:


Approach 2: Strong Security - Granular Access Control (FLS/DLS) + Encryption

This approach leverages OpenSearch’s powerful built-in security features to control access within the platform. It’s often more practical if application-level encryption is too complex, but requires meticulous configuration.

Concept: Data is stored plaintext (or encrypted-at-rest) in OpenSearch, but the Security Plugin strictly controls who can see which fields or documents via sophisticated Role-Based Access Control, Field-Level Security (FLS), and Document-Level Security (DLS).

Access Control Flow Diagram (Mermaid):

graph LR
    User(User/Application) -- Credentials --> AuthN[1. Authentication Service];
    AuthN -- Role Info --> RBAC[2. RBAC Check];
    User -- Request (e.g., Search Query) --> RBAC;
    RBAC -- Filtered Request --> AccessControl[3. FLS/DLS/Masking Filter];
    AccessControl -- Query --> DataStore[(OpenSearch Index<br/>Encrypted-at-Rest)];
    DataStore -- Raw Results --> AccessControl;
    AccessControl -- Filtered/Masked Results --> User;

    subgraph OpenSearch Security Plugin
        AuthN
        RBAC
        AccessControl
    end

    subgraph OpenSearch Storage
        DataStore
    end

    style DataStore fill:#f9f,stroke:#333,stroke-width:2px

Key Components:

Pros:

Cons:


Essential Supporting Measures (Apply to BOTH Approaches)

Regardless of the primary approach chosen, these are fundamental:


Conclusion

Always perform thorough security reviews and testing before deploying sensitive data into any system.