Alibaba Cloud has introduced a data masking feature in its Simple Log Service (SLS) to address growing security concerns around sensitive data exposure in large language model (LLM) applications. The mask function automatically detects and anonymizes personally identifiable information (PII) in log data before storage, eliminating the need for complex regular expressions while maintaining log utility for operations and troubleshooting.
What’s New
Alibaba Cloud’s SLS mask function operates through its Ingest Processor to secure sensitive data at the write stage. The solution supports two detection patterns: built-in matching for six common data types (phone numbers, ID cards, email addresses, IP addresses, landline numbers, and bank card numbers) and keyword matching that intelligently identifies key-value pairs in formats like “key”:”value” or key=value.
The feature integrates with LoongCollector, Alibaba Cloud’s lightweight log collection tool that gathers data from host text logs, Kubernetes containers, and HTTP sources. Organizations configure data masking rules through Structured Process Language (SPL) scripts in a write processor, ensuring sensitive fields are masked before reaching the LogStore.
Performance testing shows the mask function delivers 2.8 times faster processing compared to traditional regular expression-based methods, particularly in scenarios with nested JSON structures or large data volumes.
Why It Matters
LLM-powered applications like e-commerce copilots process thousands of customer interactions daily, creating logs filled with sensitive information including order IDs, shipping addresses, API tokens, and payment details. Without proper data masking, these logs pose compliance risks under data minimization principles and create potential leakage vectors when shared across teams or exported for debugging.
The write-side masking approach eliminates “plaintext storage” risks by processing data before it enters the system. Operations teams can analyze user behavior trends without accessing individual user details, while security teams gain audit trails without worrying about incomplete masking coverage.
Real-World Implementation
Alibaba Cloud demonstrated the solution using an e-commerce copilot built on the Dify orchestration platform. The system handles refund requests, order queries, logistics tracking, and product consultations through automated LLM interactions.
LoongCollector captures logs from the Dify service layer and backend APIs, then pushes them to SLS LogStore where the mask function processes sensitive fields. For phone numbers, the system retains the first three and last four digits, enabling O&M engineers to verify user identity and troubleshoot issues while protecting full number disclosure.
The solution allows different teams to access the same masked logs with role-appropriate visibility: O&M sees call chains and performance bottlenecks, operations views conversion funnels and inquiry patterns, and security monitors policy execution all without exposing raw PII.
Technical Advantages
The keyword matching mode eliminates the need to write complex regular expressions for nested data structures. Administrators only configure the innermost key in JSON hierarchies, and the function automatically masks corresponding values regardless of nesting depth.
Chinese content receives precise masking for names and addresses according to configured rules, avoiding encoding-related failures common in traditional regex approaches. The system supports customizable prefix and suffix retention for different field types, balancing security requirements with operational traceability needs.
SLS provides additional compliance capabilities including configurable log retention periods (180+ days for network audit logs), user-level operation auditing through CloudLens, and role-based access controls that restrict log viewing permissions.
Featured Snippet Boxes
What is SLS data masking?
SLS data masking is Alibaba Cloud’s automated feature that detects and anonymizes sensitive information in log data before storage. It uses built-in pattern recognition and keyword matching to identify PII without requiring complex regular expressions.
How does data masking protect LLM applications?
Data masking secures LLM application logs by anonymizing sensitive user information (phone numbers, addresses, payment details) at the write stage. This prevents accidental exposure when logs are debugged, shared across teams, or exported for analysis.
What types of sensitive data can SLS mask?
SLS mask function handles six built-in data types: phone numbers, ID cards, email addresses, IP addresses, landline numbers, and bank card numbers. Keyword matching mode extends coverage to any custom sensitive fields in key-value pair formats.
Why is write-side masking better than post-processing?
Write-side masking processes data before storage, eliminating risks of plaintext data leakage, incomplete coverage, or accidental exports. Post-processing approaches leave temporary windows where sensitive data exists in raw form.
What is SLS data masking?
SLS data masking is Alibaba Cloud’s automated feature that detects and anonymizes sensitive information in log data before storage. It uses built-in pattern recognition and keyword matching to identify PII without requiring complex regular expressions.
How does data masking protect LLM applications?
Data masking secures LLM application logs by anonymizing sensitive user information (phone numbers, addresses, payment details) at the write stage. This prevents accidental exposure when logs are debugged, shared across teams, or exported for analysis.
What types of sensitive data can SLS mask?
SLS mask function handles six built-in data types: phone numbers, ID cards, email addresses, IP addresses, landline numbers, and bank card numbers. Keyword matching mode extends coverage to any custom sensitive fields in key-value pair formats.
Why is write-side masking better than post-processing?
Write-side masking processes data before storage, eliminating risks of plaintext data leakage, incomplete coverage, or accidental exports. Post-processing approaches leave temporary windows where sensitive data exists in raw form.

