"kind": "SealedSecret",
"apiVersion": "bitnami.com/v1alpha1",
"metadata": {
"name": "mysecret",
"namespace": "default",
"creationTimestamp": null
},
"spec": {
"template": {
"metadata": {
"name": "mysecret",
"namespace": "default",
"creationTimestamp": null,
"labels": {
"jenkins.io/credentials-type": "usernamePassword"
},
"annotations": {
"jenkins.io/credentials-description": "mysecret",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Secret\",\"metadata\":{\"annotations\":{\"jenkins.io/credentials-description\":\"mysecret\"},\"labels\":{\"jenkins.io/credentials-type\":\"usernamePassword\"},\"name\":\"mysecret\",\"namespace\":\"default\"},\"stringData\":{\"password\":\"secretpassword\",\"username\":\"username\"},\"type\":\"Opaque\"}\n"
}
},
"type": "Opaque"
},
"encryptedData": {
"password": "...",
"username": "..."
}
},
"status": {
}
}
We're using kubeseal v0.8.1 now, with support for metadata annotations, which is nice for secrets like jenkins-credentials. But due to this change the
kubectl.kubernetes.io/last-applied-configurationannotation also gets added. And in my way of using kubeseal the stringData will leak into the sealed secret this way.Reproduce issue (my workflow)
I typically first create a secret with stringData which is convenient. I apply it, so I can test it. Then I finally read it out from the cluster, feed it through kubeseal and commit it to git. This ensures me that the
stringDatahas been converted todataand the secret actually works. And this workflow produces this issue. Describe in more detail below:Create a secret with
stringDataproperty rather thandataproperty for convenience in a file.mysecret.yamlApply the secret to the cluster.
kubectl apply -f mysecret.yamlThe secret in the cluster now has the
stringDataproperty in thespec:template:metadata:annotations:kubectl.kubernetes.io/last-applied-configuration.Checkout the secret and seal with kubeseal
kubectl get secret mysecret -o json | kubeseal --cert cert.pem > sealed-secret.jsonNow the sealed-secret.json contains the secret in plaintex in the metadata:
The resulting secret is not safe to share or check into git.
Probably the same will happen for the
dataproperty, which is just the base64 encoded version of the stringDataWhat should happen
I think the best way of dealing with this issue is by stripping the last-applied-configuration when ingesting a secret.