pkg/archive: adjust chmod bits on windows#11148
pkg/archive: adjust chmod bits on windows#11148tiborvass merged 1 commit intomoby:masterfrom ahmetb:win-cli/chmod-x-fix
Conversation
|
LGTM although I'm uncertain on what the best path might be for group/other bits |
There was a problem hiding this comment.
@ahmetalpbalkan could you please reference #11047 in a comment ?
This change modifies the chmod bits of build context archives built on windows to preserve the execute bit and remove the r/w bits from grp/others. Also adjusted integ-cli tests to verify permissions based on the platform the tests are running. Fixes #11047. Signed-off-by: Ahmet Alp Balkan <[email protected]>
|
LGTM |
Tests fixed on windows. |
There was a problem hiding this comment.
@ahmetalpbalkan is it 11 just in case the x bit is set for some magical reasons? :)
There was a problem hiding this comment.
@tiborvass I didn't want to clear the +x on grp/others. (e.g. in case of directories, I wanted to preserve the x bit)
There was a problem hiding this comment.
@tiborvass so direct answer to your question is, directory entries are also passed to this method and we already have x bit on those from os.Stat, we don't want to clear those bits.
There was a problem hiding this comment.
in archive_windows.go, should you be using os.PathSeparator rather than hard coding?
There was a problem hiding this comment.
@jhowardmsft i'm not sure which one you are referring to can you please comment on that line? Edit: corrected Siri dictation
|
@tianon re-LGTM maybe? |
|
LGTM |
|
I wonder whether we need docs to explain the "issue". |
|
@tiborvass hmm we don't have any windows docs at all at this point. I will create an issue now and you can assign that to me. |
pkg/archive: adjust chmod bits on windows
|
@tiborvass ❤️ 🍸 🎶 |
|
This is a bit overkill for windows as you have the default windows permissions now at "-rwx------" rather than the linux permissions of "-rw-r--r--". Having new files added to containers not be group/world readable is a big downside and probably not expected. I agree group/world writeable is not a good idea but removing all read permissions is probably too far. I would assume a 0755 would be a more appropriate mask override. In addition windows users can build tar archives with proper permissions (ie --owner 0 --mode 755) so it may be better rather than masking all permissions in windows to only look for the bad permission of 666 (default for tarred items for windows) and changing that to 755 or 644. I don't think this commit is also the cause of the ADD/COPY behavior change but I may be wrong. As now with Add doing similar doing an ADD then running as a restricted user will now fail if a chown is not done so: will fail with permission denied. (Also while the commit seems to primarily deal with archives I noticed the change to default file permissions above. |
|
@mitchcapper main reason we cleared the permissions from others/group is because people might assume they set the correct permissions on NTFS and those ACLs cannot be translated to unix formats. Assumption here was people are not very commonly using Feel free to come up with another proposal, I'd happily review but this is basically result of what we discussed in #11047. |
|
I 100% agree with you on the fact people are not commonly using USER, the problem is this is recommended practice from a security perspective. Running as root (even containered root priv dropped rooot) is probably a bad idea. Docker is fairly hard to run as non-user, which is a whole separate discussion, but I figured this behavior is only making it all the harder to run as a non-root user. I am not sure I agree with the private key aspect.
I missed the boat on the other proposal and realize the input is far after the fact, but figured I would comment my 2cents. I am all for security, and do a decent bit of work to run containers with least privs possible, but am not sure this will work to improve it (even at the cost of convenience). This masking I think will truly weaken good user behavior (as more dockerfiles just wont work as users other than root out of the box), in exchange for protecting bad user behavior (adding sensitive information into containers and expecting privacy by default). |
This change modifies the chmod bits of build context archives built on
windows to preserve the execute bit and remove the r/w bits from
grp/others.
I just created a post-processing step to modify tar headers retrieved from
tar.FileInfoHeader() method. This fixes tests:
Also adjusted integration-cli tests to verify permissions based on the platform
the tests are running. Fixes #11047.
Signed-off-by: Ahmet Alp Balkan [email protected]
cc: @duglin @tiborvass @icecrime @jfrazelle @tianon