Skip to content

Add support for global secret changing #21068

@ianseyer

Description

@ianseyer

Currently, the global secret value used for encrypting/decrypting strings is unable to change. See goharbor/harbor-helm#325 (comment)

The value is specified here (when using helm): https://github.com/goharbor/harbor-helm/blob/main/values.yaml#L360

and used by: https://github.com/goharbor/harbor/blob/main/src/lib/encrypt/encrypt.go

More technically, it is able to change, which results in Harbor being unable to decrypt already-encrypted values. This puts harbor into an inoperable state. Additionally, once changed, even reverting the secret does not make Harbor healthy again (I imagine because the new value has been used to encrypt new strings? Unsure.)

This means that a simple value change being applied will break Harbor, seemingly forever.

I see a three-pronged solution to this problem:

  1. Documentation
    Provide documentation that clearly indicates that this value must not change. Additionally, documentation must be provided that guides users on how to repair Harbor if the value does change.

  2. Logging & Locking to allow reversion
    Harbor should, if the global secret were to change, preempt issues by refusing to perform encryption/decryption and immediately log a FATAL error linking users to the documentation from # 1.
    This could potentially be accomplished by, on boot, immediately attempting to decrypt a secret. If that fails, abort boot.

  3. Supporting changing
    Harbor should provide tooling to support changing this secret. Plenty of companies (ours included) have policies around rotations and the like. Additionally, it would be trivial for an engineer to mistakenly change the value.

I imagine this would work as follows, though I am not sure:

  • use the current global-secret to decrypt all secrets
  • encrypt all secrets using the new global-secret
  • discard the old global-secret

I have flagged this as [Urgent] primarily because it there is no documentation around how to revert this change; I view an "undo" guide to be the MVP for a solution here. We recently had to nuke our staging postgres environment because we changed this secret value. If this has happened in production, we would likely look for alternatives to Harbor.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions