anon
pg_anon · PostgreSQL Anonymizer (anon) extension
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 7070 | anon | pg_anon | 3.4.0 | SEC | PostgreSQL | Rust |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | anon |
| See Also | column_encrypt pg_tde supabase_vault pg_enigma pgsodium pgcryptokey |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| el8.aarch64 | N/A | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| el9.x86_64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| el9.aarch64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| el10.x86_64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| el10.aarch64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| d12.x86_64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| d12.aarch64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| d13.x86_64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| d13.aarch64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| u22.x86_64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| u22.aarch64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| u24.x86_64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| u24.aarch64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| u26.x86_64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
| u26.aarch64 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 | PIGSTY 3.4.0 |
Source
gitlab.com/dalibo/postgresql_anonymizer/
postgresql_anonymizer-3.4.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
Sources:
- Dynamic masking and privileges
- PostgreSQL Anonymizer 3.4.0 README
- Masking functions
- 3.4.0 changelog
- Official documentation
- 3.4.0 upgrade guide
- 3.4 series release announcement
anon is PostgreSQL Anonymizer. It applies declarative masking rules for protected query access, produces anonymized data sets, and provides pseudonymization and randomized-response helpers. Use it when realistic data must remain useful without exposing the original sensitive values; treat masking policy, role grants, and access to the unmasked database as part of the security boundary.
Core Workflow
Load anon for sessions in the target database, install the extension, and enable transparent dynamic masking. New connections pick up database-level settings.
Mark a login as masked and attach masking rules to sensitive columns:
Queries made as reporting see the transformed values. Privileged users still see the originals, so do not grant masked roles a path around the policy.
Masking Strategies
- Dynamic masking transforms results for roles labeled
MASKEDwithout rewriting the table. - Static masking permanently rewrites selected data and is appropriate for disposable development or test copies.
- Anonymous dumps and replicas produce sanitized exports or downstream copies.
- Masking views and data wrappers expose a deliberately reduced or transformed projection.
- Pseudonymization uses deterministic transforms when joins or repeated values must remain consistent.
Important Objects
anon.dummy_*,anon.random_*, andanon.partial(...)generate or partially conceal values.anon.hash(text)andanon.digest(text, text, text)provide deterministic transformations. In 3.1.2 they were markedRESTRICTEDto limit brute-force exposure.anon.ldp_grrm(value, epsilon, max_v)andanon.ldp_grrm_pttt(value, truth_probability, max_v)implement generalized randomized response for local differential privacy.anon.ldp_truth_probability(...)andanon.ldp_lie_probability(...)help inspect randomized-response probabilities.- Security labels on roles and columns define who is masked and how each value is transformed.
Operational Notes
anon is superuser-installed and non-relocatable. Test every policy with the same grants and connection path used by the intended consumer. Randomization is not automatically deterministic; use a confirmed pseudonymization function when stable equality is required. Static anonymization is destructive, so run it on a copy and verify constraints and application behavior afterward.
Upgrading to 3.4.0
Save masking rules on roles, columns and tables, together with their grants. After installing the 3.4.0 library, follow the upstream guide to drop and recreate anon in each affected database. Restore the rules and grants, then test them as the masked role. Upstream provides no ALTER EXTENSION ... UPDATE path.
Transparent dynamic masking also covers the results of CREATE TABLE AS and SELECT INTO. Masked roles cannot create or refresh materialized views. Grant whole-table read access only on the required tables and restrict schema CREATE privileges.
Seed arguments to anon.seeded_* and anon.pseudo_* must be TEXT or BIGINT. For example, explicitly cast a UUID seed in a masking rule.
For dates and timestamps, choose a representation independent of session settings, such as to_char(birth_date, 'YYYY-MM-DD') for a date or extract(epoch FROM created_at)::BIGINT for an instant. Upstream plans to remove the older pseudonymization functions in 4.0.
Version 3.3.2
Version 3.3.2 is the follow-up release to the 3.3 security series and restores the missing ARM build. The 3.3 series forbids subqueries in masking rules, disables inlining for transparent dynamic masking, rejects SQL-standard-body functions for masked roles, and changes anon.salt. There is no in-place update path: preserve and migrate masking rules, then drop and recreate the extension in each database as directed by upstream.
Version 3.2.0 introduces localized deterministic anon.seeded_* functions; the older anon.pseudo_* family is deprecated. It fixes three upstream-reported security vulnerabilities and defaults to refusing masking operations executed by superusers. Use a dedicated non-superuser masking role. Setting anon.nosuperuser to false removes that barrier and is not the recommended upgrade path. The masking-rule JSON format changed; re-export rules after upgrading.
Version 3.2.3 is a security update for CVE-2026-97469: dynamic masking now checks for RESTRICTED functions inside subqueries. Upgrade the installed library, then follow the upstream drop-and-recreate procedure in each database; ALTER EXTENSION ... UPDATE is unsupported. Preserve and migrate masking rules before recreating the extension; review masked-role queries that previously reached restricted functions through subqueries.