MS Publisher file subheader

application/octet-stream

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

The SSH Public Key format is a cryptographic data structure standardized by the Internet Engineering Task Force for the Secure Shell protocol. It is primarily used for authenticating users to remote servers and establishing secure communication channels across networked systems. While it shares the .pub file extension with Microsoft Publisher documents, this specific format is a text-based structure and is considered safe as it contains no executable code.

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);
}
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

Related Formats