Skip to main content

MaskGuard

AI-powered PII discovery and query-time, role-based masking for PostgreSQL, MySQL and SQLite.

MaskGuard is a gateway between people and the database. It finds sensitive columns by looking at their values (a LightGBM classifier plus checksum validators for Aadhaar, PAN, GSTIN, cards, IBAN and more). It rewrites every query so the database itself returns only what the caller's role may see. It watches for probing, and records every decision in a hash-chained audit log. Stored data never changes.

Role Sees
Admin real values
Support partial masks: 4111-XXXX-XXXX-1111, XXX-XX-6789, r***@bank.in, rounded balances
Analyst keyed tokens (joinable, not reversible); no individual balances
Auditor REDACTED, plus the audit log, policies and integrity proofs

One query as four roles

Install and try it

pip install maskguard
export MASKGUARD_HMAC_KEY=dev-only-hmac-key-change-me     # PowerShell: $env:MASKGUARD_HMAC_KEY="..."  cmd: set MASKGUARD_HMAC_KEY=...
maskguard                                                # console with synthetic demo data (created in ./data/)
maskguard compare "SELECT name, ssn, phone FROM users LIMIT 2" --roles admin,support,analyst,auditor
maskguard serve                                          # REST API + Control Room at http://127.0.0.1:8000/ui/

Demo logins: admin.ann, support.sam, analyst.ali and auditor.aud, each with password <role>123. Data, the audit log and the scanner registry are written to ./data/ in the folder you run it from.

maskguard status shows HMAC KEY FAIL until you set the key: there is deliberately no default key.

To use your own database, set MASKGUARD_DB (postgresql://… or mysql://…) and MASKGUARD_DEMO=0. Columns the scanner finds nothing in are UNREVIEWED and masked for every role except admin until you approve them as PUBLIC in your overrides file (maskguard pii list shows them). For real data, run in production mode (MASKGUARD_ENV=production): it refuses to start on any unsafe setting.

Results

  • PII discovery: 0.965 F1 with misleading column names and 5 sample values per column; the benchmark baseline scores 0.844.
  • Attack suite: 0 of the 17 bypass and inference attacks in its suite leak, against 14–15 of 17 for output-only masking. That is evidence for those attack shapes, not a proof for every query.
  • Tests: 498 tests on SQLite, PostgreSQL 16 and MySQL 8.4.
  • Latency: about 8 ms added per query.

What's new in 1.0.1

Security fixes from an external source audit:

  • Unreviewed columns fail closed. In 1.0.0 a column the scanner found nothing in was returned to every role unmasked. It is now UNREVIEWED (admin only) until a person approves it as PUBLIC.
  • SQL comments and MySQL optimizer hints no longer reach the audit log or the database.
  • Database error text no longer reaches clients through the PostgreSQL proxy or the classic dashboard.
  • The query capability is enforced on every path.

Upgrade with pip install -U maskguard. On your own database, review the UNREVIEWED columns after upgrading.

Learn more

Noisy analyst aggregates are experimental and refused in production until an independent privacy review. Licensed under Apache-2.0.

Metadata

Release files for maskguard 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maskguard 1.0.1
File Size Uploaded
maskguard-1.0.1.tar.gz 23.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for maskguard 1.0.1
File Interpreter ABI Platform
maskguard-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.1 MB

Release files / maskguard-1.0.1.tar.gz

Download URL maskguard-1.0.1.tar.gz
Size 23.4 MB
Tags Source
SHA-256 checksum
How to use checksums
5f1d6ebef5648aeda940f304cda29638a1eeea70825eef5c103f78a934cbfef3
BLAKE2b-256 checksum
How to use checksums
b7625cc073d9ba65d9e6a04d32e62568f1371c203b12927e7c288b0e6ed8c658
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / maskguard-1.0.1-py3-none-any.whl

Download URL maskguard-1.0.1-py3-none-any.whl
Size 696.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52a0245274d5c8c1dcf099801c9740e40afc35a30f5755ffcf90259d05c82b5b
BLAKE2b-256 checksum
How to use checksums
830ba0ea22418cb472256469c0de72f7250e88233a316ee0fefbf5ed5d468de8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page