Masking sensitive fields in OpenSearch

OpenSearch field masking replaces string values with a per-role, per-index hash so some roles see documents without the raw personal or secret value. This page covers how it works, the compliance salt, the loss of search, and the alternatives to plan before you enable it.

On this page

When field masking in OpenSearch fits and when it does not

Field masking fits when your logs or documents hold personal or secret values, such as email addresses, account numbers or tokens, and some roles still need to see the rest of each document but not the raw value. The OpenSearch Security plugin handles this by replacing the field's string value with a cryptographic hash, and the hash is computed per role and per index, so the same input can produce different output for different roles. Before you commit, confirm that the fields you want to mask are string fields, because the field masking documentation states that masking works only on string fields. Numeric, date and other non-string fields need a different control, such as field-level security or a change to what is indexed.

The core trade-off is that masked fields cannot be searched. A user who sees a hashed value cannot run a match query on the original value, and a hashed field gives an investigator no way to find every event for one customer or one card number. Decide early which questions your analysts must answer from masked fields. If they need to correlate on an identifier, masking the field outright is the wrong tool, and you should plan a separate, tightly controlled path for that lookup. Ask whether a field is needed for search, aggregation or display only, since the answer determines whether masking is appropriate at all.

Masking also needs a clear boundary with its neighbors. Document-level and field-level security remove data from a role's view entirely and keep the field searchable for roles that can read it, so they suit cases where the unauthorized role should not see the value in any form. Masking is a better fit when a role must see that a value exists and that the record is complete, while still being unable to read the original. Confirm the exact behavior of each control in the OpenSearch field masking documentation against the version you run, and test the result with a non-admin account before you rely on it for an audit.

How a masked field reaches each role

The diagram starts with two users querying the same index through the OpenSearch Security plugin. For the masked role, the plugin replaces the string value with a cryptographic hash, and the compliance salt is one input to that hash. For the unmasked role, the plugin returns the raw value unchanged. Check that the masked role's searches on that field are planned, because a hashed field cannot be searched.

Two roles query one index, and the Security plugin returns hashed or raw string values by role.

Field masking options and when each fits

This table compares the building blocks available for hiding values in OpenSearch and the search or operational cost of each. Read it by first deciding whether a field is a string, then whether the role needs a hashed view or no view at all, and treat the masked-search cost as the deciding factor.

OptionWhen it fitsWhat it costs in search or operations
Field masking per roleA role must see that a string value exists but not its content, such as a customer email shown as a stable token to support staffMasked fields cannot be searched, sorted or matched on, so queries must use fields that remain unmasked
Compliance salt (plugins.security.compliance.salt)You want hashes that cannot be trivially reversed by comparing against known values across deploymentsMust be at least 16 ASCII characters and is highly recommended; losing or changing it changes masked outputs, so store it in your secrets process and confirm rotation behavior with your team
String-only fieldsPersonal identifiers and secrets held in text fields, which is where masking appliesNumeric, date, boolean and other non-string fields cannot be masked, so they need a different control such as field-level security or ingest-time removal
Field-level securityA role should not see certain fields at all, rather than a hashed version of themHidden fields are absent from results for that role; confirm the behavior in your version and test queries that reference the field
Document-level securityA role should see only some documents in an index, such as one region or business unitAdds a query filter to every search for that role; query design and cluster load should be tested, and DLS does not restrict writes
Separate index or pipeline-level removalSensitive values should never reach the index for any role, or must be retained only in a restricted storeRequires ingest-time processing or index design work and a plan for reprocessing existing data; confirm the approach with your data owners

What the compliance salt changes and how to set it

The plugins.security.compliance.salt setting is optional, but the OpenSearch documentation highly recommends it for field masking. Any value you set must be at least 16 ASCII characters. Without a salt, the masking hash is derived only from the value and the role and index context, so anyone who knows or can guess a masked value, such as a common account number format, can compare hashes across systems and confirm matches. The salt makes those comparisons much harder, which matters when masked exports from one cluster are shared with another team or system that needs to match records without seeing the raw values.

Treat the salt as a secret, not as a tuning parameter. Store it in the same secrets manager that holds your other cluster credentials, restrict who can read the opensearch.yml file or the configuration source that renders it, and keep it out of version control and tickets. Confirm with your security team who may rotate it and how that change is approved. Also confirm how your configuration management tool deploys the value to every node, because a node that runs with a different salt will produce different hashes for the same input and will break matching silently.

Changing the salt changes the hashes. Values masked under the old salt will not match values masked under the new one, so any downstream join, deduplication or reconciliation that depends on the hashes will break at the cutover. Decide the salt before go-live, record it in your data handling documentation, and write down how you would re-mask historical exports if you ever must rotate it. Test the full path on a non-production cluster with sample data, comparing the hashes produced by each node, before you load real records.

How to configure field masking safely

This sequence takes you from identifying which string fields hold personal or secret values to proving that masked roles see hashed values and cannot search them. Each step ends with a check, so the masking is verified before any user depends on it.

  1. Inventory string fields holding sensitive values

    List every index and string field that stores personal or secret values, such as email addresses, national identifiers, account numbers or tokens. Include fields that arrive through ingest pipelines or application logs, because they are easy to miss. Field masking only applies to string fields, so note any sensitive value stored as a number, date or nested object, since it needs a different control. The step is complete when the team has a reviewed list of index and field pairs signed off by the data owner.

  2. Decide which roles see raw and masked values

    For each sensitive field, map the roles that need the actual value and the roles that only need to know a record exists or can be matched across records. Write this as a short access matrix that lists index, field, role and visibility. Confirm the matrix with the compliance or privacy owner before any configuration changes. The step is complete when every role that can read a sensitive index has an explicit decision, including roles that only inherit access through backend roles.

  3. Define masked fields in role permissions

    In the Security plugin, add the field masking entry to the role definitions for the masked-view roles, scoped to the index patterns and fields from the matrix. Keep the unmasked roles on their existing permissions so they continue to read raw values. Store the role definitions in version-controlled YAML so the change can be reviewed and rolled back. The step is complete when the roles load without errors and a role-by-role review shows each field mapped to exactly one visibility setting.

  4. Set and store the compliance salt

    Set plugins.security.compliance.salt in opensearch.yml on every node, using a value of at least 16 ASCII characters. The salt is optional, but it is highly recommended, because it makes the hashed values harder to reverse by comparing against known inputs. Store the value in your secrets manager, not in the repository, and record who can read it. Confirm the value is identical on all nodes so hashes stay consistent across the cluster. Any change to the salt changes every masked value, so plan that change as a controlled event. The step is complete when the setting is present on every node and the value is recorded in the secrets system.

  5. Apply the security configuration and restart nodes

    Apply the updated role and configuration files with securityadmin.sh using an admin certificate, then restart nodes so the salt setting takes effect. Confirm that the security index reflects the new roles and that the cluster reports healthy after the restart. Check the audit trail for the configuration change. The step is complete when the cluster is green, the configuration version matches the change record, and no node reports a configuration error.

  6. Test with a masked user

    Sign in as a test user in a masked-view role and retrieve a document that contains a sensitive field. Confirm the value comes back as a hash rather than the original text. Then run a search on the masked field using a term that exists in the raw data and confirm that it returns no hits, since masked fields cannot be searched. Check that a search on an unmasked field still returns the expected documents. The step is complete when the masked user sees only hashes and the search behavior matches the documented limits.

  7. Test with an unmasked user

    Sign in as a test user in a role without masking and retrieve the same document. Confirm the raw value is visible and that a search on the sensitive field returns the expected hit. Then verify that the two users see different values for the same document, which shows the masking is applied by role rather than by index. Record the test results with the role names, index names and field names used. The step is complete when both user types produce the expected results and the evidence is saved for the compliance file.

  8. Document the search limits for users

    Give dashboard authors and analysts a written note that masked fields cannot be searched or aggregated on the masked view, and list the alternative ways to meet their needs, such as searching on a non-sensitive identifier or using an unmasked role for approved investigations. Review Dashboards visualizations that use the masked fields, since they may show hashes or empty results. The step is complete when the note has been shared, the affected dashboards are reviewed, and the owners have confirmed which fields they still need.

What breaks when a field is masked

Masking changes what a role sees and what the cluster can do with that value. The consequences below affect search, aggregations, dashboards and the systems that read from the index, so each one should be checked against your own queries before a masking rule reaches production.

Masked fields cannot be searched

Field masking replaces values with a cryptographic hash, and masked fields cannot be searched. A query for a customer email address or national identifier will match nothing for a masked role, even when the document clearly contains that value for another role. Before you mask a field, list every search box, saved query and API client that filters on it, and confirm which of them run under a masked role. Test each one with a masked user account, not only with an admin account.

Field masking docs

Masking applies only to string fields

Field masking works only on string fields. Numeric, date, boolean and other non-string fields cannot be masked this way, so a sensitive value stored as a number or date needs a different control. Check your mappings to see which sensitive fields are dynamically or explicitly mapped as text or keyword and which are not. Mappings that store identifiers as numbers will not be protected by this feature at all.

Aggregations and sorting lose meaning

A hash is stable for a given role and index, so counts and terms aggregations on a masked field still group identical values together. The groups now represent hashes, not the original values, which means top-value reports and bucket labels no longer show anything a person can read. Sorting on the masked field orders hashes, not the underlying data. Confirm with the owners of each report whether they need the actual values or only the number of distinct records.

Dashboards and saved searches need rework

Dashboards and saved searches that filter on a masked field will return empty or misleading results for masked roles. A visualization built by an administrator may look correct to that administrator and wrong to the analyst who views it through a masked role. Inventory the saved objects that reference each masked field, decide which ones move to a different field or role, and test them under every role that will open them.

Pipelines and consumers may expect raw values

Ingest pipelines, alerting monitors, downstream exports and application code may expect the original value in the same index. If they read through a role that is masked, they receive hashes and can fail silently or raise false alerts. Identify every service account and pipeline that reads the masked index, decide whether it should run under an unmasked role, and confirm that its credentials are scoped to that purpose only.

Alternatives to masking when search still matters

Document-level security keeps every field and every value searchable for roles that are allowed to see a document, and hides the non-matching documents from other roles. It is the right choice when the sensitivity lives in the record rather than in one field, for example when a support team should only search tickets for its own region. Restriction is defined as a query per role, so the query itself becomes part of your access model and needs review like any other permission.

  • Search keeps working: Allowed users run normal queries, aggregations and highlighting on the fields they can see.
  • Record-level rule: The query decides which documents exist for a role, so it must match how your data is tagged.
  • Writes are not restricted: A role that can index into an index is not limited by document-level rules, so pair the control with write permissions.
  • Size limit: Role definitions have a configuration size limit, so large lists of allowed values may need a different design.
  • Query cost: Complex role queries add work to every search, so test them against realistic volumes.

Confirm the exact query syntax and limits for your OpenSearch version in the security documentation before writing rules that depend on them.

Security and operational considerations for masked data

Field masking only protects what it covers, and its protection depends on the salt, the role definitions and the audit trail around them. The cards below cover the controls to set up and the checks to repeat as roles change and versions move forward.

Salt handling and storage

The compliance salt is the input that makes masked hashes harder to reverse, and the docs make it optional but highly recommended. Set plugins.security.compliance.salt to at least 16 ASCII characters, generate it outside the cluster, and store it in your secrets manager with restricted access. Confirm that the same salt is deployed to every node and that its owner knows the effect of changing it, since masked values produced under one salt will not match values produced under another.

Field masking docs

Auditing raw and masked access

Masking is only defensible if you can show who saw unmasked values. Enable the Security plugin audit logs and review which roles can read the raw field, which can read only the masked output, and which accounts hold both. Ask who receives the logs, how long they are kept, and whether anyone reviews them against the masking role list on a schedule. Treat unexpected reads of a sensitive index as an incident candidate.

Role change review

Masking depends on role membership, so a single role change can expose a field that was hidden for years. Keep the roles, mappings and masked field definitions in version control, and require a second reviewer for any change that adds a role to an index with masked fields. Include backend role mappings from your identity provider, because a group change in the directory can grant raw access without any change in OpenSearch itself.

Configuration management

The masking rules live in the security configuration, so they should follow the same lifecycle as the rest of your access model. Track which configuration version is active, record who applied it and when, and keep a tested rollback path. Confirm that a restored snapshot or a rebuilt cluster carries the same masking definitions and salt reference, because a cluster rebuilt from partial configuration can start returning raw values.

Testing masking after upgrades

Upgrades and plugin changes can alter how the Security plugin evaluates roles and fields. After each minor or major upgrade, run a fixed test set: query the masked field as each role, confirm the hashed output is stable for the same input, and confirm that searches on the masked field return no results as expected. Repeat the same checks after restoring a snapshot. Record the results so a later regression has a baseline to compare against.

Masking is not encryption or retention

Field masking is an access control layer. It does not encrypt data at rest, it does not remove values from snapshots, backups or the search index, and it does not delete data when retention expires. Anyone with access to the underlying storage, to snapshot repositories or to a role that bypasses the masked field still sees the original value. Pair masking with transport and disk encryption, snapshot access restrictions and a retention policy for the source data, and confirm each control with your security team before relying on masking for compliance.

Questions buyers ask before masking fields

How much effort does field masking take in OpenSearch?

Effort depends less on the masking setting itself and more on how many fields need masking, how many roles see those fields, and how many indices hold them. Masking is configured in the Security plugin's role definitions, so the work is mostly planning: listing every string field that holds personal or secret values, deciding which roles see the hash and which see the raw value, and checking each index that carries the same field. Costs come from the discovery and design phase, then testing across roles. Ask any partner to break its quote into field inventory, role design, configuration, and test cases, so you can see which part grows with your data model.

What drives the cost of masking fields?

The main drivers are the number of sensitive fields, the number of roles that need different views, the number of indices and index patterns involved, and how well documented your data model is. Teams with clean mappings and a clear list of owners move faster. Teams that discover sensitive data in logs or free-text fields after go-live add rework. Recurring cost arises when new indices or fields appear and need the same treatment, so ask who maintains the field list after handover.

Can our own team mask fields in OpenSearch without a partner?

Yes, if your team already runs the Security plugin and can write and test role definitions. Field masking is a configuration feature, so the technical steps are not the hard part. The harder parts are agreeing on what counts as sensitive, getting data owners and security to sign off, and proving that the masked view behaves as intended for every role. If none of those exist yet, a partner can help build them, or your team can take over a plan a partner has written and tested.

What does the work need from our team?

Three inputs matter most. Data owners must confirm which fields are personal or secret and which business uses need the raw value. Security or compliance must approve the masking rules and the salt handling. You also need a test cluster that mirrors your index mappings and role set, so changes can be proven before they reach production. Without a test cluster, validation runs against live data, which raises risk. Confirm early who signs off each stage, because approval delays usually set the schedule more than configuration does.

How long does validation take for masked fields?

Validation time depends on the number of roles, the number of indices, and how many query patterns your applications and dashboards use. Each role should be tested with a user that holds it, checking that the hash appears where intended and the raw value appears where allowed. Dashboards visualizations and saved searches that touch masked fields need their own checks, because aggregations and filters behave differently on hashed values. Ask for a test plan with named cases before agreeing to any timeline.

Can masked fields still be searched?

No. Field masking works only on string fields, and masked fields cannot be searched. A masked value is replaced by a cryptographic hash per role and index, so a user who sees the hash cannot run a text match on the original value, and queries against the raw value return nothing for that role. Plan search requirements before masking. If support staff need to find a record by email address, for example, you may need a separate lookup field, a different access path, or a decision to keep that field unmasked for a narrow role.

What changes when the compliance salt is rotated?

The optional salt is set with the plugins.security.compliance.salt key, must be at least 16 ASCII characters, and is highly recommended. It is part of how the hash is computed, so changing it changes the hash output that users see. Any saved searches, dashboards, or downstream comparisons that depend on hash values will break or show different results after rotation. Before rotating, confirm with your security team whether hashes must stay stable for correlation, plan the change in a test cluster, and record who holds the salt value and where it is stored.

How DeployOpen scopes a masking change

DeployOpen plans field masking as part of a fixed-scope engagement whose scope, deliverables and timeline are agreed in writing before any change reaches the cluster. The written scope starts with a field inventory: every string field that holds personal or secret values, the indices that contain it, the roles that read those indices today, and the dashboards, saved searches and pipelines that depend on those fields being searchable. Because masked fields cannot be searched, that inventory is the step that decides what a masking change will break, so it is the first deliverable the client should review.

The rest of the scope covers role and index design, salt handling and testing, all carried out in the client's own infrastructure. For each masked field, the design records which roles see the hashed value, which see the original, and which index patterns they apply to. Salt handling is written down as a decision: whether plugins.security.compliance.salt is set, how its value is generated, stored and rotated, and who holds it. The engagement should confirm the setting's current requirements against the OpenSearch field masking documentation, and the testing plan should show that masked values, search behavior and Dashboards views match the agreed design in a staging cluster before production.

DeployOpen prepares the controls, configuration and evidence that a compliance team needs for an assessment, such as role definitions, test results and change records. DeployOpen does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations, so the client should ask its assessor early which evidence they will accept and confirm that the agreed deliverables match that list.

How DeployOpen works on this

DeployOpen plans, implements and documents OpenSearch field masking inside your own infrastructure, so your compliance and security teams can review the roles, salt handling and search impact before anything reaches production. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Inventory which string fields hold personal or secret values and which roles must see them masked.
  • Record which searches, sorts and aggregations depend on those fields so the loss of search is agreed up front.
  • Agree in writing how the compliance salt is generated, stored and rotated, and who holds it.

How we build

  • Configure masked-field roles per index in the Security plugin and test each role against sample documents.
  • Confirm the salt meets the documented minimum of 16 ASCII characters and is delivered through your secret store.
  • Test that masked values are not returned to restricted roles through search, aggregations, Dashboards and exports.

How we hand over

  • Deliver role definitions, index mappings and configuration files in a form your team can version and review.
  • Document which fields are masked, for which roles, and which queries were removed or changed as a result.
  • Walk through the runbook for salt rotation, role changes and retesting so your operators can run it without us.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer after the initial handover.
  • Retest masking rules after OpenSearch version upgrades or changes to roles, mappings and tenants.
  • Confirm alternatives such as field-level security or ingest-time redaction with your data owners when masking is not enough.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.