Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50242

withCredentials step masking easily bypassed

    XMLWordPrintable

Details

    Description

      A very common use case of Jenkins is to delegate the responsibility of the creation of pipelines to third parties or developers. These external teams should be able to use secrets given to them via Jenkins credentials, but shouldn't be able to visualize the value of the secret.

      For this use case, withCredentials is broken:

      node {
        stage('Break Security') {
          withCredentials([string(credentialsId: 'AWS_DEFAULT_REGION', variable: 'AWS_DEFAULT_REGION'),
          string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'AWS_ACCESS_KEY_ID'),
          string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'AWS_SECRET_ACCESS_KEY')]) {
            def exposedSecret = ""
            for(letter in env.AWS_SECRET_ACCESS_KEY) {
              exposedSecret = "$exposedSecret $letter"
            }
            echo "$exposedSecret"
          }
        }
      }

      The secret can be easily viewed.

      Letting someone work on a pipeline is basically showing them the secrets that pipeline uses.
      For this example I used "Secret Text", but it also happens with "AWS Credentials".

      Attachments

        Issue Links

          Activity

            apineros Andres Pineros created issue -
            apineros Andres Pineros made changes -
            Field Original Value New Value
            Description A very common use case of Jenkins is to delegate the responsibility of the creation of pipelines to third parties or developers. These external teams should be able to use secrets given to them via Jenkins credentials, but shouldn't be able to visualize the value of the secret.

            For this use case, withCredentials is broken:
            {code:java}
            node {
             stage('Break Security') {
               withCredentials([string(credentialsId: 'AWS_DEFAULT_REGION', variable: 'AWS_DEFAULT_REGION'), string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'AWS_ACCESS_KEY_ID'), string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'AWS_SECRET_ACCESS_KEY')]) {
              def exposedSecret = ""
              for(letter in env.AWS_DEFAULT_REGION) {
              exposedSecret = "$exposedSecret $letter"
             }
             echo "$exposedSecret"
             }
             }
            }{code}
            The secret can be easily viewed.

            Letting someone work on a pipeline is basically showing them the secrets that pipeline uses.
            A very common use case of Jenkins is to delegate the responsibility of the creation of pipelines to third parties or developers. These external teams should be able to use secrets given to them via Jenkins credentials, but shouldn't be able to visualize the value of the secret.

            For this use case, withCredentials is broken:
            {code:java}
            node {
            stage('Break Security') {
            withCredentials([string(credentialsId: 'AWS_DEFAULT_REGION', variable: 'AWS_DEFAULT_REGION'),
            string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'AWS_ACCESS_KEY_ID'),
            string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'AWS_SECRET_ACCESS_KEY')]) {
            def exposedSecret = ""
            for(letter in env.AWS_DEFAULT_REGION) {
            exposedSecret = "$exposedSecret $letter"
            }
            echo "$exposedSecret"
            }
            }
            }{code}
            The secret can be easily viewed.

            Letting someone work on a pipeline is basically showing them the secrets that pipeline uses.
            apineros Andres Pineros made changes -
            Description A very common use case of Jenkins is to delegate the responsibility of the creation of pipelines to third parties or developers. These external teams should be able to use secrets given to them via Jenkins credentials, but shouldn't be able to visualize the value of the secret.

            For this use case, withCredentials is broken:
            {code:java}
            node {
            stage('Break Security') {
            withCredentials([string(credentialsId: 'AWS_DEFAULT_REGION', variable: 'AWS_DEFAULT_REGION'),
            string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'AWS_ACCESS_KEY_ID'),
            string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'AWS_SECRET_ACCESS_KEY')]) {
            def exposedSecret = ""
            for(letter in env.AWS_DEFAULT_REGION) {
            exposedSecret = "$exposedSecret $letter"
            }
            echo "$exposedSecret"
            }
            }
            }{code}
            The secret can be easily viewed.

            Letting someone work on a pipeline is basically showing them the secrets that pipeline uses.
            A very common use case of Jenkins is to delegate the responsibility of the creation of pipelines to third parties or developers. These external teams should be able to use secrets given to them via Jenkins credentials, but shouldn't be able to visualize the value of the secret.

            For this use case, withCredentials is broken:
            {code:java}
            node {
              stage('Break Security') {
                withCredentials([string(credentialsId: 'AWS_DEFAULT_REGION', variable: 'AWS_DEFAULT_REGION'),
                string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'AWS_ACCESS_KEY_ID'),
                string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'AWS_SECRET_ACCESS_KEY')]) {
                  def exposedSecret = ""
                  for(letter in env.AWS_DEFAULT_REGION) {
                    exposedSecret = "$exposedSecret $letter"
                  }
                  echo "$exposedSecret"
                }
              }
            }{code}
            The secret can be easily viewed.

            Letting someone work on a pipeline is basically showing them the secrets that pipeline uses.
            apineros Andres Pineros made changes -
            Description A very common use case of Jenkins is to delegate the responsibility of the creation of pipelines to third parties or developers. These external teams should be able to use secrets given to them via Jenkins credentials, but shouldn't be able to visualize the value of the secret.

            For this use case, withCredentials is broken:
            {code:java}
            node {
              stage('Break Security') {
                withCredentials([string(credentialsId: 'AWS_DEFAULT_REGION', variable: 'AWS_DEFAULT_REGION'),
                string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'AWS_ACCESS_KEY_ID'),
                string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'AWS_SECRET_ACCESS_KEY')]) {
                  def exposedSecret = ""
                  for(letter in env.AWS_DEFAULT_REGION) {
                    exposedSecret = "$exposedSecret $letter"
                  }
                  echo "$exposedSecret"
                }
              }
            }{code}
            The secret can be easily viewed.

            Letting someone work on a pipeline is basically showing them the secrets that pipeline uses.
            A very common use case of Jenkins is to delegate the responsibility of the creation of pipelines to third parties or developers. These external teams should be able to use secrets given to them via Jenkins credentials, but shouldn't be able to visualize the value of the secret.

            For this use case, withCredentials is broken:
            {code:java}
            node {
              stage('Break Security') {
                withCredentials([string(credentialsId: 'AWS_DEFAULT_REGION', variable: 'AWS_DEFAULT_REGION'),
                string(credentialsId: 'AWS_ACCESS_KEY_ID', variable: 'AWS_ACCESS_KEY_ID'),
                string(credentialsId: 'AWS_SECRET_ACCESS_KEY', variable: 'AWS_SECRET_ACCESS_KEY')]) {
                  def exposedSecret = ""
                  for(letter in env.AWS_SECRET_ACCESS_KEY) {
                    exposedSecret = "$exposedSecret $letter"
                  }
                  echo "$exposedSecret"
                }
              }
            }{code}
            The secret can be easily viewed.

            Letting someone work on a pipeline is basically showing them the secrets that pipeline uses.
            For this example I used "Secret Text", but it also happens with "AWS Credentials".
            apineros Andres Pineros made changes -
            Summary withCredentials step masking isn't secure withCredentials step masking easily bypassed
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 49 (Web Link)" [ 20272 ]
            jglick Jesse Glick made changes -
            Resolution Not A Defect [ 7 ]
            Status Open [ 1 ] Resolved [ 5 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "Page (Jenkins Wiki)" [ 20282 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "Page (Jenkins Wiki)" [ 20282 ] This issue links to "Page (Jenkins Wiki)" [ 20282 ]
            kon Kalle Niemitalo made changes -
            Link This issue is duplicated by JENKINS-60962 [ JENKINS-60962 ]
            kon Kalle Niemitalo made changes -
            Link This issue relates to JENKINS-54538 [ JENKINS-54538 ]
            kon Kalle Niemitalo made changes -
            Link This issue relates to JENKINS-61277 [ JENKINS-61277 ]

            People

              Unassigned Unassigned
              apineros Andres Pineros
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: