feat: add privacy authorization and output integration hooks - #1976
Open
yz271544 wants to merge 1 commit into
Open
feat: add privacy authorization and output integration hooks#1976yz271544 wants to merge 1 commit into
yz271544 wants to merge 1 commit into
Conversation
Add AUTHORIZE PRIVACY parsing, final tuple and COPY delivery hooks, distributed security labels, and parallel RETRIEVE metadata propagation. Companion extension and integration tests are maintained in cloudberry-privacy.
There was a problem hiding this comment.
Hi, @yz271544 welcome!🎊 Thanks for taking the effort to make our project better! 🙌 Keep making such awesome contributions!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add experimental privacy authorization and output integration hooks
Related discussion: #1943
What does this PR do?
This PR introduces the Cloudberry core integration points for an experimental, extension-based output privacy design. It allows a companion extension to apply policy-based transformations or permit authorized access immediately before values are delivered to a client, without modifying executor input tuples.
This is the core integration portion, not a complete privacy protection implementation. JWT verification, session authorization, policy management, MASK/CPT transformations, and policy-version validation are implemented in the separate
cloudberry-privacyproject and are not included in this PR.The core changes are:
Authorization command parsing
AUTHORIZEkeyword and parseAUTHORIZE PRIVACY FROM STDIN.CopyStmtmarker for the extension's utility hook. With the companion extension, JWT bytes are received through CopyData rather than embedded in SQL text.Final-output hooks
utils/privacy_output.h(experimental ABI version 2).printtup.candcopyto.cbefore text or binary encoding.Distributed security labels
cloudberry_privacyprovider with snapshot and two-phase transaction flags.SecLabelStmtbinary serialization/deserialization and text-output support.Parallel RETRIEVE integration
The companion extension uses the existing
PlannedStmt.extensionContexttransport for QD-to-QE policy fingerprints and scoped capabilities. No new client protocol message is introduced.Type of Change
This is an experimental feature with internal ABI and endpoint shared-memory compatibility changes.
Breaking Changes
PortalDatagains an output-metadata field, andSetupEndpointExecState()gains a planned-statement argument.No on-disk table format change is introduced. Without registered handlers, these hooks do not apply privacy transformations; this patch alone does not protect labeled data.
Test Plan
Local validation used Cloudberry 3-devel / PostgreSQL 16.9, based on
867c6a147df, with this core patch and the companion extension. Tests used disposable installations and a one-coordinator/one-segment topology, not production data.make installcheckmake -C src/test installcheck-cbdb-parallelPassed locally:
basicSQL regression through Cloudberrypg_regress: 1/1 passed.The full Cloudberry regression and parallel installcheck suites have not been run. The test scripts and expected output are in the companion project, not in this core diff; repository-local coverage is still needed for upstream integration.
Reproduction from the companion project, with the patched Cloudberry source in an adjacent
cloudberrydirectory:python3 tests/prepare_stage.py # Replace the path with the temporary stage printed by the command above. python3 tests/run_all.py --stage /tmp/cloudberry-privacy-build.REPLACE_ME --benchmark-rows 10000Impact
Performance:
The patch adds per-field hook checks and endpoint metadata serialization/storage. Standalone core overhead has not been isolated.
An exploratory companion-extension run fetched 10,000 rows with two fields using a single utility backend. Median complete PQexec times over seven measured runs were:
These are end-to-end prototype measurements, not p95, multi-segment benchmarks, or performance acceptance results. They are affected by cache state, run order, and machine load. The current companion CPT adapter opens and validates its key file for every value; safe caching and key-rotation semantics remain future work.
User-facing changes:
Dependencies:
Checklist
The implementation review is not an independent security audit. Companion-project documentation exists, but core documentation and upstream test integration remain follow-up work.
Additional Context
This change is submitted as an experimental implementation for design review, not as a production-ready security boundary.
The companion prototype is opt-in and supports a restricted direct-column query subset. General expression provenance, inference resistance, complete view/partition/DDL/restore coverage, durable fail-closed auditing, cluster-wide immediate revocation, protected internal-copy workflows, and fault/failover testing remain incomplete. Protected WITH HOLD cursors and several unsupported query shapes are currently rejected by the companion extension.
The new privacy metadata is intended to contain only field origins, policy/version identifiers, and scoped capabilities—not raw JWTs, keys, or protected values. This does not imply that ordinary query plans or internal tuples contain no plaintext.
Implementation references:
9a36e58b961cloudberry-privacy, commita3c2831docs/test-results-2026-09-09.mdtests/prepare_stage.pyandtests/run_all.pyFeedback is particularly welcome on the hook API, the provider-specific SECURITY LABEL dispatch, endpoint metadata ownership/lifetime, and the appropriate split between core and extension responsibilities.
CI
Please run the normal CI jobs for this core change. No CI skip marker is requested.