Format:RPM package
| Magic | ED AB EE DB at offset 0; header structures start 8E AD E8 01 |
|---|---|
| Extensions | .rpm, .srpm |
| Endianness | big-endian (network order) |
| On this wiki | Facts · Code · Notes · Topics |
The .rpm package of Red Hat, Fedora, SUSE and others: a 96-byte lead starting ED AB EE DB, a signature header and a metadata header (both with magic 8E AD E8 01, tag/index/data sections), then a compressed cpio payload.
Sections
From the rpm manual (docs/manual/format_v4.md, format_lead.md, format_header.md; rpm commit 3a7ddfd1c9). All integers are big-endian. A package has four logical sections:
- Lead: always 96 bytes. Magic
ED AB EE DB, then major and minor version bytes (3.0 in the documented example), a 16-bit type (0 binary, 1 source), a 16-bit architecture number, a 66-byte name-version-release string, a 16-bit OS number, a 16-bit signature type (5 means header-style signatures) and 16 reserved bytes. The manual calls the rest of the lead historical only; the real architecture is a string tag in the header. - Signature: a header structure (below), zero-padded to a multiple of 8 bytes. Its first tag is 62 (HEADERSIGNATURES). Other tags: DSA 267, RSA 268, SHA1 269 (string), LONGSIZE 270, LONGARCHIVESIZE 271, SHA256 273 (string; 272 is reserved, SIG_BASE 256 + 17), FILESIGNATURES 274, VERITYSIGNATURES 276, SIZE 1000, PGP 1002, MD5 1004, GPG 1005, RESERVEDSPACE 1008. These numbers clash with the main header's tags: do not mix them.
- Header: the same structure; its first tag is 63 (HEADERIMMUTABLE). It holds name (tag 1000), version, file list, dependencies, scripts...
- Payload: a cpio archive, gzip-compressed by default; the cpio type is SVR4 with CRC (see Format:Cpio newc (initramfs); newc
070701and CRC070702). The compressor and the format are named by header tags. Since rpm 4.12 packages with files over 4 GB use a stripped cpio with magic07070Xwhose headers carry only the file's index (8 hex digits) in the RPM header: names and metadata come from the header.
Header structure
An 8-byte magic 8E AD E8 01 00 00 00 00 (3 magic bytes, version 1, 4 reserved), uint32 index_length (entry count), uint32 data_length, then index entries of 16 bytes (uint32 tag, uint32 type, int32 offset, uint32 count, sorted by tag), then the data section. Types: 1 CHAR, 2 INT8, 3 INT16, 4 INT32, 5 INT64, 6 STRING (count 1), 7 BIN, 8 STRING_ARRAY, 9 I18NSTRING. Integers are aligned to their size inside the data section; strings are NUL-terminated.
Getting at the binaries
- Find the payload start by walking: 96 bytes of lead, signature header (pad to 8), metadata header, payload. Then check the payload magic (gzip
1F 8B, xzFD 37 7A 58 5A 00, zstd28 B5 2F FD, bzip2BZh) and unpack the cpio. rpm2cpio file.rpm | cpio -idmvdoes it on Linux.- The manual says the proper way to read these structures is the rpm library; version 6 packages are described in format_v6.md (not read in detail here).
Tag numbers and types are in Fact:RPM package/enum/Header tag numbers, Fact:RPM package/enum/Signature header tag numbers and Fact:RPM package/enum/Header entry types. The file list is split: DIRNAMES 1118 (string array), BASENAMES 1117 (string array) and DIRINDEXES 1116 (int array giving each file's directory); the full path of file i is DIRNAMES[DIRINDEXES[i]] + BASENAMES[i]. Unverified: the join rule (the DIRNAMES entries end with a slash); and that RPMTAG_FILENAMES 5000 is a computed extension tag, not stored in the file (rpmtag.h marks it extension).
Sources
rpm-software-management/rpm, docs/manual (documentation; GPL-2.0-or-later with LGPL parts per the project).
Code & repositories
- https://github.com/rpm-software-management/rpm @
3a7ddfd1c9260c429855bf7811f31de86b453e37· license: GPL-2.0-or-later OR LGPL-2.0-or-later (declared by the contributor; GitHub's detector did not recognize COPYING)
RPM: docs/manual describes lead, signature, header and payload formats
Tested on: source read, not run: not run, documentation read · checked 2026-10-18; last activity 2026-10-14