Keep gitlab CI/CD variables secret in public repository











up vote
2
down vote

favorite
1












I have a private project on Gitlab with CI/CD set up to push/pull docker images from Google Container Registry and to deploy my software to Kubernetes Engine in GCP.



Is there a way to make my project public without worrying about the secrets used to connect to GCP getting leaked? In particular, I'm worried that when my repository is public anyone would be able to add a line like echo $GCP_REPOSITORY_SECRET somewhere in the .gitlab-ci.yml file, push their branch and view the output of the CI to "discover" my secret. Does Gitlab have a mechanism to prevent this? More fundamentally, are there best practices to keep deployment secrets secret for public repositories?










share|improve this question


























    up vote
    2
    down vote

    favorite
    1












    I have a private project on Gitlab with CI/CD set up to push/pull docker images from Google Container Registry and to deploy my software to Kubernetes Engine in GCP.



    Is there a way to make my project public without worrying about the secrets used to connect to GCP getting leaked? In particular, I'm worried that when my repository is public anyone would be able to add a line like echo $GCP_REPOSITORY_SECRET somewhere in the .gitlab-ci.yml file, push their branch and view the output of the CI to "discover" my secret. Does Gitlab have a mechanism to prevent this? More fundamentally, are there best practices to keep deployment secrets secret for public repositories?










    share|improve this question
























      up vote
      2
      down vote

      favorite
      1









      up vote
      2
      down vote

      favorite
      1






      1





      I have a private project on Gitlab with CI/CD set up to push/pull docker images from Google Container Registry and to deploy my software to Kubernetes Engine in GCP.



      Is there a way to make my project public without worrying about the secrets used to connect to GCP getting leaked? In particular, I'm worried that when my repository is public anyone would be able to add a line like echo $GCP_REPOSITORY_SECRET somewhere in the .gitlab-ci.yml file, push their branch and view the output of the CI to "discover" my secret. Does Gitlab have a mechanism to prevent this? More fundamentally, are there best practices to keep deployment secrets secret for public repositories?










      share|improve this question













      I have a private project on Gitlab with CI/CD set up to push/pull docker images from Google Container Registry and to deploy my software to Kubernetes Engine in GCP.



      Is there a way to make my project public without worrying about the secrets used to connect to GCP getting leaked? In particular, I'm worried that when my repository is public anyone would be able to add a line like echo $GCP_REPOSITORY_SECRET somewhere in the .gitlab-ci.yml file, push their branch and view the output of the CI to "discover" my secret. Does Gitlab have a mechanism to prevent this? More fundamentally, are there best practices to keep deployment secrets secret for public repositories?







      gitlab gitlab-ci






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 22:54









      Paymahn Moghadasian

      1,51642237




      1,51642237
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote














          More fundamentally, are there best practices to keep deployment secrets secret for public repositories?




          Yes, don't have any sensitive data in it. Ever.



          At the GCP level, the secret management options are listed here.



          When connecting a GitLab-CI to GCP, you can see the security implication here, which uses kubectl get secret <secret name> -o jsonpath="{['data']['ca.crt']}" | base64 -D, with the right account and RBAC.




          The whole cluster security is based on a model where developers are trusted, so only trusted users should be allowed to control your clusters.







          share|improve this answer





















          • Even if I use KMS, won't my CI jobs need a decryption key? If the jobs have a decryption key, can't that be echo-ed and then used maliciously? Our plan is to only allow trusted developers access the cluster but I'm worried that making our repository public will give untrusted developers access to our cluster, which would be bad. I think private pipelines might be the right solution: docs.gitlab.com/ee/user/project/pipelines/…
            – Paymahn Moghadasian
            Nov 12 at 13:45






          • 1




            @PaymahnMoghadasian Agreed regarding KCM: that is what is mentioned in hk.saowen.com/a/…
            – VonC
            Nov 12 at 16:55











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244223%2fkeep-gitlab-ci-cd-variables-secret-in-public-repository%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote














          More fundamentally, are there best practices to keep deployment secrets secret for public repositories?




          Yes, don't have any sensitive data in it. Ever.



          At the GCP level, the secret management options are listed here.



          When connecting a GitLab-CI to GCP, you can see the security implication here, which uses kubectl get secret <secret name> -o jsonpath="{['data']['ca.crt']}" | base64 -D, with the right account and RBAC.




          The whole cluster security is based on a model where developers are trusted, so only trusted users should be allowed to control your clusters.







          share|improve this answer





















          • Even if I use KMS, won't my CI jobs need a decryption key? If the jobs have a decryption key, can't that be echo-ed and then used maliciously? Our plan is to only allow trusted developers access the cluster but I'm worried that making our repository public will give untrusted developers access to our cluster, which would be bad. I think private pipelines might be the right solution: docs.gitlab.com/ee/user/project/pipelines/…
            – Paymahn Moghadasian
            Nov 12 at 13:45






          • 1




            @PaymahnMoghadasian Agreed regarding KCM: that is what is mentioned in hk.saowen.com/a/…
            – VonC
            Nov 12 at 16:55















          up vote
          3
          down vote














          More fundamentally, are there best practices to keep deployment secrets secret for public repositories?




          Yes, don't have any sensitive data in it. Ever.



          At the GCP level, the secret management options are listed here.



          When connecting a GitLab-CI to GCP, you can see the security implication here, which uses kubectl get secret <secret name> -o jsonpath="{['data']['ca.crt']}" | base64 -D, with the right account and RBAC.




          The whole cluster security is based on a model where developers are trusted, so only trusted users should be allowed to control your clusters.







          share|improve this answer





















          • Even if I use KMS, won't my CI jobs need a decryption key? If the jobs have a decryption key, can't that be echo-ed and then used maliciously? Our plan is to only allow trusted developers access the cluster but I'm worried that making our repository public will give untrusted developers access to our cluster, which would be bad. I think private pipelines might be the right solution: docs.gitlab.com/ee/user/project/pipelines/…
            – Paymahn Moghadasian
            Nov 12 at 13:45






          • 1




            @PaymahnMoghadasian Agreed regarding KCM: that is what is mentioned in hk.saowen.com/a/…
            – VonC
            Nov 12 at 16:55













          up vote
          3
          down vote










          up vote
          3
          down vote










          More fundamentally, are there best practices to keep deployment secrets secret for public repositories?




          Yes, don't have any sensitive data in it. Ever.



          At the GCP level, the secret management options are listed here.



          When connecting a GitLab-CI to GCP, you can see the security implication here, which uses kubectl get secret <secret name> -o jsonpath="{['data']['ca.crt']}" | base64 -D, with the right account and RBAC.




          The whole cluster security is based on a model where developers are trusted, so only trusted users should be allowed to control your clusters.







          share|improve this answer













          More fundamentally, are there best practices to keep deployment secrets secret for public repositories?




          Yes, don't have any sensitive data in it. Ever.



          At the GCP level, the secret management options are listed here.



          When connecting a GitLab-CI to GCP, you can see the security implication here, which uses kubectl get secret <secret name> -o jsonpath="{['data']['ca.crt']}" | base64 -D, with the right account and RBAC.




          The whole cluster security is based on a model where developers are trusted, so only trusted users should be allowed to control your clusters.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 0:48









          VonC

          821k28425773093




          821k28425773093












          • Even if I use KMS, won't my CI jobs need a decryption key? If the jobs have a decryption key, can't that be echo-ed and then used maliciously? Our plan is to only allow trusted developers access the cluster but I'm worried that making our repository public will give untrusted developers access to our cluster, which would be bad. I think private pipelines might be the right solution: docs.gitlab.com/ee/user/project/pipelines/…
            – Paymahn Moghadasian
            Nov 12 at 13:45






          • 1




            @PaymahnMoghadasian Agreed regarding KCM: that is what is mentioned in hk.saowen.com/a/…
            – VonC
            Nov 12 at 16:55


















          • Even if I use KMS, won't my CI jobs need a decryption key? If the jobs have a decryption key, can't that be echo-ed and then used maliciously? Our plan is to only allow trusted developers access the cluster but I'm worried that making our repository public will give untrusted developers access to our cluster, which would be bad. I think private pipelines might be the right solution: docs.gitlab.com/ee/user/project/pipelines/…
            – Paymahn Moghadasian
            Nov 12 at 13:45






          • 1




            @PaymahnMoghadasian Agreed regarding KCM: that is what is mentioned in hk.saowen.com/a/…
            – VonC
            Nov 12 at 16:55
















          Even if I use KMS, won't my CI jobs need a decryption key? If the jobs have a decryption key, can't that be echo-ed and then used maliciously? Our plan is to only allow trusted developers access the cluster but I'm worried that making our repository public will give untrusted developers access to our cluster, which would be bad. I think private pipelines might be the right solution: docs.gitlab.com/ee/user/project/pipelines/…
          – Paymahn Moghadasian
          Nov 12 at 13:45




          Even if I use KMS, won't my CI jobs need a decryption key? If the jobs have a decryption key, can't that be echo-ed and then used maliciously? Our plan is to only allow trusted developers access the cluster but I'm worried that making our repository public will give untrusted developers access to our cluster, which would be bad. I think private pipelines might be the right solution: docs.gitlab.com/ee/user/project/pipelines/…
          – Paymahn Moghadasian
          Nov 12 at 13:45




          1




          1




          @PaymahnMoghadasian Agreed regarding KCM: that is what is mentioned in hk.saowen.com/a/…
          – VonC
          Nov 12 at 16:55




          @PaymahnMoghadasian Agreed regarding KCM: that is what is mentioned in hk.saowen.com/a/…
          – VonC
          Nov 12 at 16:55


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244223%2fkeep-gitlab-ci-cd-variables-secret-in-public-repository%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python