Cloud concept · Updated

Data Masking - Data masking conceals sensitive values by replacing, obscuring, or suppressing them while retaining useful information for an authorized task.

In short

Data masking reduces unnecessary exposure of confidential information in logs, messages, query results, and nonproduction datasets. It complements encryption and access control by limiting which sensitive values users and downstream systems can actually see.

Cloud Concepts Hub →

6 key aspects of Data Masking

Effective masking combines selective disclosure, tested detection, appropriate enforcement boundaries, and tightly controlled access to original values.

01
Selective disclosure

Hide sensitive values while preserving the context needed for a task. For example, retain an error code and request identifier while suppressing a customer's national identifier.

02
Static and dynamic enforcement

Static masking modifies a copy of data; dynamic masking changes the representation returned to a reader. Determine whether original values remain accessible before treating a masked result as safe to distribute.

03
Sensitive-data identification

Combine known field definitions with managed identifiers or custom matching rules. Test for missed matches and false positives, especially for application-specific secrets and identifiers.

04
Trust-boundary placement

Apply masking before sensitive content reaches a broader audience or downstream system. An outbound masking rule protects its covered deliveries, not every upstream or parallel copy.

05
Controlled access to originals

Where an implementation retains original values, restrict permissions that bypass masking or request unmasked output. Separate routine troubleshooting access from exceptional access to confidential content.

06
Defense in depth

Combine masking with data minimization, encryption, least privilege, and retention controls. Treat exposed credentials and cryptographic keys as compromised rather than relying on masking to repair the exposure.

Cloud services for Data Masking

These services apply masking at different points in a data flow. Amazon SNS can de-identify sensitive message content at configured messaging boundaries, while CloudWatch Logs can mask sensitive values that nevertheless appear in operational logs. Amazon Redshift applies dynamic masking when users query analytical data. Configure each boundary independently rather than assuming one policy follows the data everywhere. Align detection rules and access permissions, test downstream outputs, and verify whether each mechanism preserves original values. Encryption and retention controls remain necessary for the underlying data.

Amazon RedshiftAmazon Redshift

Dynamic data masking policies transform sensitive column values in query results according to policy assignments and priority. This enables analysts to work with useful results without granting routine visibility into the underlying sensitive values.

Data Masking exam questions

Real practice exam questions on Data Masking, with the correct answer and its explanation. Answer them with every option in the exam simulator.

MLA-C02 (beta)

A company is building an ingestion API for English-language customer feedback used to train an ML model. Each request contains less than 5 KB of UTF-8 text. Before the API stores a message, it must identify personally identifiable information (PII), including names, email addresses, and bank account numbers, and replace every character in each detected PII span with an asterisk. The sanitized message must retain its original character count so that existing text annotations remain aligned. Unredacted messages must not be written to Amazon S3, and preprocessing must complete within the ingestion request.

Which solution best meets these requirements?

Show answerCORRECT ANSWER

Call Amazon Comprehend DetectPiiEntities for each message. Use the returned beginning and ending character offsets to replace each detected PII span with the same number of asterisks before storing the message.

DetectPiiEntities synchronously identifies supported PII types and returns their character offsets. Applying length-preserving masking to those spans produces sanitized text while maintaining annotation alignment, without staging unredacted messages in S3.

SAP-C03

A manufacturer uses Amazon Bedrock to draft public procurement announcements from internal purchasing notes. Security policy prohibits personal names, email addresses, and confidential bid references in model inputs and generated announcements. Bid references have the format BID- followed by exactly 10 digits and are not a built-in PII type.

If inspection detects prohibited information, the application must reject the entire input or response and return an approved notification. Processing must not continue with redacted content. Testing shows that personal-name detection varies with the surrounding text. An independent approval gate is required before publication because automated inspection alone cannot establish that all sensitive information has been removed.

Which design meets these requirements with the least custom detection code?

Show answerCORRECT ANSWER

Configure built-in name and email sensitive information filters and a custom regular expression for bid references with the block action. Inspect inputs before inference and responses before delivery, configure the approved blocked-content messages, and retain context-diverse testing and independent publication approval.

Built-in PII filters detect names and email addresses, and a custom regular expression detects the organization-specific bid-reference format. The block action rejects all inspected input or response content when sensitive information is detected and returns a configured message. Built-in PII detection is probabilistic and context-dependent, so a clean inspection does not guarantee that no sensitive information remains. Testing and independent publication approval address that coverage limitation.

DEA-C01

A company runs an AWS Glue Spark job that processes customer records in a restricted data lake. When validation fails, the job writes the rejected record and exception details to Amazon CloudWatch Logs. Operations engineers need the validation rule, processing stage, and error details for troubleshooting, but company policy prohibits storing customer account identifiers in the logging system. The original records must remain unchanged in the restricted data lake.

Which change meets these requirements?

Show answerCORRECT ANSWER

Update the Glue job's logging and exception-handling paths to replace account identifiers with a fixed placeholder before emitting messages, while preserving validation rules, processing stages, and nonsensitive error details.

Masking before log emission prevents account identifiers from entering the logging system. Applying the transformation to both explicit record logging and exception details closes both exposure paths, preserves useful diagnostics, and leaves the restricted source records unchanged.

Practice Data Masking in a full exam

Questions on Data Masking in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Data Masking

2 min read

Data masking protects sensitive information by hiding selected values rather than making an entire dataset unavailable. A support engineer might see a payment card number as a sequence of asterisks followed by its last four digits, while still seeing the transaction timestamp and error code. The objective is to preserve enough context for troubleshooting, analysis, or testing without exposing information that the task does not require.

Start by identifying sensitive fields and the boundaries where they could escape. Examples include personal identifiers in application logs, credentials accidentally included in error messages, and customer details distributed through messaging systems. Prefer not to collect or emit sensitive values in the first place. When that is impractical, apply masking before data crosses a trust boundary, and check every path that can produce another copy, including exports, subscriptions, retries, and diagnostic output.

Static masking creates a modified copy of data, such as a sanitized dataset for development. Dynamic masking changes what a reader sees while retaining the original value in the underlying system. This distinction matters operationally: a masked display does not prove that the stored value has been removed. Administrators, privileged readers, alternative APIs, or downstream copies might still expose the original, depending on the implementation.

In Amazon CloudWatch Logs, data protection policies use managed or custom data identifiers to detect sensitive information and mask matching content at supported egress points. This capability is available for Standard-class log groups. Policies protect newly ingested events after configuration; they do not retroactively mask previously ingested events. A principal with the logs:Unmask permission can request access to original values through supported interfaces, so that permission should be narrowly controlled and its use monitored.

Amazon SNS message data protection applies policies to Standard topics to inspect message bodies. Policies can audit findings, deny messages containing specified sensitive information, or de-identify matching content through masking or redaction. Inbound policies evaluate messages entering the topic, while outbound policies evaluate messages before delivery to subscribers. Choose the direction and applicable principals deliberately: inspecting a message is not equivalent to preventing its delivery, and masking an outbound delivery does not sanitize every other copy of that message.

Detection requires testing. Pattern-based identifiers can miss unusual formats or incorrectly classify ordinary values, and encoded or encrypted payloads can defeat content inspection. Use representative synthetic examples, including negative cases, and monitor findings without reproducing the sensitive values in alerts. Do not assume that managed identifiers recognize every password, access token, private key, or proprietary identifier.

Masking is not encryption, and neither control replaces the other. Encryption protects data through cryptographic access restrictions, whereas masking limits disclosed content. Masking also does not automatically make data anonymous: remaining fields may permit re-identification. Partial masking improves usability but reveals more information, while aggressive replacement can impair debugging and analysis. If a credential or cryptographic key is exposed, masking subsequent output is insufficient; revoke or rotate the material and address retained copies.

Learn Data Masking in lessons

10 short lessons on Data Masking in 6 certification courses.

and 4 more lessons

Open the lessons