Format:Snap package
| Magic | 68 73 71 73 (hsqs) at offset 0 |
|---|---|
| Extensions | .snap |
| License | GPL-3.0 (snapd) |
| On this wiki | Facts · Code · Notes · Topics |
The .snap package of Canonical's snapd: a plain SquashFS image (magic hsqs at offset 0) with the application tree and a meta/snap.yaml description; built by snapd with mksquashfs, xz compression by default.
Identification
snapd treats a file as a squashfs-format snap when its first bytes are the SquashFS magic h s q s (68 73 71 73); the check reads superblock size + 1 = 97 bytes and compares the first 4 (snap/squashfs/squashfs.go, FileHasSquashfsHeader, magic = []byte{'h','s','q','s'}). There is no snap-specific header: a .snap is a SquashFS (Format:SquashFS) and unsquashfs opens it. snap.Open also accepts a directory (snap try), recognized by the presence of meta/snap.yaml (snap/snapdir/snapdir.go).
Building
Snap.Build runs mksquashfs with -noappend and -comp <compression>; the default compression is xz when none is given, and -all-root -no-xattrs is added for some builds (squashfs.go, Build). snapd's source comments that a snap smaller than 16384 bytes can make some kernels log errors when scanning the loopback device (MinimumSnapSize).
What is inside
The squashfs root holds the application files and a meta/ directory: meta/snap.yaml (name, version, apps, plugs and slots), meta/hooks/ (hook programs, from the HooksDir paths in snap/info.go) and meta/gui/ (desktop files and icons). Unverified: the remaining layout (command wrappers, meta/snapcraft.yaml, snap/manifest.yaml) and how a store-signed assertion relates to the file; assertions are believed to be separate .assert files, not part of the image.
For the analyst
- Check bytes 0..3 for
hsqs; read the compression id at offset 20 (Format:SquashFS, 4 is XZ, the snapd default). unsquashfs -d out file.snap, then readmeta/snap.yamlfor thecommand:of each app.- The binaries are ELF (Format:ELF (Executable and Linkable Format)) in the snap tree, often linking against a base snap (core22 etc.) rather than the host: Unverified: the
base:key in snap.yaml names that runtime.
See Technique:Identifying Linux and macOS package containers.
Sources
canonical/snapd (GPL-3.0), snap/squashfs/squashfs.go, snap/snapfile/snapfile.go, snap/snapdir/snapdir.go, snap/info.go at commit 1c1dde3f64, read.
Code & repositories
- https://github.com/canonical/snapd @
1c1dde3f641ad9219905e50acde90a818b069307· license: GPL-3.0 (declared by the contributor; GitHub's detector did not recognize COPYING)
snapd: snap/squashfs (hsqs check, mksquashfs build), snapdir, info.go
Tested on: source read, not run · checked 2026-10-19