File permissions leak through to built snap
Metadata
Current evaluation
A restrictive host umask can preserve inaccessible source modes in built snaps, reproducing an OpenStack runtime PermissionError; the report remains untriaged and unresolved.
Suggested action: needs triage
Reason: The report provides exact umasks, source and target paths, resulting 0750 modes, and a runtime PermissionError, while current Snapcraft code contains no umask normalization and still uses shutil.copy, which preserves source modes. However, the issue has no labels or maintainer response, and its only comment is an automated CRAFT-2614 ticket notice, so prioritization and the intended permission policy still need maintainer assessment.
Evaluated by: mr-cal-bot
Impact:
58
Quick Win:
24
Complexity:
52
Confidence:
84
Actionability:
87
Issue body
### Bug Description
Permissions of source files on the host machine can leak through the snapcraft build process and end up in the built snap. This means that file permissions can be unexpectedly incorrect in the final snap.
Source file permissions can easily be different if the host machine's umask is customised.
This is a bug because it it's unexpected and undermines the ideal of snapcraft consistently building a snap in an isolated build environment.
Permissions being unexpectedly incorrect in the resulting snap can result in unexpected permission-related errors, such as this for the openstack snap:
```
$ openstack.sunbeam -v cluster bootstrap
...
PermissionError: [Errno 13] Permission denied: '/snap/openstack/x1/etc/deploy-sunbeam-machine'
WARNING An unexpected error has occurred. Please run 'sunbeam inspect' to generate an inspection report. utils.py:290
ERROR Error: [Errno 13] Permission denied: '/snap/openstack/x1/etc/deploy-sunbeam-machine' utils.py:291
```
### To Reproduce
On a workstation, set a more restrictive umask than the default, clone a snap repository that has files it copies to the snap (files that need to be readable by a non-root user), and build the snap. Then on another machine, install the snap (this is to show the bug lies in the snapcraft build process, not in the installation process).
```
# workstation
$ umask 027
$ git clone https://github.com/canonical/snap-openstack
Cloning into 'snap-openstack'...
remote: Enumerating objects: 5943, done.
remote: Counting objects: 100% (5943/5943), done.
remote: Compressing objects: 100% (1673/1673), done.
remote: Total 5943 (delta 4154), reused 5864 (delta 4103), pack-reused 0
Receiving objects: 100% (5943/5943), 1.44 MiB | 1.15 MiB/s, done.
Resolving deltas: 100% (4154/4154), done.
$ stat cloud/etc/deploy-sunbeam-machine
File: cloud/etc/deploy-sunbeam-machine
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 252,1 Inode: 21245537 Links: 2
Access: (0750/drwxr-x---) Uid: ( 1000/ ubuntu) Gid: ( 1000/ ubuntu)
Access: 2024-03-13 10:10:05.547611390 +1030
Modify: 2024-03-13 10:09:50.526825834 +1030
Change: 2024-03-13 10:09:50.526825834 +1030
Birth: 2024-03-13 10:09:50.526825834 +1030
$ snapcraft
Generated snap metadata
Created snap package openstack_2023.2_amd64.snap
$ rsync -av openstack_2023.2_amd64.snap serverstack-sunbeam-0:
sending incremental file list
openstack_2023.2_amd64.snap
sent 137,536,414 bytes received 35 bytes 1,211,774.88 bytes/sec
total size is 137,502,720 speedup is 1.00
# target machine
ubuntu@serverstack-sunbeam-0:~$ sudo snap install --dangerous ./openstack_2023.2_amd64.snap
openstack 2023.2 installed
ubuntu@serverstack-sunbeam-0:~$ stat /snap/openstack/x1/etc/deploy-sunbeam-machine/
File: /snap/openstack/x1/etc/deploy-sunbeam-machine/
Size: 77 Blocks: 0 IO Block: 1024 directory
Device: 704h/1796d Inode: 139 Links: 2
Access: (0750/drwxr-x---) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2024-03-12 23:50:19.000000000 +0000
Modify: 2024-03-12 23:50:19.000000000 +0000
Change: 2024-03-12 23:50:19.000000000 +0000
Birth: -
ubuntu@serverstack-sunbeam-0:~$ ls /snap/openstack/x1/etc/deploy-sunbeam-machine/
ls: cannot open directory '/snap/openstack/x1/etc/deploy-sunbeam-machine/': Permission denied
```
Note that the file permissions for etc/deploy-sunbeam-machine have passed through from the host machine. That directory is inaccessible to a non-root user (eg. the default ubuntu user).
Compare with repeating the above with the default umask on Ubuntu:
```
# workstation
$ umask 002
$ git clone https://github.com/canonical/snap-openstack
Cloning into 'snap-openstack'...
remote: Enumerating objects: 5943, done.
remote: Counting objects: 100% (5943/5943), done.
remote: Compressing objects: 100% (1673/1673), done.
remote: Total 5943 (delta 4154), reused 5864 (delta 4103), pack-reused 0
Receiving objects: 100% (5943/5943), 1.44 MiB | 1.29 MiB/s, done.
Resolving deltas: 100% (4154/4154), done.
$ stat cloud/etc/deploy-sunbeam-machine
File: cloud/etc/deploy-sunbeam-machine
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 252,1 Inode: 21245537 Links: 2
Access: (0775/drwxrwxr-x) Uid: ( 1000/ ubuntu) Gid: ( 1000/ ubuntu)
Access: 2024-03-13 10:29:16.866583966 +1030
Modify: 2024-03-13 10:29:16.866583966 +1030
Change: 2024-03-13 10:29:16.866583966 +1030
Birth: 2024-03-13 10:29:16.866583966 +1030
$ snapcraft
Generated snap metadata
Created snap package openstack_2023.2_amd64.snap
$ rsync -av openstack_2023.2_amd64.snap serverstack-sunbeam-0:
sending incremental file list
openstack_2023.2_amd64.snap
sent 37,797,351 bytes received 82,170 bytes 1,097,957.13 bytes/sec
total size is 137,502,720 speedup is 3.63
# target machine
ubuntu@serverstack-sunbeam-0:~$ sudo snap install --dangerous ./openstack_2023.2_amd64.snap
openstack 2023.2 installed
ubuntu@serverstack-sunbeam-0:~$ stat /snap/openstack/x1/etc/deploy-sunbeam-machine/
File: /snap/openstack/x1/etc/deploy-sunbeam-machine/
Size: 77 Blocks: 0 IO Block: 1024 directory
Device: 706h/1798d Inode: 139 Links: 2
Access: (0775/drwxrwxr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2024-03-13 00:10:45.000000000 +0000
Modify: 2024-03-13 00:10:45.000000000 +0000
Change: 2024-03-13 00:10:45.000000000 +0000
Birth: -
ubuntu@serverstack-sunbeam-0:~$ ls /snap/openstack/x1/etc/deploy-sunbeam-machine/
main.tf variables.tf
```
Also compare with installing from the snap store:
```
ubuntu@serverstack-sunbeam-0:~$ sudo snap install openstack --channel 2023.2/edge
openstack (2023.2/edge) 2023.2 from Canonical✓ installed
ubuntu@serverstack-sunbeam-0:~$ stat /snap/openstack/437/etc/deploy-sunbeam-machine/
File: /snap/openstack/437/etc/deploy-sunbeam-machine/
Size: 77 Blocks: 0 IO Block: 1024 directory
Device: 704h/1796d Inode: 139 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2024-03-11 08:54:40.000000000 +0000
Modify: 2024-03-11 08:54:40.000000000 +0000
Change: 2024-03-11 08:54:40.000000000 +0000
Birth: -
ubuntu@serverstack-sunbeam-0:~$ ls /snap/openstack/437/etc/deploy-sunbeam-machine/
main.tf variables.tf
```
### Environment
NA
### snapcraft.yaml
```shell
NA
```
### Relevant log output
```shell
NA
```
### Additional context
_No response_
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha |
Impact:
58
Quick Win:
24
Complexity:
52
Confidence:
84
Actionability:
87
|
needs triage | A restrictive host umask can preserve inaccessible source modes in built snaps, reproducing an OpenStack runtime PermissionError; the report remains untriaged and unresolved. | |
| qwen/qwen3.6-35b-a3b |
Impact:
70
Quick Win:
34
Complexity:
40
Confidence:
70
Actionability:
80
|
needs triage | File permissions from host machine's umask leak into built snaps, causing permission errors at runtime | |
| qwen/qwen3.8-27b |
Impact:
50
Quick Win:
22
Staleness:
72
Complexity:
55
Confidence:
62
Support Request:
5
|
needs triage | Host umask leaks into built snap file permissions, causing permission errors at runtime. Reported March 2024 with detailed repro; only a Jira-sync bot comment, no maintainer response or labels in ~1.5 years. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
85
Complexity:
20
Confidence:
70
Support Request:
0
|
needs triage | File permissions from the host machine's umask leak into the built snap, causing permission errors. The issue is unlabelled and has had no maintainer interaction for over two years. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
92
Complexity:
40
Confidence:
85
Support Request:
10
|
close stale | Host file permissions leak into built snaps when custom umask is used, causing runtime permission errors. Reported March 2024, synced to internal Jira, but remains open with no maintainer response or fix. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1515394 Restrictive umask and permissions may cause a built snap to be unusable | snapcraft (launchpad) | closed | Closed by maintainer in Jan 2019 as a non-issue for the general case, since consistent build environments make a restrictive host umask irrelevant; no snapcraft code changes made. |