Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions mitigations/SAFE-M-40/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# SAFE-M-40: UI Security – Clear UI Patterns

## Overview
**Mitigation ID**: SAFE-M-40
**Category**: UI Security
**Effectiveness**: Medium-High (Reduces risk of hidden instruction injection through visual clarity)
**Implementation Complexity**: Medium
**First Published**: April 2025

## Description

Clear UI Patterns is a user interface security control that ensures tool metadata—especially descriptions and parameters—are clearly presented to human reviewers and users. It visually distinguishes between content intended for human consumption and content interpreted by AI models. This separation reduces the likelihood that hidden instructions embedded in metadata (e.g., via steganography or prompt injection) will go unnoticed.

In MCP environments, attackers may embed malicious instructions in tool descriptions or parameter labels that are parsed by LLMs but not easily visible to users. By using distinct UI elements—such as color coding, tooltips, or separate panels—this mitigation makes AI-visible content transparent to human reviewers, helping detect and prevent Shadow Tools and other metadata-based attacks. Not all AI-visible metadata is malicious. Many tools intentionally inject behavioral context to guide model tone, style, or domain-specific reasoning. Clear UI Patterns supports this by making such context transparent to reviewers and users, ensuring that purposeful design is distinguishable from hidden manipulation.


## Mitigates
- [SAFE-T1402](../../techniques/SAFE-T1402/README.md): Instruction Steganography
- [SAFE-T1403](../../techniques/SAFE-T1403/README.md): Context Poisoning
- [SAFE-T1401](../../techniques/SAFE-T1401/README.md): Direct Prompt Injection

## Technical Implementation

### Core Principles
1. **Visual Differentiation**: Use distinct UI elements (e.g., color, icons, layout) to separate AI-visible and user-visible metadata.
2. **Transparency by Design**: Ensure all metadata passed to the model is also visible to reviewers in a clearly marked format.
3. **Inline Warnings**: Flag or highlight metadata fields that contain suspicious patterns (e.g., zero-width characters, HTML comments).

### Architecture Components
```
+------------------+ +------------------+ +------------------+
| Tool Registry UI | ---> | Metadata Renderer| ---> | Reviewer Display |
+------------------+ +------------------+ +------------------+
| | |
| v v
| [Styled Metadata] [Human-AI Distinction]
v
[Tool Review Workflow]
```

### Prerequisites
- UI framework capable of rendering styled metadata
- Access to raw tool metadata and AI context fields

### Implementation Steps
1. **Design Phase**:
- Define visual language for AI-visible vs user-visible content
- Specify UI components for metadata rendering

2. **Development Phase**:
- Implement metadata renderer with syntax highlighting and tooltips
- Integrate with tool registration and review workflows

3. **Deployment Phase**:
- Apply UI patterns to all tool review interfaces
- Train reviewers to interpret visual cues

## Benefits
- **Improves Metadata Transparency**: Makes hidden or ambiguous content visible to reviewers
- **Reduces Human Oversight Risk**: Helps detect steganographic payloads during tool registration
- **Supports Reviewer Confidence**: Clarifies what the model sees vs what the user sees
- **Supports Intentional Context Injection**: Enables safe use of AI-visible metadata for tone, style, or domain alignment
- **Improves Trust and Transparency**: Users can see how tools influence model behavior, fostering informed acceptance

## Limitations
- **UI Dependency**: Requires consistent implementation across all interfaces
- **Reviewer Training Required**: Visual cues must be understood and trusted by human reviewers
- **Does Not Prevent Execution**: This is a visibility control, not a blocking mechanism
- **Design vs. Deception Ambiguity**: Reviewers must distinguish between purposeful guidance and subtle manipulation
- **Requires Metadata Discipline**: Tool creators must document and justify AI-visible context to avoid misuse

## Implementation Examples

### Example 1: UI Rendering Logic
```jsx
function renderToolDescription(description) {
return (
<Tooltip content="This is the text visible to user">
<span>{description.user}</span>
</Tooltip>
<Tooltip content="This is the text sent to the AI model">
<span>{description.system}</span>
</Tooltip>
);
}
```

### Example 2: Configuration Policy
```json
{
"ui_patterns": {
"highlight_ai_visible_metadata": true,
"flag_suspicious_characters": true,
"tooltip_explanation_enabled": true
}
}
```

## Testing and Validation

1. **Security Testing**:
- Inject steganographic payloads and verify visual detection
- Test UI rendering of zero-width and comment-based payloads
- Validate reviewer ability to identify suspicious metadata

2. **Functional Testing**:
- Confirm UI renders metadata consistently across browsers/devices
- Ensure tooltips and highlights function as intended
- Assess accessibility compliance

3. **Integration Testing**:
- Validate integration with tool registration and review pipelines
- Confirm metadata consistency between UI and model context

## Deployment Considerations

### Resource Requirements
- **CPU**: Minimal (UI rendering only)
- **Memory**: Low
- **Storage**: No additional requirements
- **Network**: No impact

### Performance Impact
- **Latency**: Negligible
- **Throughput**: No impact
- **Resource Usage**: Minimal

### Monitoring and Alerting
- Number of tools flagged with suspicious metadata
- Reviewer override frequency
- Alert on metadata fields with high entropy or hidden characters

## Current Status (2025)
According to industry reports, organizations are beginning to adopt UI-based defenses:
- 31% of MCP vendors have implemented visual metadata inspection tools (Invariant Labs, 2025)
- OWASP LLM Top 10 recommends UI transparency for model context review

## References
- [Model Context Protocol Specification](https://modelcontextprotocol.io/specification)
- [OWASP Top 10 for LLM Applications](https://owasp.org/www-project-top-10-for-large-language-model-applications/)
- [Tool Poisoning Attacks – Invariant Labs, 2025](https://invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks)
- [MCPTox Benchmark – Arxiv, 2025](https://arxiv.org/abs/2508.14925)

## Related Mitigations
- [SAFE-M-37](../SAFE-M-37/README.md): Metadata Sanitization – Removes hidden characters before rendering
- [SAFE-M-43](../SAFE-M-43/README.md): Steganography Scanner – Flags suspicious metadata for UI highlighting

## Version History
| Version | Date | Changes | Author |
|---------|------|---------|--------|
| 1.0 | 2025-10-25 | Initial documentation | Ryan Jennings |