@@ -11,9 +11,9 @@ varying ways.
1111
1212## Introduction
1313
14- After reading that "best practice" suggests that one should “Never put any
14+ After reading that "best practice" suggests that one should never put any
1515secret or credentials in the Dockerfile instructions (environment variables,
16- args, or hard coded into any command)” (Álvaro Iradier, 2021)[ ^ dockerfile-best-practices ] and seeing how
16+ args, or hard coded into any command) (Álvaro Iradier, 2021)[ ^ dockerfile-best-practices ] and seeing how
1717often this practice is ignored, I questioned how easy it would be to extract
1818secrets from a Docker image.
1919
@@ -24,9 +24,9 @@ secrets from a Docker image.
2424One way that secrets tend to be stored into a Docker image is through
2525copying sensitive files into the image, whether by mistake, due to naivety, or
2626for "ease of use". Fundamentally, this issue is described by [ CWE-798: Use of
27- Hard-coded Credentials] [ cwe-798-harcoded-credentials ] in that “Hard -coded
27+ Hard-coded Credentials] [ cwe-798-harcoded-credentials ] in that hard -coded
2828credentials typically create a significant hole that allows an attacker to
29- bypass the authentication that has been configured” (Mitre.org, 2020)[ ^ cwe-798 ] .
29+ bypass the authentication that has been configured (Mitre.org, 2020)[ ^ cwe-798 ] .
3030
3131Secrets could be stored into a Docker image by copying your ` .env ` file into the
3232image, or by copying a private key, or other similar credentials, into the
@@ -49,14 +49,14 @@ Apigee][gcp-apigee-exploit].
4949In the case of Codecov, credentials exported from a Docker image were used to
5050launch a man-in-the-middle attack on Codecov's infrastructure and further
5151exfiltrate the environment variables of some of Codecov's 23,000 customers
52- (Jackson, 2021)[ ^ codecov-breach ] - and, consequentially, “Large organizations such as Twilio,
52+ (Jackson, 2021)[ ^ codecov-breach ] - and, consequentially, large organizations such as Twilio,
5353Hashicorp, Rapid7, Confluent have released their own statements about how this
54- has affected them.” (Jackson, 2021)[ ^ codecov-breach ]
54+ has affected them. (Jackson, 2021)[ ^ codecov-breach ]
5555
56- Similarly, in the case of Apigee it was found that “ Aside from a number of other
56+ Similarly, in the case of Apigee it was found that Aside from a number of other
5757bugs found by analysing the source code (SSRFs, path traversals, authorization
5858bypasses and more), the image included several hard-coded passwords, which
59- turned out to be re-used in production.” (August, 2023)[ ^ apigee-case ] As a result of these
59+ turned out to be re-used in production. (August, 2023)[ ^ apigee-case ] As a result of these
6060findings, the researcher was able to gain access to Google's own Apigee
6161instance.
6262
@@ -66,17 +66,17 @@ instance.
6666
6767## Why It Matters
6868
69- The security concept of Least Privilege asserts that “ a user or entity should
69+ The security concept of Least Privilege asserts that a user or entity should
7070only have access to the specific data, resources and applications needed to
71- complete a required task.” (Palo Alto Networks, 2015)[ ^ least-privilege-explanation ] which,
71+ complete a required task. (Palo Alto Networks, 2015)[ ^ least-privilege-explanation ] which,
7272consequentially, helps to reduce attack surface and attack spread. By storing
7373secrets in Docker images, it becomes possible to bypass other security
7474procedures without the need for them to be compromised, nor for the attacker to
7575escalate their privileges.
7676
77- Alongside this, a pillar of zero-trust security is the assumption that “ there
77+ Alongside this, a pillar of zero-trust security is the assumption that there
7878are attackers both within and outside of the network, so no users or machines
79- should be automatically trusted.” (Cloudflare.com, 2021)[ ^ zero-trust-explanation ]
79+ should be automatically trusted. (Cloudflare.com, 2021)[ ^ zero-trust-explanation ]
8080
8181By leaving such such a security hole in your application, any RBAC or other
8282procedures that you have in place to protect your application are bypassed and
@@ -85,9 +85,9 @@ and infrastructure.
8585
8686### My Docker Repository is Private, So It's Safe, Right?
8787
88- In the case of Apigee, this was accidentally not the case - " a Docker registry
88+ In the case of Apigee, this was accidentally not the case - a Docker registry
8989was available on docker.apigee.net, which allowed unauthenticated users to pull
90- the Apigee Edge Docker image" (August, 2023)[ ^ apigee-case ] . This is the kind of small
90+ the Apigee Edge Docker image (August, 2023)[ ^ apigee-case ] . This is the kind of small
9191oversight that can have large consequences. It is one issue to accidentally
9292expose the source code of your application - whereas exposing the critical
9393secrets of the application alongside it gives an attacker both the lock and the
@@ -115,16 +115,16 @@ use a secret management system to store and retrieve these secrets. This allows
115115you to keep your Docker image free of sensitive information and allows you to
116116rotate secrets without needing to rebuild your Docker image.
117117
118- “ Ideally, secrets should be stored in a cryptographic secret vault and loaded
119- when needed" (August, 2023)[ ^ apigee-case ] and such a solution can be implemented using
118+ Ideally, secrets should be stored in a cryptographic secret vault and loaded
119+ when needed (August, 2023)[ ^ apigee-case ] and such a solution can be implemented using
120120tools such as [ HashiCorp Vault] [ hashicorp-vault ] , [ AWS Secrets
121121Manager] [ aws-secrets-manager ] , [ Google Cloud Secret
122122Manager] [ gcp-secret-manager ] , or [ Azure Key Vault] [ azure-key-vault ] .
123123
124- As an additional preventative step, “ you can prevent files from accidentally
124+ As an additional preventative step, you can prevent files from accidentally
125125winding up on your image by adding them to the ` .dockerignore ` file. For
126126example, if you’re worried about accidentally adding SSH keys to your image, you
127- can include: ` *id_rsa* ` ” (Cotton, 2023)[ ^ protecting-docker-secrets ]
127+ can include: ` *id_rsa* ` (Cotton, 2023)[ ^ protecting-docker-secrets ]
128128
129129[ hashicorp-vault ] : https://www.hashicorp.com/products/vault
130130[ aws-secrets-manager ] : https://aws.amazon.com/secrets-manager/
0 commit comments