Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secrets don't get re-encrypted and stays persisted as a plain text #14864

Closed
php-coder opened this issue Jun 23, 2017 · 4 comments
Closed

Secrets don't get re-encrypted and stays persisted as a plain text #14864

php-coder opened this issue Jun 23, 2017 · 4 comments
Assignees
Labels
area/security component/restapi kind/bug Categorizes issue or PR as related to a bug. priority/P1

Comments

@php-coder
Copy link
Contributor

When user starts to use secrets encryption, the existing secrets should be encrypted after running oadm migrate storage --include=secrets --confirm. But it doesn't happen and secrets stay persisted in the plain text.

Version
oc v3.6.0-alpha.2+b28a75e-471-dirty
kubernetes v1.6.1+5115d708d7
features: Basic-Auth
Steps To Reproduce
  1. start OpenShift without secrets encryption enabled (for example, sudo $(which openshift) start --public-master=127.0.0.1 )
  2. create a secret (oc create secret generic foo --from-literal=password=test123)
  3. stop OpenShift
  4. create an encryption config:
kind: EncryptionConfig
apiVersion: v1
resources:
  - resources:
    - secrets
    providers:
    - aesgcm:
        keys:
        - name: key1
          secret: c2vjcmv0iglzihnly3vyzq==
    - identity: {}
  1. generate master config (sudo $(which openshift) start master --public-master=127.0.0.1 --write-config=$PWD/openshift.local.config/master)
  2. edit master config and enable secrets encryption (sudoedit openshift.local.config/master/master-config.yaml)
kubernetesMasterConfig:
  apiServerArguments:
    experimental-encryption-provider-config:
    - /path/to/encryption.config
  1. start OpenShift with secrets encryption enabled (sudo $(which openshift) start --public-master=127.0.0.1 --master-config=$PWD/openshift.local.config/master/master-config.yaml --node-config=$PWD/openshift.local.config/<node>/node-config.yaml)
  2. check that the secret persisted in the plain text (the ETCDCTL_API=3 etcdctl --cacert=$PWD/openshift.local.config/master/ca.crt --key=$PWD/openshift.local.config/master/master.etcd-client.key --cert=$PWD/openshift.local.config/master/master.etcd-client.crt --endpoints 'https://127.0.0.1:4001' get /kubernetes.io/secrets/default/foo -w fields | grep Value command should output something like this: "Value" : "k8s\x00\n\f\n\x02v1\x12\x06Secret\x12\x91\x01\nr\n\x03foo\x12\x00\x1a\adefault\"&/api/v1/namespaces/default/secrets/foo*$6689f2de-566f-11e7-8bdd-507b9d2b16b92\x008\x00B\f\b㞩\xca\x05\x10\xfd\xf6\xce\xd1\x03z\x00\x12\x13\n\bpassword\x12\atest123\x1a\x06Opaque\x1a\x00\"\x00")
  3. migrate secrets (oadm migrate storage --include=secrets --confirm)
  4. check that the secret persisted in the encrypted form
Current Result

Step 8: oadm migrate storage outputs summary: total=168 errors=0 ignored=0 unchanged=168 migrated=0
Step 9: the secret persisted in the plain text (output is similar to the Step 7)

Expected Result

Step 8: oadm migrate storage should print summary: total=168 errors=0 ignored=0 unchanged=0 migrated=168
Step 9: the secret should be encrypted and data should starts from the "k8s:enc:aesgcm:v1:key1:" prefix, for example: "Value" : "k8s:enc:aesgcm:v1:key1:n\x14YG(\x008i\xee\u007f\xce\xd0...

Additional Information

IMPORTANT: I've tested with #14836 and #14838 being applied.

My debug observations:

  • Inside of UpdateResource() the flag wasCreated is false
  • Inside of GuaranteedUpdate() we're exiting very early, just before transforming data to storage. At this point origState.stale flag is false but it should be true
  • origState with a wrong stale field has been returned from getStateFromObject function

@smarterclayton @liggitt @simo5 I couldn't provide a fix at this moment because I don't have enough time and I'm not familiar with rest/etcd code for doing an update. Next week I'll be on PTO and if this blocked issue will be fixed by someone else, I wouldn't mind.

@php-coder
Copy link
Contributor Author

@smarterclayton
Copy link
Contributor

smarterclayton commented Jun 23, 2017 via email

@php-coder
Copy link
Contributor Author

It turned out that it has been fixed by #15001

@smarterclayton Thanks for fixing this but if you mentioned me at that issue then I wouldn't try to fix it today... :(

@smarterclayton
Copy link
Contributor

smarterclayton commented Jul 10, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security component/restapi kind/bug Categorizes issue or PR as related to a bug. priority/P1
Projects
None yet
Development

No branches or pull requests

3 participants