Skip to content

update: check the tarball's member names before unpacking - #419

Open
sheduxdev wants to merge 1 commit into
libracoder:mainfrom
sheduxdev:update-archive-check
Open

sheduxdev wants to merge 1 commit into
libracoder:mainfrom
sheduxdev:update-archive-check

Conversation

@sheduxdev

Copy link
Copy Markdown

The update tarball is checked against the feed's SHA-256 and unpacked with
/usr/bin/tar before check() verifies the app. bsdtar refuses .. names,
extraction through symlinks, an escaping hard link, and strips a leading /,
so nothing landed outside the staging folder in practice (thanks for checking
that on 27.0/27.2.1). This makes the invariant explicit instead of leaving it
to tar's defaults, across versions and flags.

  • check_archive lists the tarball with the tar crate before extraction and
    refuses entries outside Kiri.app/, absolute or .. names, names beside
    the app (AppleDouble ._* aside), special files, and links whose target
    leaves the bundle.
  • /usr/bin/tar still does the unpacking, so the sparse disk template stays
    sparse; tar is added as a macOS-only dependency.
  • Tests: well-formed archive, escaping names, symlink and hard link targets,
    special files, missing app.

No behaviour change for a well-formed release archive.

Originally reported as an advisory and closed as not reproducible; splitting
the hardening out as suggested.

The update tarball is checked only against the feed's SHA-256 before
/usr/bin/tar unpacks it, and the app's signature only afterwards. bsdtar
refuses most dangerous members itself, but that leaves the "nothing
outside the staging folder" invariant to tar's defaults, across versions
and flags. List the archive with the tar crate first and refuse names
outside Kiri.app, absolute or .. names (AppleDouble files aside), special
files, and links whose target leaves the bundle. /usr/bin/tar still
unpacks, so the sparse disk template stays sparse.

Tests: a good archive, escaping names, escaping links (symlink and hard
link), and special files or a missing app.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant