We are asked to design a universal binary packaging format supporting hermetic dependencies. The prompt asks for: metadata schema, runtime sandboxes, update ecosystem, and signing policy. This is an open-ended design question. As ChatGPT, we need to produce a comprehensive answer that covers all these aspects. We should think about what is meant by "universal binary packaging format". This likely refers to a format that can package an application along with all its dependencies, ensuring hermetic (isolated, reproducible) builds and executions. Something like container images, but perhaps more focused on binaries and dependencies at the OS level? Possibly a packaging format that can be used across different operating systems? The term "universal" might imply cross-platform, but that could be challenging. Alternatively, it could be a format that is independent of the host OS, like a tarball with a manifest, that can be installed on any system with a compatible runtime. We might be designing something akin to Flatpak, Snap, AppImage, or even Docker images, but with a focus on hermetic dependencies and universal support. We need to define metadata schema (what information is stored about the package, its dependencies, etc.), runtime sandboxes (how the package runs in an isolated environment, perhaps using seccomp, namespaces, capabilities, etc.), update ecosystem (how packages are distributed, updated, versioned, with rollbacks, delta updates, etc.), and signing policy (how packages are signed for authenticity, key management, revocation, etc.). We should present a design that is coherent, secure, and practical.
Let's break down each part.
1. Metadata Schema:
We need to define the structure of the package's metadata. It should include:
Dependencies: possibly other packages or system libraries? For hermetic dependencies, we want to bundle all non-OS dependencies. So the format should allow specifying external dependencies that are either provided by the host (like kernel, glibc?) or bundled. The metadata should specify the required runtime environment (e.g., minimum kernel version, CPU features, etc.).
Entry point: the main executable or command.
File list: the files included in the package, with paths, permissions, etc.
Maybe a manifest of dependencies (like a hash tree of included libraries) to ensure integrity.
Possibly a sandbox configuration: required capabilities, filesystem access, network access, etc.
Signatures: cryptographic signatures of the metadata and possibly the whole package.
Optional: scripts for pre/post install? But for hermetic, maybe we avoid host scripts; instead, everything is inside the package and runs in sandbox.
A schema format (like JSON, protobuf, etc.) with versioning.
We can define a "Package Manifest" as a machine-readable file (e.g., manifest.json) that describes the package. Then we might have an "image" that is a tar archive containing the manifest and the payload (files). The manifest could be signed separately or be part of a signed envelope.
2. Runtime Sandboxes:
When running the package, we need to isolate it from the host system to ensure hermetic execution. We can use OS-level sandboxing:Linux namespaces (pid, net, mount, uts, ipc), cgroups for resource limits, seccomp for syscall filtering, and capabilities dropping. On other OSes, we might need similar mechanisms. We could also use a container runtime like runc, or a higher-level solution. We need to define what the default sandbox is and how the package can request additional privileges (maybe via manifest entries). For example, network access might be blocked by default, but the package can request "network" which then allows it. Or we might have a policy that the user can adjust at install/run time. We could also use mandatory access control (AppArmor, SELinux) policies defined in the package.
We should think about hermetic dependencies: the package includes all its libraries, but the runtime may still need access to certain system resources (like /dev, /proc). We can mount a minimal root filesystem from the package, but we also need to share some host paths (e.g., /dev, /sys) maybe read-only. We should define a standard rootfs layout: the package provides a directory structure that will be the root of the sandbox. The runtime will mount it as the root filesystem (maybe with overlayfs for writable parts like /tmp). It may also bind-mount necessary host resources (like /dev/null, /dev/urandom) as needed. The package should declare which host resources it needs, and the runtime enforces it.
Alternatively, we could have a more lightweight approach: the package is just a binary and a set of libraries, and we run it with LD_LIBRARY_PATH set and a chroot. But that's not as secure; we need proper sandbox. However, for universal, we might rely on platform-specific sandbox APIs (e.g., Windows jobs, macOS sandbox-exec). Perhaps we define an abstract sandbox model and have implementations per OS.
3. Update Ecosystem:
We need a system for distributing packages, checking for updates, handling versioning, dependencies, and rollbacks. This could be a repository (like apt, yum, npm) but with support for atomic updates and delta downloads. We might design a client-side tool that manages packages: install, uninstall, update. The repository would host package files (maybe split into base and delta patches). The client would check for updates by querying the repository's metadata (like an index). The update should be atomic: either fully applied or not, to avoid corruption. We might use a two-stage installation: download new package, verify, then switch to it. For rollback, keep previous version until new one is verified. Also, handle dependencies: if a package depends on another, updating one might require updating the other. The ecosystem could include a central registry of packages and dependency resolution.
We also need to think about updates in a hermetic context: the entire package is self-contained, so updating means replacing the whole package (or applying a delta that updates the whole). Dependencies between packages might be limited to runtime libraries that are shared? But hermetic suggests each package brings its own dependencies, so maybe packages are independent and do not depend on each other? But still they might have inter-package dependencies for plugins or shared data. We could allow packages to depend on other packages (like shared runtimes) that are also installed. The update system would need to consider those dependencies to avoid breaking packages.
4. Signing Policy:
We need to ensure packages are authentic and have not been tampered with. Use cryptographic signatures: each package should be signed by the maintainer (or publisher). The format should include a signature block (e.g., using PKCS#7, PGP, or a custom scheme). The manifest can be signed, and the payload can be hashed and included in the signature. We also need key management: a way to trust public keys. Possibly a web of trust or a central authority that distributes trusted keys. Or we could have a policy that any package signed with a key that is in the user's trust store is accepted. The signing policy should cover the whole package: the manifest and the payload must be signed as a unit. We should also support multiple signatures (e.g., by different entities). There should be a way to revoke keys and check revocation.
We may also need to consider reproducibility: the build process should be deterministic so that the same source yields the same binary, making signatures more meaningful.
Now we need to integrate these into a cohesive design. Let's propose a name: "Universal Hermetic Package" (UHP). Or something like "Hermetic Binary Format" (HBF). We'll define a file extension: .uhp or .hbf.
We can structure the package as a tar archive (or a more efficient container format like squasfs? But for simplicity, tar.gz). Inside:
A manifest file at the root: manifest.json
A payload directory: payload/ containing the files that will become the rootfs when installed (or run).
Optionally, a signature file: signature.p7s (detached) or embedded in manifest.
Alternatively, we could use a single file that contains manifest and payload with a clear separation, like a self-extracting archive with a signature at the end.
We'll design the manifest schema as JSON (or JSON Schema). We'll have fields:
But we need to decide which fields are required. Also, the sandbox configuration can be more detailed: it could define allowed system calls, network access, etc.
We should also define a "runtime manifest" that describes the environment variables, etc.
Maybe we can have a separate file for the sandbox profile (like a seccomp filter) and reference it in the manifest.
Now, for runtime sandbox: we need a runtime component that can interpret the manifest and launch the application. This runtime, say "uhp-runtime", will be installed on the host system. It will read the manifest, set up a new mount namespace, pivot_root to the payload (which might be extracted to a directory), set up network namespace, apply seccomp filters, drop privileges, and then exec the entrypoint. The runtime also might handle resource limits (cgroups) and MAC policies (AppArmor/SELinux profiles). The manifest can specify required capabilities: e.g., "CAP_NET_RAW" for raw sockets. The runtime will check if the user has allowed those (maybe via policy or prompts). Also, sandbox configuration can be provided by the packager and can be overridden by user policy.
For universal support, the runtime must be available on multiple OSes. On Linux, we use namespaces/ seccomp. On macOS, we could use sandbox-exec and seatbelt profiles? But we need a common model. Possibly we define a minimal required sandbox that can be implemented on all: use a chroot, setuid, and seccomp on Linux; on Windows, use job objects and restricted tokens. But that's complex. Perhaps we focus on Linux first, and note that other OSes would need their own runtime implementations that respect the manifest. Or we define an abstract "sandbox" language that can be compiled to native sandbox mechanisms.
For update ecosystem: we need a repository format. The repository could be a simple HTTP server with an index file (JSON) listing available packages and their versions, along with hashes and signatures. The client tool ("uhp-manager") can add repositories, then query them. When installing, it downloads the package (maybe a compressed archive), verifies the signature (using trusted keys stored locally), then extracts the payload to a location (like /var/lib/uhp/packages/-). It registers the package in a database. Running the app through the runtime looks up the package path and uses the manifest.
Updates: the client checks the index for newer versions. It can download full packages or delta packages (generated using bsdiff or similar). The delta update must be applied to the existing payload to produce the new payload, then verified. We need to ensure atomicity: maybe keep two versions and switch a symlink. Also, we need to support rollback: keep old version for some time.
Dependencies: if a package depends on another package, the client must resolve dependencies from the repositories. Dependencies can be version constraints. The package can also declare "bundled" dependencies that are included within its own payload, thus not requiring separate packages. So dependencies could be external packages that are installed separately. For hermeticity, we want to minimize external dependencies, but some system components (like kernel, libc) cannot be bundled. So we need to declare those as requirements and possibly provide a compatibility list: the package might require a minimum glibc version. The runtime could check the host's glibc against that. Or we could bundle a libc if static linking is possible. However, glibc is tricky because of NSS and locales. But maybe we allow bundling a minimal libc through something like musl? But we might rely on the host's libc. The design should state that the package must be built against a baseline of system libraries that are considered part of the runtime (e.g., Linux Standard Base). Or we could have a base runtime package (like a "system" package) that provides essential libraries, and all packages depend on it. That base would be installed once per OS.
Signing policy: each package is signed by one or more keys. The manifest includes signatures over the manifest itself (including the file digests). The payload is not separately signed; its integrity is ensured by the digests in the manifest, which is signed. So tampering with any file would be detected because its digest would mismatch. The signature covers the manifest and all digests. So we need a canonical representation of the manifest (e.g., sorted JSON, or binary encoding) to sign. We can use a detached signature file: the manifest is a JSON file, and a separate .sig file signature over it. Or we can embed signatures as a field. The client will verify that the manifest's signature is valid and from a trusted key. We can have a trust store of public keys (like /etc/uhp/trusted-keys). The user can add keys. Alternatively, we could have an "authority" model where packages are signed by maintainers, and the user decides which maintainers to trust.
We should also consider key revocation via CRL or OCSP, but perhaps out of scope.
Now, we need to produce an answer that clearly explains each part. We'll structure: Introduction, then sections for Metadata Schema, Runtime Sandboxes, Update Ecosystem, Signing Policy. We'll include details like file format, fields, implementation notes. We'll try to be comprehensive but concise.
We should also discuss how hermetic dependencies are achieved: by bundling all application-specific libraries, and isolating from host. The sandbox prevents access to host resources unless explicitly allowed.
We'll also address the "universal" aspect: the package format should be OS-agnostic; it's just an archive with a manifest. The runtime provides OS-specific sandboxing. So the same package can be used on different OSes if the runtime is available and the binaries are compatible (i.e., if it's for the same architecture and OS type). But the binary itself may be compiled for Linux x86_64; it won't run on Windows. So "universal" might mean it works across Linux distributions? Or across any OS that supports the runtime? Probably the latter: the package contains the binary and dependencies for a specific OS/arch combo. The manifest would indicate the supported OSes and architectures. The runtime on a given host would only accept packages matching its OS/arch. So the format is universal in the sense that it's a single specification that can be implemented on multiple OSes, but packages are still OS-specific. We could also include multiple binaries in one package for different OSes? Possibly, but that complicates. Simpler: one package per OS/arch.
We might allow the payload to contain a directory structure that matches the filesystem layout: e.g., /usr/bin, /usr/lib, etc. That's typical.
Now, we need to present the design. Let's outline:
Metadata Schema:
Package Manifest: defined in JSON, with required fields as above.
The manifest must include a unique identifier (maybe a UUID or name+version+arch).
It must list all files in the payload with their relative paths, modes, and digests (to ensure integrity). This allows verification without extracting.
Dependencies: external packages that are required. Each dependency has name, version constraint, and provider (system or packaged). If provider is "system", it means it's expected to be present on the host (e.g., glibc). If provider is "packaged", it means it should be another package installed via the system.
Also, the manifest should specify the minimum required host kernel version and any required CPU features (e.g., "sse4.2"). That's necessary for compatibility.
OS and architecture fields: free-form strings; we can use typical triplet like "linux-x86_64".
Sandbox: includes configuration for the runtime: what directories to mount read-only, what devices to expose, network mode (none, host, etc.), and a seccomp filter (can be a base64-encoded binary blob). Also may specify environment variables.
Entrypoint: either an executable file within the payload, or a command to launch (if the package is a script). We should also support specifying arguments.
Update: metadata to assist updates: e.g., delta from previous version, release notes URL, etc. Not strictly needed but useful.
Signatures: array of signatures. Each signature includes key identifier, algorithm, and value. The manifest should be signed over its canonical form (maybe we define that the signatures are computed on the manifest with the signatures array empty? Or better, we exclude the signatures when hashing). The canonical form could be the JSON after sorting keys and removing whitespace, but for deterministic signing we may need a binary format (like protobuf) that has canonical encoding. Simpler: we say that the manifest must be in a canonical form (e.g., minified JSON with sorted keys) and the signature is computed over the UTF-8 bytes of that form. The signatures array is not included in the signed data; instead, the signature covers the manifest without signatures. The signature value is stored in the array. When verifying, we check that the signature is valid over the manifest (excluding the signatures array) and that the key matches.
Alternatively, we could use a separate detached signature file. That's simpler for implementation but requires an extra file. We can say that a package is a tarball containing manifest.json and payload/. The signature can be a separate file .sig alongside the tarball, or embedded. I'd propose a single file format: The package file is a concatenation of the manifest (json), then a zero byte, then the payload (tar). Or we could use a standard container format like OCI image layers but simpler. Maybe use a "universal package" format: a zip file? But zip may not store Unix permissions well. Tar is fine. So we can have a tar archive with two top-level entries: "manifest.json" and "payload/". Then we also have "signature" entry (detached) but we can also put it in manifest. However, the signature of the manifest can be included as a field, and that signature is computed over the manifest without that field. This is a bit subtle; but it's common (like JSON Web Signature). We could also use a separate manifest.signature file: the package includes manifest.json and manifest.json.sig. The signature is over the manifest.json. That's simpler. Then we have a separate file for the payload? But the payload is huge; we don't want to hash the whole payload each time? Actually, we want to include digests of each file in the manifest, so that the payload integrity is covered by the manifest's digest list. So we can compute digests of payload files and include them in manifest.json. Then we sign the manifest.json. So the signature file is derived from manifest.json. So the package could be a tar of manifest.json, manifest.json.sig, and payload/. Or we could have a single .uhp file that is just the tar. The installer expects manifest.json and its .sig. Or the manifest can contain the signatures as a field, and we compute signature over a canonical representation of manifest with that field removed. Either way is fine.
We'll go with separate file: The package archive contains:
manifest.json
manifest.json.sig (or signature.p7s)
payload/ (directory with all files)
This is intuitive.
Runtime Sandboxes:
The runtime is a host-specific program (e.g., "uhp-run") that:
Parses the manifest of the installed package.
Sets up a new mount namespace, making the payload directory as the new root (using pivot_root or similar). The payload should be read-only; any writable areas are provided via tmpfs or overlay.
Unshare other namespaces: PID, network, UTS, IPC. Optionally user namespace if needed.
Set resource limits (rlimit, cgroups).
Apply seccomp filter: parse the seccomp filter (maybe a BPF program) and load it.
Configure AppArmor/SELinux if available.
Drop capabilities: by default drop all, then add those listed in manifest.
Mount necessary pseudo-filesystems: proc, sys, dev (maybe devpts). The mount points can be configured; default may mount a minimal /dev (only null, urandom, etc.) and /proc/sys read-only.
Set environment variables as specified.
Finally, exec the entrypoint with arguments.
The sandbox must ensure that the process cannot escape the rootfs or access host filesystem beyond what is explicitly bind-mounted. Also, it should prevent access to sensitive resources like /proc/kcore, etc.
The manifest's sandbox section can be used to request specific mounts or capabilities. The runtime may have a default policy that the user can override (e.g., in /etc/uhp/policy.d/). For security, the runtime should enforce a default deny policy: no network, no access to host devices, etc., unless explicitly allowed.
The runtime must be installed on the host; it's part of the "uhp-tools".
Update Ecosystem:
Repository: a simple HTTP/HTTPS directory containing:
An index file (e.g., repodata/primary.json) that lists all packages, with their name, version, architecture, size, and manifest URL (or the package file URL), and maybe the manifest's SHA256.
Possibly delta packages (with references to base version).
Signatures for the index (e.g., repodata/primary.json.sig).
Client tool (uhp-manager) that:
Can add a repository by URL.
Fetches the index (and verifies its signature against trusted keys).
Determines installed packages and available updates.
For update: downloads new package (or delta), verifies signatures of the package (manifest and possibly package signature), then atomically installs (i.e., writes to a new directory, updates symlink, runs any migration scripts? But hermetic suggests no host-side scripts. However, we might need to run a pre-start hook? Probably not; the package is self-contained).
Installs by extracting the payload to a versioned directory under /var/lib/uhp/packages//. Then creates a symlink current -> that version. The runtime uses the symlink to find the payload. So switching symlink is atomic.
Rollback: if new version fails (user reports), revert symlink to previous version.
Dependency resolution: before installing a package, check if its dependencies (external) are satisfied by installed packages or host. If not, fetch and install them automatically (with user confirmation maybe).
Delta updates: client downloads delta file and uses a delta algorithm (like xdelta3) to apply it to the existing payload to generate new payload. To ensure atomicity, apply to a new directory, then verify manifest, then switch. Delta updates are optional; the client may prefer full if delta not available.
Cache: stores downloaded packages and deltas.
We need to define a versioning scheme: semantic versioning recommended, but any string. Comparison should be defined.
Signing Policy:
Packages are signed by one or more keys. The key can be an Ed25519 or RSA key. The signature algorithm should be specified.
The manifest includes a list of signatures. Alternatively, the package archive includes detached signature file that signs the manifest.
The trust model: each user/administrator maintains a set of trusted root keys (like /etc/uhp/trusted-keys/). Packages are accepted if at least one of their signatures is by a key in the trust store.
Revocation: trust store may include revocation lists or use signatures with expiration. For simplicity, we can rely on the user to remove untrusted keys manually. Or we can have a mechanism to check a revocation server (CRL) but that's optional.
The index file (repository metadata) must also be signed to prevent tampering. The client verifies index signature against a repository key that is trusted (maybe the repository maintainer's key is pre-configured as trusted). That ensures the package URLs are authentic.
The signing process: when building a package, the packager runs a tool that creates manifest, computes file digests, writes manifest, then signs it with their private key. The manifest and payload are packaged.
Verification: when installing, the runtime tool (or installer) verifies the manifest's signature(s) against trusted keys. It also verifies that the file digests in the manifest match the actual payload files. If any mismatch, installation fails.
To support multiple signatures (e.g., maintainer and CI), we can have an array of signatures. The trust policy may require N-of-M signatures from trusted keys, but we can keep it simple: any trusted key is enough.
Additional concerns:
Security: sandbox must be robust. Use user namespaces to map to non-root inside, so even if compromised, attacker gets limited privileges.
Performance: using Mount and PID namespaces is overhead but acceptable.
Portability: on Windows, we could use similar concept with job objects, restricted tokens, etc. But maybe out of scope.
Cross-architecture: package includes arch field; the client only installs if matches host.
Naming: We'll call the format "Hermetic Universal Package" (HUP). But that's similar to "HUP" (hot upgradeable package). We'll use "UPack" (Universal Package) or "HoloPack". Let's pick "UPack".
We can define file extension .upack.
Putting it all together:
We'll produce a detailed design document.
Now, to answer the question: "Design a universal binary packaging format supporting hermetic dependencies: metadata schema, runtime sandboxes, update ecosystem, and signing policy."
We need to present a design that covers these aspects. We'll write a structured response.
I'll structure:
Overview: We'll propose "UPack" format.
Metadata Schema: Detailed JSON schema with fields, description.
Runtime Sandbox: How packages are executed, the runtime environment, isolation mechanisms.
entry: object with executable path and optional args array.
files: array of file objects: each with path (absolute path in payload), mode (octal string), type (file/dir/symlink), target for symlink, and digest (e.g., "sha256:hex").
For directories, digest may be omitted? But we could compute a hash of directory contents recursively. For simplicity, we only list regular files and symlinks; directories are implied.
dependencies: array of external dependencies. Each dependency: name, version (constraint), provider ("system" or "package"). For system, the runtime will check compatibility (e.g., host libc version). For package, the manager ensures it's installed.
sandbox: object with optional fields:
capabilities: array of strings (Linux capability names, e.g., "CAP_NET_BIND_SERVICE").
mounts: array of mount specs: source, target, type (bind, tmpfs), options (array, e.g., ["ro","noexec"]).
seccomp: string (base64 encoded BPF program) or path to a file inside payload? But that could be circular. Better as raw data.
apparmor: maybe a profile string.
env: object of environment variables to set.
network: string ("none", "host", "isolated").
update: optional, for update assistance: delta_from previous version, delta_url, release_notes.
signatures: array of signature objects: key_id, algorithm, data (base64-encoded signature). Or maybe we place signatures outside metadata. We'll decide: manifest includes a field signatures. The signature is computed over the manifest with signatures field removed. That is similar to JSON Web Signature but simpler. We'll define that the canonical form to sign is the JSON string with keys sorted lexicographically and without whitespace (as produced by a canonical JSON serializer). The array contains the signature values and key IDs. The signature signs the canonical JSON minus the field (or with an empty array). This ensures that adding more signatures does not invalidate previous ones.
Alternatively, we could keep signatures in a separate file; easier. I'll propose separate: the manifest is pure (no signatures). The package includes a separate file manifest.sig that is a binary blob: a list of signatures. But then the manifest file is not self-contained. We'll choose the separate file approach for simplicity in verification: the manifest.json is signed as is, and the signature file is SIGNATURE(manifest.json). That's a typical approach: you have a file and a .sig. The tooling can expect both. So we'll say: The package archive contains manifest.json and manifest.sig (which may contain one or more signatures in a format like "keyid:base64sig" repeated). The manifest does not contain a signatures field. The signature is computed over the exact bytes of manifest.json (deterministic encoding). That avoids the need to strip a field.
Let's adopt that: manifest.json is plain, with no signature field. The signature is a separate file manifest.sig. The manifest.sig format: lines: <key-id> <base64 signature>. Or we could use a more structured binary format (e.g., a simple struct). Simpler: text lines.
But the prompt asks for "signing policy", so we can describe the policy: mandatory signature, trusted keys, etc.
Now, the sandbox configuration: we need a standard that can be mapped to OS-specific primitives. We'll define a set of fields that the runtime will interpret. We'll specify that the default is "deny all", and only what is explicitly allowed is permitted. So if no capabilities or mounts, then none. That's safe. But some minimal things are needed: we need to provide a filesystem with /dev/null, /dev/zero, /dev/random, /proc, /sys, maybe /etc/passwd, /etc/hosts. Those can be provided by the runtime by default, not requiring package request. The package can request additional mounts (like a home directory) via the mounts field, but the runtime may restrict to certain sources (like only allow bind-mounting from a user-specified location). For security, the package shouldn't be able to request arbitrary host paths. Actually, hermetic means the package should be self-contained and not need host files. But sometimes you need to access user data, like a home directory. The runtime could provide a read-only view of host's /etc/hostname? Actually, we can have a default set of read-only mounts: /etc/hosts, /etc/resolv.conf (for DNS), maybe /etc/ssl/certs for CA certificates. These are necessary for network apps. The package could also bundle its own certificates. The runtime may allow configuration: user can choose to allow access to host's home via a file picker at launch. So the manifest might include a requires_home flag that indicates it needs user's home directory; the runtime can mount it at a specific path (e.g., /home/user). But that's more of a policy. We'll keep it simple: the default sandbox includes a minimal set of mount points (tmpfs for /tmp, devpts, proc, sys, and a minimal /dev). The package can request additional bind mounts via the mounts array, but the runtime may prompt the user or check a policy to allow it. For hermeticity, we prefer packages not to request host paths; they should bundle needed data. However, user data is dynamic. So we could have a concept of "user data directories" that are provided by the runtime based on user consent.
We'll not go too deep; just define that the sandbox configuration controls what resources are exposed.
Runtime Implementation:
We can say that the runtime is implemented as a set of platform-specific backends. For Linux, it uses unshare, mount, pivot_root, seccomp, etc. For other OSes, the runtime uses equivalent features.
Now, Update Ecosystem:
We'll describe a repository as a static file server with an index. The index is a JSON file index.json containing an array of package objects. Each object includes:
name
version
arch
manifest_url: relative URL to the manifest.json within the package? Or the package file itself? Let's say the package is a .upack file containing manifest and payload. So url points to the .upack file.
size, digest (sha256 of the .upack file)
delta_urls: optional array of delta from previous versions.
release_notes_url
The index itself is signed with a repository private key, producing index.json.sig. The client tool has the repository's public key configured (maybe distributed with the OS or manually added). When fetching index, it verifies signature. That prevents MITM on index.
The client maintains a local database of installed packages: for each, store name, version, install path, manifest (maybe cached). On update check, it compares installed versions with index. For each package with newer version, it computes needed delta (or full). It may also check dependencies: if a package depends on another, and that other has an update, it may need to be updated as well, possibly with a consistent set. The client can perform a "transaction" where multiple packages are updated atomically (by installing new versions in parallel and then switching symlinks? Might be complex). We could say that the client updates one package at a time, but that's not atomic; if one fails, the system might be left in inconsistent state. But we can use a staging area: download all new packages, verify, then install them atomically by swapping symlinks. However, dependencies might interrelate; e.g., A and B both depend on C. If we update C and A but not B, B might break. So the client should consider dependency graph and update in order. Maybe we rely on version constraints: all packages must be compatible with the new version of a shared dependency. The dependency resolution can be done like in package managers. We'll say the client resolves dependencies and ensures all required packages are scheduled for update. If some cannot be updated due to conflicts, the update fails.
We'll keep it simple: The manager updates each package independently. If a package fails to run after update, user can rollback. But we can also provide a "transaction" mode where multiple updates are applied together. Not essential.
Rollback: The client keeps the previous version's payload directory. The runtime uses a symlink current pointing to the active version. To rollback, simply change the symlink back. The client can also purge old versions after a timeout.
Signing Policy:
We'll describe:
All packages must be signed. The signature(s) are over the manifest.json file (not the payload). The manifest includes digests of payload files, so payload integrity is covered.
The manifest.sig file contains signatures in a format: each signature is a line: <key-id> <base64 signature>. The key ID is a hash of the public key (e.g., SHA-256).
The client verifies that at least one signature corresponds to a public key in its trusted store (e.g., /etc/uhp/trusted-keys/*.pub). The keys can be in PEM format. The client also checks for key revocation if CRL is configured (optional).
For repository index, a separate signature (e.g., index.json.sig) is required, signed by the repository's key. The client must have that repository key pre-installed as trusted, or the administrator must explicitly trust it.
To sign a package, the packager uses a tool that reads manifest.json, computes a hash, signs with private key, and writes manifest.sig.
The trust model is web-of-trust or direct trust. We can note that the user can add any maintainer's key to the trust store manually.
We could also support timestamping to prevent replay attacks? Not needed.
Now, we need to think about hermetic dependencies: the package includes all files needed except those explicitly declared as system dependencies. This ensures that the package runs the same on any host that meets the system dependency requirements. The sandbox ensures it doesn't accidentally use other host files.
Examples: The package might include its own libstdc++.so, not rely on host's. That's fine.
Now, we'll produce a final answer.
We'll start with an introduction: We propose UPack (Universal Package) a binary packaging format designed for hermetic dependencies, consisting of ... It aims to provide secure, reproducible, and isolated execution across Linux (and potentially other OSes). Then we describe each component.
We'll provide a JSON schema example for manifest.
We'll explain the runtime: upkd-run.
We'll explain update flow.
We'll explain signing.
Let's write in a clear, technical manner.
Potential pitfalls:
The manifest must be canonical for signature. We'll specify that manifest.json must be in canonical JSON: keys sorted alphabetically, no whitespace, double quotes, etc. We can say tools must produce it that way.
File paths: must be absolute and within a standard root, e.g., they start with /. The payload will be extracted preserving these paths. The runtime will treat its root as /. So path /usr/bin/app means file at usr/bin/app inside payload.
Permissions: mode field sets permissions.
Symlinks: if a file is a symlink, we include type: "symlink" and target (the link target, relative or absolute). The symlink target is interpreted as is inside the sandbox root. The payload stores the symlink.
Executables: should have executable bit.
We might also need to handle device nodes? Probably not needed.
Dependency resolution:
We need to define version constraints: using simple operators like >=, <, etc. Could be semver.
Architecture string: We'll define a standard: -. E.g., "linux-amd64". The client checks that its runtime's architecture matches.
Sandbox details:
We'll define defaults:
No network.
Read-only rootfs.
writable /tmp via tmpfs.
/dev contains only essential device nodes: null, zero, random, urandom.
/proc and /sys are mounted (maybe read-only).
seccomp filter: allow a set of safe syscalls; but we can also have a default seccomp that blocks many. The package can specify a custom seccomp filter (binary) that overrides default. That's risky; better to have default deny and allow list in manifest. Simpler: the manifest lists allowed syscalls? That's a lot. Or we rely on the runtime's default seccomp and the package can request additional ones? That's messy. Perhaps we define that the sandbox uses a default seccomp profile that only allows syscalls needed for typical applications (like read, write, open, etc.). The package can provide its own seccomp filter as a file in the payload (maybe at .seccomp.bpf) and the manifest references it. The runtime loads that BPF program. That's flexible. We'll go with that: the manifest's sandbox.seccomp is a base64-encoded BPF program. This allows the packager to fine-tune.
But we want to keep it simple: we can say that the runtime applies a default seccomp that blocks many dangerous syscalls (like ptrace, mount, kexec). The package can request to relax via a seccomp option that is a path to a precompiled BPF program inside the payload; the runtime loads it. But that's okay.
Alternatively, we can use a high-level policy like "allow all" (not hermetic). But we stick to default deny and only allow what's specified.
Security Considerations:
We'll mention that the runtime runs as root? To create namespaces and pivot_root, it may need privileges. It can be setuid root or use user namespaces. To avoid running as root, we can use user namespaces where the runtime maps its own UID to root inside the namespace. That way the runtime process can be unprivileged on the host but have root inside the namespace. That is typical for container runtimes. We'll say the runtime runs unprivileged, using user namespaces to gain necessary capabilities inside the namespace. That is safe.
How hermeticity is ensured: bundled dependencies + sandbox.
Attack surface minimization.
Reproducibility note.
We'll also mention limitations: only supports platforms where runtime can be implemented; requires kernel features for namespaces, etc.
Now, we need to write the answer. We'll be thorough but not overly long; maybe 2-3 pages.
We should also consider that the question asks "universal binary packaging format supporting hermetic dependencies". Perhaps it's similar to "OCI images" but for apps. Indeed, we can borrow heavily from OCI image spec: it has manifest, config, layers. But we are designing a simpler one. We can say the package is similar to an OCI image minus the layers concept; just one layer (the payload) plus config (manifest). That might be good: the manifest describes the payload archive. The manifest is signed. The payload is a tarball of the filesystem.
We could define that the package is a "blob" that is a tarball, and the manifest is separate but included. Actually OCI image uses a manifest.json that lists layers and config. The config is a JSON that includes runtime config. But we can simplify: our manifest is the config and includes file list. OCI image stores filesystem diff in layers; we store full filesystem. That's okay.
But maybe we can reuse OCI: the package would be an OCI image. That's already a universal packaging format. However, it's primarily for containers. But the question asks to design one, so we can propose something inspired by OCI but simpler.
We'll stick to our own.
Let's sketch manifest JSON schema more concretely:
We might also include a minimum_host_kernel and cpu_features.
We'll include that in requirements.
Now, about digest: we need to ensure that for each file we have a digest. For directories, we could skip or compute recursively. We'll say that directories are implied by the presence of files within them; they are created with mode as given (or default 755). The manifest may list directories explicitly if they need specific mode or to be empty. But it's okay.
Now, for update delta: the delta is a binary patch that transforms the previous payload tarball into the new payload tarball. The client would have the old payload extracted; it can apply delta directly on the extracted directory? But easier: delta is applied to the tar archive? We'll say the delta is a binary diff (e.g., xdelta) between the old payload tar and new payload tar. Then the client can apply it to the old tar to get new tar. But that requires storing the old tar. Alternatively, we can apply delta to the extracted old rootfs to produce new rootfs. That may be more efficient and avoid storing old tar. We can define: the delta is a binary patch that when applied to the old rootfs directory produces the new rootfs directory. The client can extract old payload to a temporary directory, apply delta, then verify manifest, then move into place. That avoids storing the old tar separately. But the old rootfs is already extracted in the installed location; we can apply delta directly to that directory? But we need atomicity: we don't want to modify the current live version. So we could copy the old rootfs to a new location, apply delta, verify, then switch. Or we can have the delta be applied to a tarball of the old rootfs (which we might have cached). Let's just say that delta updates are optional and are implemented as binary differences between the new package's payload tarball and the previous version's payload tarball. The client caches the old tarball (or keeps the extracted version) and uses a tool (like xdelta) to compute new tarball. That's fine.
Now, for runtime sandboxes: we need to define that the payload is a tarball that will be extracted to a directory. The runtime will then set that directory as the root. The directory will be read-only; any modifications go to tmpfs overlays. We'll mention use of overlayfs for writable parts.
Now, signing: We'll define that manifest.json is signed using Ed25519 or RSA with SHA-256. The signature file is in ASCII armored PGP format? Or simple binary? Simpler: we use a simple format: a file "manifest.sig" that is the concatenation of signatures: each signature is a line: <key-id-hex> <base64>. The verifier reads each line, decodes base64, verifies against the manifest bytes using the public key identified by key-id (which is found in trust store). If any signature matches a trusted key, accept.
Key-id: could be the SHA-256 fingerprint of the public key (32 bytes hex). That's long. Could use shorter first 16 bytes. We'll say use a truncated SHA-256 (16 bytes) for brevity.
Now, we must ensure that the manifest bytes are exactly as signed. So the manifest must be written without any trailing newline? Or we can specify that the signature is computed over the exact bytes of the file. To avoid issues with line endings, we require LF.
We can also note that the manifest may be minified (no whitespace) but that's not required; we just sign the bytes we store. So the canonicalization is just the stored bytes. That's simpler: no special canonicalization needed beyond consistent formatting. The packager tool writes the manifest in a deterministic way (e.g., sorted keys). We'll recommend using a deterministic JSON serializer (e.g., json.dump(..., sort_keys=True, separators=(',', ':'))). The signature is over that serialization.
We'll also mention that the manifest may be gzipped? No, it's plain.
Now, the runtime will verify signature before launching, but also the package manager will verify at install time. So we have two verification points: install and run. At install, we check manifest.signature and also digests of payload. At run, we might trust that install already verified, but we can re-verify if needed. Typically, you verify once on install; subsequent runs may skip if not tampered. But for security, runtime should also verify signatures? Possibly not needed if the installed package's files are read-only and protected. We'll state that the installer verifies signatures and digests, and sets files immutable (chattr +i) maybe, to prevent tampering. Or the runtime could re-verify before each execution to detect post-install tampering. We'll note that as optional.
Now, we need to address the "universal" aspect: The format is defined for any OS, but the runtime implementation is per OS. We'll note that for non-Linux, analogous sandbox mechanisms will be used (e.g., Windows sandbox, macOS Seatbelt). The manifest schema can be extended with OS-specific fields, but we try to keep core portable.
We'll also discuss that the package may include multiple binaries for different OSes (multi-arch) via optional fields? Could be a separate package per arch; easier.
Now, let's write the answer.
We'll produce a thorough design. Let's begin.
UPack: A Universal Binary Packaging Format for Hermetic Execution
1. Overview
UPack (Universal Package) is a packaging format designed to deliver applications with hermetic dependencies—all non‑system libraries, runtimes, and assets are bundled inside the package and executed inside a hardened sandbox. The format is OS‑agnostic at the specification level, but concrete runtime implementations are provided per operating system (e.g., Linux, Windows, macOS). A UPack bundle is a single file with the extension .upack.
Key goals:
Hermeticity – The package contains everything it needs to run, independent of host‑installed libraries (except an explicitly defined minimal system interface).
Isolation – Execution occurs in a mandatory access‑controlled sandbox with a default‑deny policy.
Reproducibility – Deterministic builds and cryptographic verification of all contents.
Rollback‑friendly updates – Atomic installs, delta updates, and easy rollbacks.
2. Package Structure
A .upack file is a POSIX.1‑2001 tar archive (uncompressed or gzip‑compressed) with the following mandatory entries:
The payload/ directory contains the complete root filesystem as it should appear inside the sandbox (e.g., usr/bin/app, usr/lib/libcustom.so, etc.). File ownership and permissions are preserved via tar metadata.
3. Metadata Schema (manifest.json)
The manifest is a canonical JSON object (keys sorted alphabetically, no whitespace) describing the package and its requirements. All fields are required unless marked optional.
format_version: Enables future schema evolutions; tools must reject unknown major versions.
name: A globally unique identifier (reverse‑DNS style is recommended).
arch: <os>-<cpu> triple (e.g., linux-amd64, windows-arm64, darwin-amd64). The runtime only accepts packages matching its own os-arch.
minimum_host_kernel & cpu_features: Used to reject incompatible hosts before launching.
entry: Path to the main executable inside the payload and optional default arguments.
files: An array of all regular files and symlinks that belong to the package. Each entry:
path: absolute path inside the rootfs.
mode: octal Unix permission bits (e.g., "0755").
type: "file", "dir", or "symlink". Directories are created automatically with mode; explicit entries are allowed to set empty directories.
target: required for "symlink" (the link target).
digest: "sha256:<hex>" of the file content (directories may omit digest).
dependencies: External requirements.
provider: "system" means the runtime must check that the host provides a compatible version (e.g., glibc, libstdc++). "package" means another UPack must be installed.
version: A constraint string; semver‐compatible operators (>=, ~, =) are encouraged.
sandbox: Controls the isolation environment:
capabilities: Linux capabilities to retain in the new user namespace (e.g., CAP_NET_BIND_SERVICE). Default is none.
mounts: Additional mount points to create. Sources may be read‑only bind mounts from the host (only allowed if the source path is within a permitted whitelist or user explicitly consents at launch). tmpfs mounts are always safe.
seccomp: Base64‑encoded classic BPF program. If omitted, a safe default filter is used.
network: "none" (completely isolated), "host" (share host network namespace), (create a new network namespace with a virtual Ethernet pair; NAT to host if needed).
4. Runtime Sandbox (upkd)
upkd (UPack Daemon) is the runtime that launches a verified package inside a hardened environment. It is installed once per operating system and is invoked by the package manager or directly by users.
4.1. Launch Sequence
Trust verification – Before execution, upkd checks that the package’s manifest.sig is present and verifies it against the trusted keys on the host (see §5). It also recomputes all file digests from the payload and compares them to the manifest; any mismatch aborts launch.
Preparation – The payload directory (extracted at install time) is mounted read‑only.
Namespaces – The process enters new mount, PID, UTS, IPC, and (by default) user namespaces. The user namespace maps the calling user to UID 0 inside the sandbox, granting the necessary capabilities only within the namespace.
Rootfs setup – pivot_root isolates the payload as /. A minimal set of system directories is provided by the runtime:
/dev – populated with only null, zero, random, urandom, and optionally tty devices (if required).
/proc and /sys – mounted read‑only.
/tmp – a fresh tmpfs.
Host paths requested in sandbox.mounts are bind‑mounted after policy checks (e.g., user must explicitly grant access to $HOME at first launch). All mounts are read‑only unless explicitly marked rw.
Capabilities & SecComp – All capabilities are dropped except those listed in sandbox.capabilities. The default seccomp filter allows a safe whitelist of syscalls (read, write, open, fstat, mmap, mprotect, exit, etc.). If sandbox.seccomp is present, that BPF program is loaded instead (it can further restrict or extend).
Network – If network is "isolated", a new network namespace with a veth pair and NAT to the host is created. "host" uses the host’s namespace. "none" leaves the namespace without any network interfaces.
Environment – Variables from sandbox.env and a minimal set (e.g., PATH=/usr/bin) are set.
Exec – The process finally execve()s the entry point with its arguments. All subsequent processes inherit the same restrictions.
4.2. Platform Support
Linux – Uses unshare(2), pivot_root(2), seccomp(SECCOMP_SET_MODE_FILTER), setns(2), and user namespaces.
Windows – Uses Job Objects, Restricted Tokens, and the Windows Sandbox APIs.
macOS – Uses seatbelt profiles, sandbox_exec(3), and launchd constraints.
The manifest schema is intentionally generic; OS‑specific extensions can be added under an "os_ext" object.
5. Update Ecosystem
UPack ships with a package manager (upkd-mgr) that handles installation, updates, removals, and dependency resolution.
5.1. Repository Layout
A repository is a static HTTP(S) directory with the following structure:
code
repo/
├── index.json # main index (array of package objects)
├── index.json.sig # repository key signature over index.json
└── packages/
├── com.example.myapp-1.2.3.upack
├── com.example.myapp-1.2.2-1.2.3.delta
└── ...
index.json contains an array of package descriptors:
The index.json is signed with the repository’s private key using the same manifest‑signing scheme (signature over the file bytes). upkd-mgr ships with the repository’s public key pre‑installed, or the user can add it manually.
5.2. Installation & Atomic Roll‑backs
Installing – The manager downloads the .upack file, verifies the signature and all file digests, then extracts the payload to a version‑specific directory: /var/lib/upkd/packages/com.example.myapp/1.2.3/.
A symlink current points to the active version. The manifest is copied to a cache area.
Atomicity – Extraction is done to a temporary directory; after verification the directory is atomically renamed into place and the current symlink is updated (rename(2) ensures the switch is atomic). Old versions are retained for rollback.
Rollback – To revert, the manager simply switches the current symlink to the previous version and restarts the service (if needed). No data is lost because each version has its own isolated payload.
5.3. Updates
The manager periodically fetches index.json (or on user request) and compares installed versions.
Full vs Delta – If a delta is available for the current current version, it is downloaded and applied to the already‑extracted payload using a deterministic algorithm (e.g., xdelta3). The resulting directory is verified against the new manifest before switching. If the delta fails, the manager falls back to downloading the full package.
Dependency resolution – Before installing/updating a package, all declared provider: "package" dependencies are checked. If a required package is missing or out‑of‑date, it is queued for update (respecting version constraints). The manager builds a consistent update set and performs updates in a single transaction if feasible, otherwise aborts with a conflict report.
Security – All downloaded files (index, packages, deltas) are verified before use. Deltas are signed along with the target manifest (the delta file includes a signature that binds it to the target version; its manifest.sig is still required).
6. Signing Policy
6.1. Package Signing
Manifest generation – The build tool creates manifest.json with canonical JSON.
Signature – The manifest is signed with the maintainer’s private key (Ed25519 or RSA‑PKCS#1 v1.5 with SHA‑256). The signature is stored in a separate ASCII file manifest.sig with the format <key-id-hex> <base64‑signature>
where key-id-hex is the first 16 bytes of the SHA‑256 fingerprint of the public key.
Packaging – The manifest.json, manifest.sig, and payload/ are tarred into the final .upack.
The signature covers only the bytes of manifest.json. The file digests in the manifest protect the payload. This separation allows the manifest to be verified before downloading the entire payload (the manager may first fetch manifest.json and its .sig to decide whether to download the heavy payload).
6.2. Trust Model
Trusted key store – The system location /etc/upkd/trusted-keys/ (or a user‑specific dir) holds PEM‑encoded public keys. A key may be marked as trusted either by explicit admin action or by being signed by another trusted key (web‑of‑trust).
Verification – Upon install or launch, upkd reads manifest.sig, extracts the key-id, looks up the corresponding public key in the trust store, and verifies the signature. At least one signature must be from a trusted key. Multiple signatures (e.g., from a CI system and a maintainer) are allowed.
Revocation – Keys can be removed from the trust store. Optionally, a CRL distribution point may be configured; however, for simplicity, revocation is administrative.
Repository signatures – The index.json and its .sig are verified against a dedicated repository key stored in the trust store. This prevents a compromised client from being fed a malicious index.
6.3. Build & Release Process (for maintainers)
Maintainers generate a key pair (upkd-keygen).
They build the package, then run upkd-sign --key <private-key> manifest.json to create manifest.sig.
For repository indexes, the repo maintainer signs index.json with the repository's private key (outside the package format).
7. Security and Hermeticity Guarantees
Hermetic dependencies – All files required at runtime (libraries, assets, config defaults) are inside payload/. The only system components relied upon are the kernel, a minimal set of device nodes, and the virtual filesystems (proc, sys). Optional system dependencies (e.g., glibc) are declared and validated at launch.
Strong isolation – The sandbox employs multiple Linux namespaces (or OS equivalents), a restrictive seccomp filter, and a minimal capability set. By default, the process has no network access and no access to host files beyond explicitly granted mounts.
Cryptographic integrity – The manifest’s signature and per‑file digests guarantee that neither the package description nor any payload file can be altered without detection.
Reproducibility – Build tools are expected to produce deterministic payloads (e.g., by zeroing timestamps, sorting inputs). The digest list in the manifest makes any nondeterminism visible.
Rollback safety – Old versions remain on disk and are instantly switchable, protecting against bad updates.
8. Example Workflow
bash
# Add a repository (trusts the repo key)
upkd-mgr repo-add https://repo.example.com/upkd
# List available packages
upkd-mgr list-remote
# Install
upkd-mgr install com.example.myapp
# Run (via runtime)
upkd-run com.example.myapp # automatically selects the 'current' symlink
# Check for updates
upkd-mgr check-updates
# Update (with delta if available)
upkd-mgr update com.example.myapp
# Rollback if something breaks
upkd-mgr rollback com.example.myapp
The entire process is gated by signature verification and sandbox safety.
9. Conclusion
UPack provides a complete, secure, and portable packaging solution for hermetic binary distribution. By combining a simple tar‑based bundle, a rich yet extensible manifest, a mandatory sandbox, a robust update mechanism, and a straightforward signing policy, it meets the needs of modern applications that demand isolation, reproducibility, and easy roll‑backs across diverse host environments.
signatures
signatures
"isolated"
env: Environment variables to set inside the sandbox.
update: Optional hints for differential updates.
delta_from: The exact version this package was built from.
delta_url: Location of a pre‑computed delta (binary patch) that transforms the previous version’s payload into this one.