Skip to content

test(apps): reject malicious, mismatched and colliding packages - #588

Merged
RentnerKev merged 4 commits into
mainfrom
rentner/test/package-rejection
Nov 26, 2026
Merged

RentnerKev merged 4 commits into
mainfrom
rentner/test/package-rejection

Conversation

@RentnerKev

Copy link
Copy Markdown
Member

Summary

These tests close the package-verification gaps that an acceptance audit of #452 found. Each test drives the real Installer staging, recovery and refresh paths. The fixture packages and TUF revisions are signed with the existing test keys.

No production code changes. The current code already refused every malicious, mismatched and colliding case below. The tests now prove that in Platform CI.

Tests and the #452 criteria they prove

The new unit tests are in core/tests/private/app_install/package_rejection.rs (module app_install::tests::package_rejection). The Rust job runs them as a regular user. It runs them again as root in the isolated container, through the existing app_install::tests:: filter in rust-coverage.sh.

Test Criterion What it proves
release_without_this_target_never_reaches_the_download_boundary 2 A signed release that ships only linux-arm64 is not listed on linux-amd64. Staging it fails before any download, and the archive and package stores stay empty.
packaged_manifest_must_match_the_signed_release 1, 2 Authentic signed bytes are refused when the packaged app.json uses another namespace (other.probe), version or target. No packages/<sha>, receipt or .stage-* workspace remains.
unsafe_archive_entries_are_refused_before_publication 3 ../x, /bin/app, a hard link, a symbolic link to a sentinel outside the store, a character device, a FIFO, a setuid executable, a group-writable file, a duplicate path, a case-variant duplicate path, 4,097 entries, and a 64 MiB + 1 file that arrives as a small compressed transfer are each refused with the validator's specific reason. Each case leaves the package store listing unchanged, with no packages/<sha>, receipt or workspace. The sentinel stays untouched. A valid control package from the same ustar builder is staged first.
catalogs_with_colliding_identities_are_not_accepted 5, 2, 8 A correctly signed catalog is refused when it has a release and a revocation of the same version, two releases of one version, two packages for one target, or an app outside its publisher namespace. The accepted checkpoint stays byte-for-byte unchanged. The same re-signing path then admits a valid catalog, so the refusals come from the content.
flipped_role_signatures_leave_the_accepted_catalog_unchanged 9, 8 One flipped hex digit in the targets, snapshot or timestamp signature fails the refresh as unauthorized. The hashes linking the roles stay consistent, so only the signature is wrong. The checkpoint is unchanged, and the unflipped revision is then accepted.
published_tree_without_a_receipt_must_match_its_archive 5, 1 A published package tree that lost its receipt and differs from the signed archive is neither trusted nor replaced. After its bytes are restored it is verified again and the receipt is rewritten.
republished_identity_cannot_replace_an_installed_package 5, 6 A divergent history, signed with the same online keys, publishes the installed version again with other bytes. Recovery and a pinned selection both fail with "Package identity differs from the signed catalog". The verified tree and its receipt stay as they were.
app_identity_writes_only_its_data_directory (root only) 4 Runs the boundary check below on a fixture package.
app_install::tests::greeting::privileged_signed_greeting_package (extended) 4 Runs the same boundary check on the real Greeting 1.1.0 package, in App Runtime Reference on native AMD64 and ARM64.

The boundary check (check_app_identity_boundaries) runs /bin/sh as the app UID:

  • The app identity can read and execute bin/app.
  • Each of these fails with Permission denied: appending to bin/app; creating, renaming or removing files in the package tree; writing to packages/, archives/, the catalog checkpoint or the store root.
  • Writing to its own data directory succeeds.
  • recover fails when bin/app is owned by the app UID, and when api (0775), api/openapi.json (0664) or bin/app (setuid) drift from their recorded mode. After the recorded owner and modes are restored, it succeeds again.

CI change

rust-coverage.sh now also runs app_manager::ui::package::tests:: in the root container. The five root-gated UI package tests, such as open_ui_files_are_bounded_and_do_not_follow_links, used to return early in the regular run and matched no root filter, so they never ran as root. They pass as root.

Finding for a follow-up decision

The catalog reader authenticates the TUF chain and rejects rollback, but it does not compare releases across revisions. Only the publisher's update_catalog refuses to change a published release without a revocation, or to drop a revocation. republished_identity_cannot_replace_an_installed_package pins the protection that exists today: installations stay bound to their recorded archive and manifest digests.

Whether the Platform reader should also refuse such revisions is left open. Deciding that needs a review of the app-catalog history for earlier record changes.

Verification

  • cargo fmt --check and cargo clippy --locked --all-targets --all-features -- -D warnings pass on Linux (Kiri, Rust 1.99.1). bun --no-env-file fmt --check .github passes.
  • The 8 new tests pass as an unprivileged user.
  • app_install::tests:: and app_manager::ui::package::tests:: (41 tests) pass as root in a container with the CI capability set, a read-only root filesystem and the CI tmpfs mounts.
  • The extended Greeting test needs the built Greeting packages, so it runs only in App Runtime Reference.

Refs #452

🤖 Generated with Claude Code

Prove the #452 package boundary through the real installer paths:

- Refuse releases without this target before any download, and packaged
  manifests whose namespace, version or target differ from the signed
  release.
- Refuse traversal, absolute paths, links, devices, FIFOs, privileged and
  writable modes, duplicate and case-variant paths, too many entries and
  an oversized expanded file without publishing a package or workspace.
- Refuse signed catalogs with colliding identities or targets and flipped
  role signatures while the accepted checkpoint stays unchanged.
- Keep a receipt-less colliding tree and a republished identity from
  replacing a verified installation.
- Check as the app UID that only the data directory is writable, and that
  owner or mode drift in a staged package blocks recovery, in a root unit
  test and in the Greeting package test.

Run the root-gated UI package tests in the privileged coverage container.

Refs #452

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b754ad7 and f170a58.

Files selected for processing: 4

  • .github/scripts/ci/rust-coverage.sh
  • core/tests/private/app_install.rs
  • core/tests/private/app_install/greeting.rs
  • core/tests/private/app_install/package_rejection.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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