Icon
image/vnd.microsoft.icon
Magic Bytes
Offset: 0
00 00 01 00
The ICO file format is an image container developed by Microsoft for storing icons within Windows operating systems. It encapsulates multiple bitmap images at various resolutions and color depths, allowing software to display the appropriate size for desktop shortcuts, file lists, and website favicons. While widely supported across modern browsers and platforms, malformed files have historically targeted buffer overflow vulnerabilities in older image processing libraries.
Validation Code
How to validate .ico files in Python
Python
def is_ico(file_path: str) -> bool:
"""Check if file is a valid ICO by magic bytes."""
signature = bytes([0x00, 0x00, 0x01, 0x00])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .ico files in Node.js
Node.js
function isICO(buffer: Buffer): boolean {
const signature = Buffer.from([0x00, 0x00, 0x01, 0x00]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsICO(data []byte) bool {
signature := []byte{0x00, 0x00, 0x01, 0x00}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/ico
curl https://filesignature.org/api/v1/ico