You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "nzw921rx (via GitHub)" <gi...@apache.org> on 2026/09/20 13:04:23 UTC

[I] [Feature][Transform-V2] Extend FieldEncrypt with pluggable key providers, ciphertext prefixes, and optional hashes [seatunnel]

nzw921rx opened a new issue, #12407:
URL: https://github.com/apache/seatunnel/issues/12407

   ### Search before asking
   
   - [x] I searched the existing feature issues and found no open request covering this enhancement.
   
   ### Description
   
   SeaTunnel already provides the `FieldEncrypt` Transform, which can encrypt or decrypt selected fields with AES-CBC/AES-GCM and a directly configured key. It should be extended for production key-management and searchable encrypted-data use cases without coupling Transform-V2 to a specific cloud vendor.
   
   The enhancement should introduce a provider-neutral encryption/key-provider abstraction. The existing static-key behavior must remain available and backward compatible, while optional providers may integrate with services such as AWS KMS, Google Cloud KMS, Azure Key Vault, Alibaba Cloud KMS, HashiCorp Vault, or other secret/key-management systems.
   
   The design should not require one remote KMS call per row. Implementations should consider envelope encryption, data-key caching, key rotation/version metadata, provider lifecycle, retry/timeout behavior, and secure credential handling.
   
   #### Required capabilities
   
   1. **Configurable ciphertext prefix**
      - Allow users to directly configure a prefix such as `ENC:`.
      - Encryption prepends the configured prefix to the encoded ciphertext.
      - Decryption validates and removes the prefix before decrypting.
      - The prefix can be used to distinguish plaintext from ciphertext, avoid accidental double encryption, and support rows containing mixed historical formats.
      - The behavior for a missing or unexpected prefix must be explicit and configurable, for example `FAIL`, `SKIP`, or `KEEP_ORIGINAL`.
   
   2. **Optional hash generation**
      - Provide a switch such as `generate_hash` to generate a deterministic digest from the plaintext before encryption.
      - Allow the hash algorithm and destination field mapping/suffix to be configured.
      - Prefer a keyed construction such as HMAC-SHA-256 for sensitive or low-entropy fields; plain hashes of values such as phone numbers can be vulnerable to dictionary attacks.
      - Update the output schema when new hash fields are produced.
      - Hash generation should be independently optional for each configured field or field rule.
   
   3. **Pluggable key/encryption providers**
      - Preserve the current local/static-key AES behavior.
      - Define a stable SPI so cloud KMS, Vault, secret-manager, or custom providers can be added without embedding vendor-specific code in the core transform.
      - Support key identifiers and key versions/rotation metadata where the provider exposes them.
      - Never log plaintext keys, provider credentials, plaintext field values, or decrypted data.
   
   #### Illustrative configuration
   
   ```hocon
   transform {
     FieldEncrypt {
       fields = ["phone", "id_card"]
       mode = "encrypt"
       algorithm = "AES_GCM"
   
       key_provider = "kms"
       key_provider_options {
         provider = "custom-or-cloud-provider"
         key_id = "example-key-id"
       }
   
       ciphertext_prefix = "ENC:"
       generate_hash = true
       hash_algorithm = "HMAC_SHA256"
       hash_field_suffix = "_hash"
     }
   }
   ```
   
   The exact option names and provider packaging should be finalized during design review; the example describes the desired user-facing behavior rather than a fixed API.
   
   #### Compatibility and acceptance criteria
   
   - Existing `FieldEncrypt` configurations using `fields`, `key`, `algorithm`, and `mode` continue to work unchanged.
   - Encrypt/decrypt round trips work with and without a configured prefix.
   - Prefix mismatch behavior is tested for all supported policies.
   - Optional hash output is deterministic, schema-aware, and tested for multi-table pipelines.
   - Provider instances have a defined lifecycle and are safe for concurrent transform execution.
   - External-provider failures include useful context without exposing secrets.
   - Unit tests cover prefix, hash/HMAC, provider loading, key rotation/version metadata, null fields, and error policies.
   - Add focused Transform-V2 E2E coverage.
   - Add matching English and Chinese documentation, including security guidance and a warning about plain hashes for low-entropy sensitive data.
   
   ### Usage Scenario
   
   Users need to mask sensitive columns such as phone numbers, identity numbers, email addresses, and account identifiers while data is moving through SeaTunnel. Production deployments commonly keep encryption keys in cloud KMS or Vault rather than job configuration. A configurable prefix enables safe migration of mixed plaintext/ciphertext data, while an optional deterministic HMAC field allows equality lookup, deduplication, or upsert matching even when AES-GCM produces randomized ciphertext.
   
   ### Related issues
   
   - #10246 introduced the original `FieldEncrypt` transform.
   - #10361 implemented the initial field-encryption support.
   - #10603 added AES-GCM support.
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Feature][Transform-V2] Make FieldEncrypt production-ready with pluggable key management [seatunnel]

Posted by "JAEKWANG97 (via GitHub)" <gi...@apache.org>.
JAEKWANG97 commented on issue #12407:
URL: https://github.com/apache/seatunnel/issues/12407#issuecomment-6167221889

   Hi @nzw921rx, I'd like to help with this issue if the initial design work is still available.
   
   I've read the discussion and would start with a focused STIP/design draft before implementation, covering the provider/cipher boundary, lifecycle and concurrency ownership, compatibility with existing static-key configurations and ciphertext, and module/format boundaries. A provider-free test double could then verify that key acquisition stays out of the per-row path before adding a reference provider.
   
   Is anyone already working on this scope, and would it be reasonable for me to take on that initial design proposal?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Feature][Transform-V2] Make FieldEncrypt production-ready with pluggable key management [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12407:
URL: https://github.com/apache/seatunnel/issues/12407#issuecomment-6246034419

   Hi @JAEKWANG97, thanks for volunteering — the initial design work is still available and you are welcome to take it. There is no open KeyProvider implementation PR, so nobody else is on this scope.
   
   As noted above, the first deliverable should stay a design/STIP discussion rather than a provider implementation: `FieldEncrypt` still requires a direct `key`, the `Encryptor` SPI only exposes `init(String key)` plus encrypt/decrypt, and the encryptor is discovered lazily from the transform path, so the compatible provider/cipher boundary needs to be defined before any code lands.
   
   Your outline already lines up with the points listed in the previous comment: compatibility of existing static-key AES-CBC/AES-GCM jobs and ciphertext (including distinguishing a future versioned envelope from legacy ciphertext), KeyProvider vs. DataCipher responsibilities with `open`/`close` lifecycle, concurrency ownership and startup failures, envelope/data-key and rotation semantics with restart/restore behavior and no secrets in logs, errors, metrics or state, the module/dependency/shading boundary with a provider-free test double proving the no-per-row remote-call invariant, and a staged implementation and test plan.
   
   Please do not introduce a cloud SDK, a provider module, or a new public SPI in the first code change. Once the design proposal is ready, link it here so the compatibility and packaging contract can be settled before implementation starts. Looking forward to it.
   
   <!-- streview-comment:1848 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Feature][Transform-V2] Make FieldEncrypt production-ready with pluggable key management [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12407:
URL: https://github.com/apache/seatunnel/issues/12407#issuecomment-5760331919

   Classification: B / Transform-V2 key-provider architecture.
   
   I checked the current implementation before replying. `FieldEncrypt` still requires the direct `key` option, its `Encryptor` SPI is only `init(String key)` plus encrypt/decrypt operations, and the encryptor is initialized lazily from the transform path. That is not yet a key-provider lifecycle boundary. I found no open PR implementing a provider SPI; #12403 adds SQL AES functions and is unrelated.
   
   This is too broad to start as a provider-specific code PR. Please first open a STIP/design proposal that freezes the smallest compatible v1 contract: how the existing direct-key configuration remains byte-for-byte compatible, provider initialization/close and concurrency ownership, data-key/envelope and rotation semantics, ciphertext versioning, and how secrets are redacted from configuration, errors, metrics, state, and test fixtures. The proposal must also decide the artifact and shading boundary before any cloud SDK is introduced; do not add vendor SDKs directly to the existing transform module as a first step. A provider-free test double should demonstrate the lifecycle and no-per-row remote-call invariant before an official provider is selected. No label or assignment was changed in this triage.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Feature][Transform-V2] Make FieldEncrypt production-ready with pluggable key management [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12407:
URL: https://github.com/apache/seatunnel/issues/12407#issuecomment-6168242325

   Thanks for offering to take the initial design work. That scope is available, but it should remain a design/STIP discussion before any provider implementation starts.
   
   I rechecked the current implementation: `FieldEncrypt` still requires a direct `key`, discovers an `Encryptor` lazily from the transform path, and the SPI only exposes `init(String key)` plus encrypt/decrypt operations. There is no open KeyProvider implementation PR. That means the first deliverable should define the compatible boundary rather than add a provider or vendor SDK.
   
   Please start a focused design proposal and cover at least:
   
   1. How existing static-key AES-CBC/AES-GCM jobs and already-produced ciphertext remain compatible, including how a future versioned envelope is distinguished from legacy ciphertext.
   2. The KeyProvider versus DataCipher responsibilities, lifecycle (`open`/`close`), concurrency ownership, startup failures, and the rule that remote key access is never on the per-row path.
   3. Envelope/data-key and rotation semantics, plus restart/restore behavior without placing keys or credentials in logs, errors, metrics, or serialized state.
   4. The module, dependency, and shading boundary, including a provider-free test double that proves the lifecycle and no-per-row remote-call invariant.
   5. A staged implementation and test plan: compatible static-key refactor first, one reference provider only after the design is accepted, then additional providers.
   
   Please do not add a cloud SDK, a provider module, or a new public SPI in the first code change. Link the design discussion here so the community can settle the compatibility and packaging contract first.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Feature][Transform-V2] Make FieldEncrypt production-ready with pluggable key management [seatunnel]

Posted by "JAEKWANG97 (via GitHub)" <gi...@apache.org>.
JAEKWANG97 commented on issue #12407:
URL: https://github.com/apache/seatunnel/issues/12407#issuecomment-6246514456

   Thanks for clarifying! I'll start with a design/STIP proposal covering the compatibility, lifecycle, security, and packaging requirements, along with a staged implementation and test plan.
   
   I'll keep provider implementations, cloud SDKs, and public SPI changes out of the initial work, and link the proposal here when it's ready.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Feature][Transform-V2] Make FieldEncrypt production-ready with pluggable key management [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12407:
URL: https://github.com/apache/seatunnel/issues/12407#issuecomment-5771146218

   Thanks for the detailed proposal. Since this touches public SPI, ciphertext layout and packaging, please open a design doc / discussion on the dev@ mailing list before implementation so the KeyProvider and DataCipher interfaces, versioning of the ciphertext format, and module layout (seatunnel-transforms-v2 core vs. optional provider modules) can be agreed on first.
   
   Please clarify the backward-compatibility guarantee: existing jobs using a static `key` with AES-CBC/AES-GCM must keep working unchanged, and data already encrypted by the current implementation should remain decryptable. It would help to spell out how the new ciphertext layout (e.g. key-version/provider metadata header) is distinguished from legacy ciphertext.
   
   Suggest splitting delivery into incremental PRs: (1) SPI + refactor of existing static-key path with tests, (2) one reference provider (e.g. HashiCorp Vault or AWS KMS) with e2e tests, (3) remaining providers. Please also state how key caching/rotation and provider initialization failures are handled at job start versus per-record.
   
   <!-- streview-comment:1234 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org