Repository navigation
fix(security): redact encrypted value and IV from secret reads - #6
Merged
Merged
Conversation
The secrets endpoints returned the Secret entity as-is, exposing each secret's stored ciphertext and IV via GET /secrets and GET /secrets/:id. Even though the material is encrypted, exposing it (and the IV) widens the attack surface and is unnecessary for callers, who should use the decrypt endpoint. - Mark Secret.encryptedValue and Secret.iv as select: false so they are never loaded for reads - Load them explicitly (explicit addSelect) only in getSecretValue, the one place decryption happens - Add a test covering the explicit selection in getSecretValue
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.
Problem
The secrets API returns the
Secretentity directly, soGET /secretsandGET /secrets/:idinclude the storedencryptedValueandiv. Exposing ciphertext + IV to every API caller is unnecessary (decryption already goes throughGET /secrets/:id/value) and widens the attack surface. This is the follow-up flagged in #1.Fix
Secret.encryptedValueandSecret.ivare now@Column({ ..., select: false }), so they are excluded from all default reads (find,findOne,getAllSecrets, and the entity returned by create/update/rotate responses).getSecretValue()— the only place that needs the material — loads them explicitly viacreateQueryBuilder('secret').addSelect(['secret.encryptedValue', 'secret.iv']).getSecretValueuses that explicit selection and decrypts correctly.Writes are unaffected:
createSecret/updateSecret/rotateSecretset the fields in memory andsave()persists them.Acceptance criteria
GET /secrets/GET /secrets/:idno longer exposeencryptedValueorivGET /secrets/:id/valuestill decrypts correctlyVerification (in
microservices/config-service)