Skip to content

Job payload encryption is advertised but never applied #11

Closed

Description

@CodingAnarchy

The README advertises "🔐 Job Encryption & PII Protection" (AES-256-GCM / ChaCha20-Poly1305, field-level PII protection, retention policies), but with the encryption feature enabled payloads are stored and processed in plaintext.

What happens today

  • Job::with_encryption(config) and Job::with_pii_fields(..) store the config on the Job struct, but nothing acts on it.
  • No enqueue, batch-enqueue or update query in src/queue/postgres.rs or src/queue/mysql.rs writes is_encrypted, encryption_key_id, encryption_algorithm, encrypted_payload, encryption_nonce, encryption_tag, encryption_metadata, payload_hash, pii_fields, retention_policy, retention_delete_at or encrypted_at. The columns from migration 011 are always NULL/false.
  • JobRow::into_job reads those columns back (build_encryption_config, build_encrypted_payload, parse_retention_policy), but they're never populated.
  • Nothing encrypts on enqueue or decrypts before the worker's handler runs. EncryptionEngine and KeyManager work on their own, but the queue never calls them.

A user who enables encryption for PII believes sensitive data is encrypted at rest, and it isn't. That's a security and compliance problem.

Expected

  • On enqueue (single and batch): if a job has an EncryptionConfig, encrypt the payload (or only the pii_fields) with the configured engine/key. Store the ciphertext in encrypted_payload with nonce, tag, key id, algorithm and metadata, set is_encrypted, and don't store the plaintext payload (store a redacted placeholder in payload).
  • On dequeue / get_job: decrypt transparently before the job reaches the handler, and fail the job with a clear error if the key is unavailable.
  • Retention policies (retention_delete_at) are enforced by a cleanup path.
  • PostgreSQL/MySQL parity, with integration tests on both that check the stored row holds no plaintext.
  • Without the feature or a config, behaviour is unchanged.

Part of #7. Found during the clippy workstream (#10, which left a TODO(#7) on JobRow).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions