Skip to content

MS Publisher file subheader (.pub)

.pub file signature | application/octet-stream

MS Publisher file subheader

Safe

Magic Bytes

Offset 0
2D 2D 2D 2D 2D 42 45 47 49 4E 20 53 53 48 32 20 4B 45 59 2D 2D 2D 2D 2D

Sources: Wikipedia

All Known Signatures

4 signature variants are documented for .pub files across multiple sources.

Hex Signature Offset Sources
2D 2D 2D 2D 2D 42 45 47 49 4E 20 53 53 48 32 20 4B 45 59 2D 2D 2D 2D 2D 0 Wikipedia
CF FA ED FE 0 Gary Kessler
D0 CF 11 E0 A1 B1 1A E1 0 Gary Kessler
51 20 BE FF EF FF FF FF 02 0 Gary Kessler

Extension

.pub

MIME Type

application/octet-stream

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .pub files in Python

Python
def is_pub(file_path: str) -> bool:
    """Check if file is a valid PUB by magic bytes."""
    signature = bytes([0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x53, 0x53, 0x48, 0x32, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D])
    with open(file_path, "rb") as f:
        return f.read(24) == signature

How to validate .pub files in Node.js

Node.js
function isPUB(buffer: Buffer): boolean {
  const signature = Buffer.from([0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x53, 0x53, 0x48, 0x32, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D]);
  return buffer.subarray(0, 24).equals(signature);
}

How to validate .pub files in Go

Go
func IsPUB(data []byte) bool {
    signature := []byte{0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x53, 0x53, 0x48, 0x32, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D}
    if len(data) < 24 {
        return false
    }
    return bytes.Equal(data[:24], signature)
}

API Endpoint

GET /api/v1/pub
curl https://filesignature.org/api/v1/pub

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .pub file?

A .pub file is a MS Publisher file subheader file. MS Publisher file subheader

What are the magic bytes for .pub files?

The magic bytes for MS Publisher file subheader files are 2D 2D 2D 2D 2D 42 45 47 49 4E 20 53 53 48 32 20 4B 45 59 2D 2D 2D 2D 2D at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .pub file?

To validate a .pub file, read the first bytes of the file and compare them against the known magic bytes (2D 2D 2D 2D 2D 42 45 47 49 4E 20 53 53 48 32 20 4B 45 59 2D 2D 2D 2D 2D) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .pub files?

There is no officially registered MIME type for .pub files. Systems typically use application/octet-stream as a generic fallback when handling this format.

Is it safe to open .pub files?

MS Publisher file subheader (.pub) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.