Skip to content

container: make hostconfig.json non-world-readable (0600)#41620

Merged
thaJeztah merged 2 commits into
moby:masterfrom
thaJeztah:tighten_perms
May 6, 2021
Merged

container: make hostconfig.json non-world-readable (0600)#41620
thaJeztah merged 2 commits into
moby:masterfrom
thaJeztah:tighten_perms

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Nov 2, 2020

fixes #17310 "644 permissions for config.json and the like security issue" (together with #34419, which updated permissions for config.v2.json

When writing container's hostconfig.json, permissions were set to 0644 (world-readable). While this is not a security concern (as the /var/lib/docker/containers directory has 0700 or 0701 permissions), there is no need to have these permissions, as this file is only accessed by the daemon.

Looking at history for file permissions;

This patch updates the permissions to 0600, matching what's used for config.v2.json, which was updated in ae52cea, but forgot to update hostconfig.json.

The second commit is some small cleanup/refactoring

- Description for the changelog

- change permissions on container `hostconfig.json` files to `0600` (was `0644`)

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah
Copy link
Copy Markdown
Member Author

rebased to get a fresh run of CI

When writing container's `hostconfig.json`, permissions were set to 0644 (world-
readable). While this is not a security concern (as the `/var/lib/docker/containers`
directory has `0700` or `0701` permissions), there is no real need to have these
permissions, as this file is only accessed by the daemon.

Looking at history for file permissions;

- 06b53e3 (first implementation) used `0666` (world-writable)
- cf1a6c0 refactored the code, and removed explicit permissions
- ea3cbd3 introduced atomic writes, and brought back the `0666` permissions
- 3ec8fed removed world-writable bits, but kept world-readable

This patch updates the permissions to `0600`, matching what's used for `config.v2.json`,
which was updated in ae52cea, but forgot to update
`hostconfig.json`.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Copy Markdown
Member Author

@thaJeztah
Copy link
Copy Markdown
Member Author

ping @tonistiigi @justincormack @cpuguy83 PTAL

1 similar comment
@thaJeztah
Copy link
Copy Markdown
Member Author

ping @tonistiigi @justincormack @cpuguy83 PTAL

@thaJeztah
Copy link
Copy Markdown
Member Author

ping @tonistiigi @justincormack @cpuguy83 PTAL 🤗

@thaJeztah thaJeztah merged commit 56eb823 into moby:master May 6, 2021
@thaJeztah thaJeztah deleted the tighten_perms branch May 6, 2021 16:46
@thaJeztah thaJeztah added this to the 21.xx milestone May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

644 permissions for config.json and the like security issue

3 participants