docker:security:use_copy_instead_of_add
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
docker:security:use_copy_instead_of_add [2020/04/18 19:37] – peter | docker:security:use_copy_instead_of_add [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
Arbitrary URLs specified for **ADD** could result in MITM attacks, or sources of malicious data. | Arbitrary URLs specified for **ADD** could result in MITM attacks, or sources of malicious data. | ||
- | In addition, **ADD** implicitly unpacks local archives which may not be expected and result in path traversal and Zip Slip vulnerabilities. | + | In addition, **ADD** implicitly unpacks local archives which may not be expected and result in path traversal and [[https:// |
Use **COPY**, unless **ADD** is specifically required. | Use **COPY**, unless **ADD** is specifically required. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Docker provides two commands for copying files from the host to the Docker image when building it: COPY and ADD. The instructions are similar in nature, but differ in their functionality: | ||
+ | |||
+ | * **COPY** — copies local files recursively, | ||
+ | * **ADD** — copies local files recursively, | ||
+ | |||
+ | While subtle, the differences between ADD and COPY are important. Be aware of these differences to avoid potential security issues: | ||
+ | |||
+ | * When remote URLs are used to download data directly into a source location, they could result in man-in-the-middle attacks that modify the content of the file being downloaded. Moreover, the origin and authenticity of remote URLs need to be further validated. When using COPY the source for the files to be downloaded from remote URLs should be declared over a secure TLS connection and their origins need to be validated as well. | ||
+ | * Space and image layer considerations: | ||
+ | * When local archives are used, ADD automatically extracts them to the destination directory. | ||
+ | |||
+ | |||
+ |
docker/security/use_copy_instead_of_add.1587238644.txt.gz · Last modified: 2020/07/15 09:30 (external edit)