# Maskit: Local Privacy Gateway for LLMs and AI Tools

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/xiayutian11-maskit
Generated for open source discovery and AI-assisted research.

Maskit is a local privacy desensitization gateway engineered for large language models and AI tools. It automatically masks sensitive data in requests sent to AI services and then seamlessly restores it in streaming responses, ensuring private information remains local. This innovative solution supports various AI assistants like Cursor and Claude Code, along with any tool offering a configurable Base URL.

GitHub: https://github.com/xiaYuTian11/maskit
OSRepos URL: https://osrepos.com/repo/xiayutian11-maskit

## Summary

Maskit is a local privacy desensitization gateway engineered for large language models and AI tools. It automatically masks sensitive data in requests sent to AI services and then seamlessly restores it in streaming responses, ensuring private information remains local. This innovative solution supports various AI assistants like Cursor and Claude Code, along with any tool offering a configurable Base URL.

## Topics

- data-masking
- privacy
- llm
- openai
- anthropic
- python
- security
- proxy

## Repository Information

Last analyzed by OSRepos: Sun Sep 20 2026 10:01:12 GMT+0100 (Western European Summer Time)
Detail views: 1
GitHub clicks: 0

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

Maskit, also known as Data Maskit (????), is an innovative local privacy desensitization and restoration gateway specifically engineered for large language models (LLMs) and AI tools. In an era where sensitive information can inadvertently be shared with external AI services, Maskit acts as a transparent shield, ensuring your data remains private and secure.

This powerful tool automatically masks sensitive data in your requests before they leave your local environment and then seamlessly restores the original content in the streaming responses from the AI model. It supports a wide array of AI assistants, including Cursor, Claude Code, Codex, Pi, and any other tool that allows for a configurable Base URL.

You can find the official repository here: [https://github.com/xiaYuTian11/maskit](https://github.com/xiaYuTian11/maskit){:target="_blank"}

## Why Use and Key Features

When interacting with AI programming assistants like Cursor, Claude Code, or ChatGPT, critical sensitive information in your code or queries can be unknowingly transmitted to external model service providers. This includes:

*   **Credentials and Keys**: API keys (`sk-proj-...`), GitHub tokens (`ghp_...`), cloud provider AccessKeys, JWT Tokens, PEM private key certificates.
*   **Internal Network Assets**: Database connection strings (`mysql://root:Pass123@192.168.1.50:3306/db`), private IP addresses (`10.x`, `172.16.x`, `192.168.x`).
*   **Business Privacy (PII)**: Phone numbers, ID numbers, names, bank card details, internal company codes, and confidential business terms.

Maskit's mission is to establish a transparent, local privacy protection gateway between your development terminal and external AI services. Requests are automatically coded into structured placeholders locally before being sent out, and model responses are restored to their original text in milliseconds, providing a completely seamless user experience.

Here are Maskit's core highlights and full feature set:

### Deep Desensitization and Multi-Turn Conversation Consistency

*   **Out-of-the-box Rule Library**: Includes over 20 types of scanning rules for API Keys/Tokens, PEM private keys, database connection strings, phone numbers, ID cards, emails, bank cards, internal IPv4/IPv6, USCC unified credit codes, and more. It prioritizes core privacy with low false positives.
*   **Custom Sensitive Words and Regex**: Easily manage internal names, project codes, and sensitive terms by category. Supports whole-word matching boundaries and custom regex extensions, using deterministic persistent placeholders to prevent??.
*   **Multi-Turn Conversation Sliding Window Reuse**: Features a unique placeholder reuse mechanism. In a long conversation, "John Doe" will consistently map to the same placeholder across the 1st and 10th turns, ensuring the large model's logical reasoning remains consistent without mixing identities.

### Local AI Entity Recognition (NER Semantic Model Linkage)

*   **Unstructured Free Text Recognition**: Built-in lightweight local ONNX semantic model automatically identifies names (NAME), organizations (ORG), and detailed physical addresses (ADDR) that are difficult for regex to cover.
*   **Clean Original Text Extraction + Monotonic OffsetMap Coordinate Mapping**: Semantic extraction is performed on the pristine original text, and then monotonic coordinate mapping translates entity ranges back into the masked text. This completely prevents plaintext fragments from leaking due to context truncation after rule replacement.
*   **100% Offline Inference**: All operations run locally within the process, requiring no external network calls. This feature can be toggled on/off in the settings.

### Browser Extension Ecosystem (Web-based AI Privacy Protection)

*   **Seamless Integration with Web-based LLMs**: A Chrome/Edge MV3 extension specifically designed for web versions of AI tools like ChatGPT, Claude, Kimi, Doubao, and Tongyi Qianwen.
*   **Local Interception and Masking + Web Typewriter Streaming Restoration**: Prompts sent from the page are masked by the local engine before going online, and responses are streamed and restored on the web interface. It comes with pre-configured one-click authorization for over 18 common AI sites.

### Millisecond SSE Streaming Takeover (True Typewriter Experience)

*   For OpenAI / Anthropic `text/event-stream` streaming responses, incremental restoration is delivered event by event.
*   Intelligently handles cross-chunk placeholder slicing and buffer splicing, fully preserving the native smooth typewriter experience without stuttering or delay.

### No Root Certificate Installation + Native Direct Connection Fallback (Never Offline)

*   **Multi-Port Reverse Proxy Mode**: Assigns independent local ports for different models/channels (e.g., `18701` for OpenAI, `18703` for Anthropic). Simply change the `base_url` in your tool to the local port, eliminating the need to install self-signed CA root certificates in the operating system.
*   **Fallback Passthrough Guarantee**: Even if you close the desensitization proxy or exit the software, the local port remains monitored by a lightweight underlying process and transparently forwards plaintext directly. Your AI tools will never unexpectedly lose network connectivity or report network errors.

### Full-Link Logs, Security Audit, and Cost Ranking

*   **Full-Link Log Details**: View outbound masking, upstream responses, and time distribution for each request, with one-click highlighting for original text comparison.
*   **Passive Security Audit and Anti-Injection Detection**: Real-time monitoring for potential leaks, command execution risks in model responses. Includes **Prompt Injection Detection** to catch forged system turns, credential sniffing, and outbound commands.
*   **Token Usage and Cost Estimation**: Supports intelligent matching of mainstream large model prices, providing intuitive statistics on daily call volume and expenditure.

## Installation

Maskit offers flexible deployment options to suit individual and team needs.

### A. Desktop Client (Windows / macOS, recommended for personal daily use)

Visit the [GitHub Releases page](https://github.com/xiaYuTian11/maskit/releases){:target="_blank"} to download the latest installer for your platform:

*   **Windows Users**: Download `Maskit_<version>_x64-setup.exe`, double-click to install and run. Right-click the system tray icon to start/stop. Supports fully automatic digital signature (Minisign) and seamless online updates.
*   **macOS Users (Apple Silicon M-series)**: Download `Maskit_<version>_aarch64.dmg`, double-click to open, and drag `Maskit.app` into the "Applications" folder.
    *   *macOS First Open Tip*: If you encounter a "cannot be opened because Apple cannot check it for malicious software" message, simply **right-click Maskit in Finder and select "Open"**, or run the following command in the terminal to remove the quarantine attribute:
        bash
        xattr -cr /Applications/Maskit.app
        

### B. Docker Private Gateway (recommended for teams / servers / NAS deployment)

No need to download source code. Directly pull the official GitHub pre-built multi-architecture image (natively supports `linux/amd64` and `linux/arm64`), which includes a complete Web console:

#### Start in seconds with one command:

bash
docker run -d \
  --name maskit \
  --restart unless-stopped \
  -p 127.0.0.1:5801:5801 \
  -p 127.0.0.1:18701:18701 \
  -v maskit_data:/data \
  -e MASKIT_PANEL_TOKEN="YourSecretToken123456" \
  ghcr.io/xiayutian11/maskit:latest


*   **Port Mapping and Network Access**:
    *   `5801`: **Web console port (required)**, used for viewing the dashboard, managing rules, and client configurations.
    *   `18701` onwards: **LLM reverse proxy ports (enable as needed)**. For example, `18701` defaults to OpenAI, `18702` to DeepSeek. Map only the ports you use (e.g., if using one, map only `18701`; if using three, use `-p 127.0.0.1:18701-18703:18701-18703`).
    *   **Access Address Binding**: If your server has Nginx in front or is only for local access, it's recommended to bind `-p 127.0.0.1:5801:5801`. If accessing the container directly via IP on an internal/LAN network, remove the `127.0.0.1:` prefix and use `-p 5801:5801 -p 18701:18701`.
    *   **Console Token (Password)**: `-e MASKIT_PANEL_TOKEN="YourSecretToken123456"` must be **?16 pure ASCII characters** (do not include Chinese characters, otherwise the engine will securely fall back to a random token from the startup logs).

Open `http://<server_IP>:5801` in your browser to access, and enter your set password in the login window. You can also use `http://<server_IP>:5801/#token=<your_password>` for quick password-free access (the fragment is not sent with the request, will not enter proxy access logs, and the Token will automatically be cleared from the address bar after entry).

*   **Security Recommendations and Reverse Proxy (Nginx Configuration Reference)**:
    By default, it binds to `127.0.0.1` localhost, protecting proxy ports from direct exposure to the public network. If you use Nginx to host a domain and configure TLS reverse proxy externally, **you must add the environment variable `-e MASKIT_TRUST_PROXY=1` when starting Docker** (to make the panel trust the `X-Forwarded-Proto: https` header passed by the front-end Nginx, preventing API requests from being intercepted by Origin verification). Refer to the configuration below:

    nginx
    server {
        listen 443 ssl;
        server_name maskit.example.com;
        # ssl certificate configuration omitted...

        # 1. Control Panel (access domain directly, enter Token in the pop-up window to log in)
        location / {
            proxy_pass http://127.0.0.1:5801;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;  # Crucial: inform backend that external protocol is https
            proxy_set_header X-Forwarded-Host $host;
        }

        # 2. Model Reverse Proxy Port (e.g., OpenAI, disable caching to ensure smooth streaming; recommended with internal network whitelist)
        location /openai/ {
            proxy_pass http://127.0.0.1:18701/;
            proxy_set_header Host $host;
            proxy_buffering off;
            proxy_read_timeout 600s;
        }
    }
    

#### Advanced: Single-Port Mode (Docker only opens one reverse proxy port)

If you prefer not to map a port for each client, you can use **single-port prefix mode**. All clients share the `5802` reverse proxy port, distinguished by path prefixes. In the control panel's "Client Management," each client's **Path Prefix (base_path)** corresponds to the path part of the client's `base_url`:

bash
docker run -d \
  --name maskit \
  --restart unless-stopped \
  -p 127.0.0.1:5801:5801 \
  -p 127.0.0.1:5802:5802 \
  -v maskit_data:/data \
  -e MASKIT_PANEL_TOKEN="YourSecretToken123456" \
  ghcr.io/xiayutian11/maskit:latest


Assuming you have configured two clients (with path prefixes `/openai` and `/anthropic` respectively), the external tool's Base URL would be:

| Client | Base URL |
|---|---|
| OpenAI Protocol (prefix `/openai`) | `http://<server_IP>:5802/openai/v1` |
| Anthropic Protocol (prefix `/anthropic`) | `http://<server_IP>:5802/anthropic` |

*   **Multi-Port vs. Single-Port Choice**: Multi-port (starting from `18701`) provides an independent port for each client and the shortest `base_url`, suitable for personal local use. Single-port mode only maps `5802`, ideal for scenarios with limited container ports or unified Nginx prefix forwarding. Both modes can coexist, the prefix routing on `5802` and independent client ports are simultaneously effective.

### C. Run and Develop from Source

bash
git clone https://github.com/xiaYuTian11/maskit.git
cd maskit

# 1. Install core dependencies
pip install -r requirements.txt

# 2. Build frontend and start engine (skip frontend build if only console API is needed)
cd frontend && npm install && npm run build && cd ..
python engine/panel.py

# 3. Frontend secondary development (Vite hot reload, recommended)
cd frontend && npm run dev


*   **Testing Tips**: For daily modifications, run `python scripts/verify-all.py` to execute local full gate checks (including unit tests, build, Lint, version consistency, and 15 other checks). If core extension code is modified, run `python tests/e2e_ext_bridge.py` to perform real browser end-to-end smoke tests.

## Examples

Maskit offers universal integration, supporting any tool with a configurable Base URL. Simply change the API Base URL in your tool to Maskit's corresponding local port.

*   Default port mappings: OpenAI protocol `http://127.0.0.1:18701/v1`, DeepSeek protocol `http://127.0.0.1:18702/v1`, Anthropic protocol `http://127.0.0.1:18703` (these can be freely added or modified).

### 1. Cursor

Open Cursor ? `Settings` ? `Models`:

*   **OpenAI Base URL**: `http://127.0.0.1:18701/v1`
*   Enter your real API Key (Maskit will securely forward it to the upstream service locally).

### 2. Claude Code (use with cc-switch for one-click setup)

*   In [cc-switch](https://github.com/farion1231/cc-switch){:target="_blank"}, change the **Base URL** of the Claude channel in use to:
    `http://127.0.0.1:18703`
*   Or launch via terminal environment variable:
    bash
    export ANTHROPIC_BASE_URL="http://127.0.0.1:18703"
    claude
    

### 3. Codex / Pi / OpenCode / Aider / Command-line Tools

Specify the local proxy port via environment variables for seamless masking:

bash
# Linux / macOS
export OPENAI_BASE_URL="http://127.0.0.1:18701/v1"
export OPENAI_API_KEY="your-api-key"

# Windows PowerShell
$env:OPENAI_BASE_URL = "http://127.0.0.1:18701/v1"
$env:OPENAI_API_KEY = "your-api-key"


### 4. Code Integration (Python / Node.js / LangChain)

python
from openai import OpenAI

client = OpenAI(
    base_url="http://127.0.0.1:18701/v1",
    api_key="your-api-key"
)

# Normal call, full-link automatic local masking and streaming restoration
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Troubleshoot database connection: mysql://root:Pass123@192.168.1.100:3306"}]
)
print(response.choices[0].message.content)


### 5. Adding Third-Party Relays / Aggregation Gateways (e.g., One API / New API)

1.  In "Client Management," click "Add Client."
2.  **Target Gateway**: Enter the relay provider's address (e.g., `https://api.your-relay.com`).
3.  **Local Port**: Enter an unused port (e.g., `18709`).
4.  **Masking Paths**: Mainstream paths (e.g., `/v1/chat/completions`) are pre-configured. Simply check as needed.
5.  After saving, set the external tool's Base URL to `http://127.0.0.1:18709/v1` for normal use.

### 6. Browser Extension (ChatGPT / Claude and other web-based AIs)

Web-based AIs cannot configure API Base URLs. Maskit's dedicated browser extension enables fully automatic masking and restoration:

1.  **Install Extension**: Download `Maskit_<version>_extension.zip` from [Releases](https://github.com/xiaYuTian11/maskit/releases/latest){:target="_blank"} and unzip it. In Chrome/Edge, open `chrome://extensions` ? enable "Developer mode" ? click "Load unpacked" and select the unzipped directory (source code users can directly load the `extension/` directory).
2.  **Connect Panel**: In the Maskit desktop panel, go to "Settings ? Browser Extension," enable the extension link, and copy the **access token**. Paste it into the extension's settings pop-up.
3.  **Enable Sites**: In the extension settings, check the target sites (e.g., `chatgpt.com`, `claude.ai`). It supports over 18 preset site recommendations and custom site additions.

*   **Status and Troubleshooting**:
    *   The extension icon pop-up clearly displays the current status: green (normal masking), yellow (engine not running, direct passthrough), red (invalid token or switch off).
    *   Extension traffic events are simultaneously recorded in the console's "Event Logs," which can be filtered by entry dimension (proxy link / browser extension).

## Links

*   **GitHub Repository**: [https://github.com/xiaYuTian11/maskit](https://github.com/xiaYuTian11/maskit){:target="_blank"}
*   **Official QQ Group**: `489926214` (Join for discussions, latest rules, and version updates).
*   **LINUX DO Community Discussion**: [https://linux.do/t/topic/2884715](https://linux.do/t/topic/2884715){:target="_blank"}
*   **Suggestions and Feedback**: [GitHub Issues](https://github.com/xiaYuTian11/maskit/issues){:target="_blank"} and [GitHub Discussions](https://github.com/xiaYuTian11/maskit/discussions){:target="_blank"}.
*   **Security Vulnerabilities**: Private feedback channel available in [SECURITY.md](https://github.com/xiaYuTian11/maskit/blob/master/SECURITY.md){:target="_blank"}.
*   **License**: Data Maskit is released under the [GNU AGPL-3.0 license](https://github.com/xiaYuTian11/maskit/blob/master/LICENSE){:target="_blank"}. It is completely free for individual developers, researchers, and open-source projects. For distribution or integration into closed-source commercial products, please adhere to the AGPL-3.0 terms.