`organize:{ /: another-dir/ }` causes the items under host root directory to be copied in another-dir
Metadata
Current evaluation
organize: { /: ... } incorrectly copied host root directory contents into the part install directory. Fixed in craft-parts via PR #1562.
Resolution: closed resolved
Reason: Closed by maintainer comment referencing canonical/craft-parts#1562, which corrected the organize stanza logic to prevent unintended host filesystem traversal.
Evaluated by: mr-cal-bot
No scores available.
Issue body
Consider the following `parts` recipe:
```yaml
patches:
source: snap/patches
plugin: dump
organize:
/: patches/
override-prime: 'true'
```
Here's the content under snap/patches:
```
snap/patches
└── enchant-fix-build.patch
0 directories, 1 file
```
One may expect that the `organize` stanza will make snapcraft move enchant-fix-build.patch to $SNAPCRAFT_STAGE/patches/enchant-fix-build.patch, but when running the build step of `patches` part, the content of $SNAPCRAFT_PART_INSTALL becomes:
```
parts/patches/install/
├── enchant-fix-build.patch
└── patches
├── bin
│ ├── bash
│ ├── btrfs
│ ├── btrfs-calc-size
│ ├── btrfsck -> btrfs
│ ├── btrfs-convert
│ ├── btrfs-debug-tree
│ ├── btrfs-find-root
│ ├── btrfs-image
│ ├── btrfs-map-logical
│ ├── btrfs-select-super
│ ├── btrfs-show-super
│ ├── btrfstune
│ ├── btrfs-zero-log
│ ├── bunzip2
│ ├── busybox
│ ├── bzcat
│ ├── bzcmp -> bzdiff
│ ├── bzdiff
│ ├── bzegrep -> bzgrep
│ ├── bzexe
│ ├── bzfgrep -> bzgrep
│ ├── bzgrep
│ ├── bzip2
│ ├── bzip2recover
│ ├── bzless -> bzmore
│ ├── bzmore
│ ├── cat
│ ├── chacl
│ ├── chgrp
│ ├── chmod
│ ├── chown
│ ├── chvt
│ ├── cp
│ ├── cpio
│ ├── dash
│ ├── date
│ ├── dd
│ ├── df
│ ├── dir
│ ├── dmesg
│ ├── dnsdomainname -> hostname
│ ├── domainname -> hostname
│ ├── dumpkeys
│ ├── echo
│ ├── ed
│ ├── egrep
│ ├── false
│ ├── fgconsole
│ ├── fgrep
│ ├── findmnt
│ ├── fsck.btrfs
│ ├── fuser
│ ├── fusermount
│ ├── getfacl
│ ├── grep
│ ├── gunzip
│ ├── gzexe
│ ├── gzip
│ ├── hostname
│ ├── ip
│ ├── journalctl
│ ├── kbd_mode
│ ├── kill
│ ├── kmod
│ ├── less
│ ├── lessecho
│ ├── lessfile -> lesspipe
│ ├── lesskey
│ ├── lesspipe
│ ├── ln
│ ├── loadkeys
│ ├── login
│ ├── loginctl
│ ├── lowntfs-3g
│ ├── ls
│ ├── lsblk
│ ├── lsmod -> kmod
│ ├── mkdir
│ ├── mkfs.btrfs
│ ├── mknod
│ ├── mktemp
│ ├── more
│ ├── mount
│ ├── mountpoint
│ ├── mt -> /etc/alternatives/mt
│ ├── mt-gnu
│ ├── mv
│ ├── nano
│ ├── nc -> /etc/alternatives/nc
│ ├── nc.openbsd
│ ├── netcat -> /etc/alternatives/netcat
│ ├── netstat
│ ├── networkctl
│ ├── nisdomainname -> hostname
│ ├── ntfs-3g
│ ├── ntfs-3g.probe
│ ├── ntfs-3g.secaudit
│ ├── ntfs-3g.usermap
│ ├── ntfscat
│ ├── ntfscluster
│ ├── ntfscmp
│ ├── ntfsfallocate
│ ├── ntfsfix
│ ├── ntfsinfo
│ ├── ntfsls
│ ├── ntfsmove
│ ├── ntfstruncate
│ ├── ntfswipe
│ ├── open -> openvt
│ ├── openvt
│ ├── pidof -> /sbin/killall5
│ ├── ping
│ ├── ping6
│ ├── plymouth
│ ├── ps
│ ├── pwd
│ ├── rbash -> bash
│ ├── readlink
│ ├── red
│ ├── rm
│ ├── rmdir
│ ├── rnano -> nano
│ ├── run-parts
│ ├── sed
│ ├── setfacl
│ ├── setfont
│ ├── setupcon
│ ├── sh -> dash
│ ├── sh.distrib -> dash
│ ├── sleep
│ ├── ss
│ ├── static-sh -> busybox
│ ├── stty
│ ├── su
│ ├── sync
│ ├── systemctl
│ ├── systemd -> /lib/systemd/systemd
│ ├── systemd-ask-password
│ ├── systemd-escape
│ ├── systemd-hwdb
│ ├── systemd-inhibit
│ ├── systemd-machine-id-setup
│ ├── systemd-notify
│ ├── systemd-tmpfiles
│ ├── systemd-tty-ask-password-agent
│ ├── tailf
│ ├── tar
│ ├── tempfile
│ ├── touch
│ ├── true
│ ├── udevadm
│ ├── ulockmgr_server
│ ├── umount
│ ├── uname
│ ├── uncompress
│ ├── unicode_start
│ ├── vdir
│ ├── wdctl
│ ├── which
│ ├── whiptail
│ ├── ypdomainname -> hostname
│ ├── zcat
│ ├── zcmp
│ ├── zdiff
│ ├── zegrep
│ ├── zfgrep
│ ├── zforce
│ ├── zgrep
│ ├── zless
│ ├── zmore
│ └── znew
├── boot
│ └── grub
│ ├── default
│ ├── grub.cfg
│ ├── menu.lst
│ ├── menu.lst~
│ ├── menu.lst_backup_by_grub2_prerm
│ └── unicode.pf2
├── dev
│ ├── core -> /proc/kcore
│ ├── hugepages
│ ├── lxd
│ ├── mqueue
│ ├── net
│ ├── null
│ ├── pts
│ ├── shm
│ ├── stderr -> /proc/self/fd/2
│ ├── stdout -> /proc/self/fd/1
│ ├── tty
│ └── urandom
├── etc
├── home
├── lib
├── lib64
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
27 directories, 184 files
```
It seems that the content from the build host's root directory is somehow copied to $SNAPCRAFT_PART_INSTALL, which seems to conflict with the description of `organize` stanza:
Note that the path is relative (even though it is "usr/local") because
it refers to content underneath parts/<part-name>/install which is going
to be mapped into the stage and prime areas.
I suspect that this behavior is either a bug in snapcraft or my misunderstanding of `organize`, any ideas?
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | closed resolved | organize: { /: ... } incorrectly copied host root directory contents into the part install directory. Fixed in craft-parts via PR #1562. | |
| stealth/space-bunny-alpha |
Impact:
58
Quick Win:
31
Complexity:
42
Confidence:
94
Actionability:
92
|
close resolved | A dump part using organize {'/': 'patches/'} copied the host root into the part; later craft-parts fixes anchor organize sources to part install directories. | |
| stealth/space-bunny-alpha |
Impact:
55
Quick Win:
37
Complexity:
25
Confidence:
96
Actionability:
90
|
close resolved | A root-only organize key escaped the part install directory and copied the build host's root tree; snapcraft#2034 fixed leading-slash organization handling. | |
| stealth/space-bunny-alpha |
Impact:
42
Quick Win:
31
Complexity:
20
Confidence:
90
Actionability:
93
|
close resolved | An organize rule using `/` escaped the part install tree and copied host-root content. The reproducer is complete, and craft-parts commit c349e740 later fixed organization to use each part's install directories. | |
| stealth/space-bunny-alpha |
Impact:
63
Quick Win:
44
Complexity:
22
Confidence:
91
Actionability:
90
|
close resolved | Reported organize:/ escaping the part install tree and copying host root content. craft-parts commit c349e740 later fixed organize to use each part's install directories. | |
| qwen/qwen3.8-27b |
Impact:
30
Quick Win:
14
Staleness:
92
Complexity:
55
Confidence:
55
Support Request:
20
|
needs triage | Bug report (8+ years old, 0 comments, no labels) that `organize: /: patches/` copies the build host's root directory contents into the part install dir instead of just the patch file. Organize logic since rewritten in craft-parts; never triaged by a maintainer. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
98
Complexity:
60
Confidence:
85
Support Request:
10
|
close stale | Snapcraft organize directive incorrectly copies host root directory contents into part install directory. Unassessed, 8 years old, zero activity. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
95
Complexity:
40
Confidence:
85
Support Request:
10
|
close stale | Snapcraft organize stanza unexpectedly copies host root directory contents into the part install directory. Unlabeled, zero comments, inactive for over 8 years. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
95
Complexity:
45
Confidence:
85
Support Request:
10
|
close stale | organize stanza with /: pattern unexpectedly copies host root directory contents into the part install directory. Issue is 8 years old with no maintainer response, labels, or activity. |
Update history
| Date | Change |
|---|---|
| closed | |
| created |
Related work
-
Likely Fixed By:
canonical/craft-parts#1562
(confidence 100%)
PR explicitly cited as the fix for this issue.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #689 fix(organize): use the part's install directories | craft-parts | merged | Merged craft-parts#689: organize_files now receives each part's install directories instead of recreating relative paths, ensuring organization uses base_dir rather than cwd. |