Technique:Install-time code execution in package archives
| On this wiki | Facts · Code · Notes · Topics |
|---|
Table of what each language package archive (Python wheel/sdist/egg, RubyGems, npm, NuGet, Rust crate, Go module, Conda, Composer) contains, how to recognise it, and which of its files run code when the package is installed or built, for reversers and supply-chain analysts.
Unpack the archive without installing it (these are all ZIP or tar containers) and read the files that execute first. Every row below is backed by facts on the format page.
| Ecosystem | Container | Metadata to read | Code that runs at install/build |
|---|---|---|---|
| Python wheel | Format:Python wheel ZIP .whl |
*.dist-info/METADATA, WHEEL, RECORD, entry_points.txt |
Nothing at install (files are unpacked; .pth files and imports run later)
|
| Python sdist | Format:Python sdist .tar.gz |
PKG-INFO, pyproject.toml |
Build backend and setup.py, plus build requirements
|
| RubyGems | Format:RubyGems gem tar of metadata.gz, data.tar.gz, checksums.yaml.gz | metadata.gz YAML spec, field extensions |
extconf.rb, configure, Rakefile, mkrf_conf, CMake, Cargo builds |
| npm | Format:npm package tarball .tgz, package/ prefix |
package/package.json scripts |
preinstall, install, postinstall (and default node-gyp for binding.gyp) |
| NuGet | Format:NuGet package ZIP .nupkg |
.nuspec, .signature.p7s |
MSBuild build/*.targets, analyzers; tools/install.ps1 in VS packages.config flow |
| Rust crate | Format:Rust crate .crate tar.gz |
normalized Cargo.toml, .cargo_vcs_info.json |
build.rs, proc macros, at build time
|
| Go module | Format:Go module zip ZIP with module@version/ |
go.mod, go.sum h1: |
None at download or build of dependencies (see page for caveat) |
| Conda | Format:Conda package .conda or .tar.bz2 |
info/ |
Unverified: link scripts |
| Composer | Unverified: ZIP of the repository tree with composer.json |
composer.json scripts |
Unverified: composer runs scripts events such as post-install-cmd and plugin classes
|
Recognition by first bytes
PK\x03\x04 = ZIP (wheel, nupkg, conda, Go zip, egg, Composer dist). 1F 8B = gzip (sdist, crate, npm; a gem is a plain tar whose members include gzip files). BZh = legacy conda. A ZIP with [Content_Types].xml and a .nuspec is NuGet; with *.dist-info/WHEEL a wheel; with metadata.json and pkg-*.tar.zst a conda package; entries starting package/ mean npm; one directory <name>-<version>/ with Cargo.toml.orig means a crate; one with PKG-INFO an sdist.
Checks worth doing
- List all entries and look for paths outside the expected top directory and for absolute paths or
... - Compare the package contents with the project's public repository (crates carry
.cargo_vcs_info.jsonwith the commit; npm, wheel and gem do not). - Compare hashes: wheel RECORD, gem checksums.yaml.gz, npm SRI integrity, NuGet
.nupkg.sha512, cratecksum, Goh1:.
This page is a summary; follow the links for the line-level evidence.