XSD
application/xml
Magic Bytes
Offset: 0
3C 3F 78 6D 6C
XML Schema Definition (XSD) is a recommendation developed and maintained by the World Wide Web Consortium (W3C) for describing the structure and constraints of XML documents. It provides a formal description of an XML document's elements, attributes, and data types, ensuring data integrity during automated validation processes. Although inherently safe, XSD files may be susceptible to XML External Entity (XXE) vulnerabilities if a parser incorrectly processes external references during the schema validation step.
Validation Code
How to validate .xsd files in Python
Python
def is_xsd(file_path: str) -> bool:
"""Check if file is a valid XSD by magic bytes."""
signature = bytes([0x3C, 0x3F, 0x78, 0x6D, 0x6C])
with open(file_path, "rb") as f:
return f.read(5) == signature
How to validate .xsd files in Node.js
Node.js
function isXSD(buffer: Buffer): boolean {
const signature = Buffer.from([0x3C, 0x3F, 0x78, 0x6D, 0x6C]);
return buffer.subarray(0, 5).equals(signature);
}
Go
func IsXSD(data []byte) bool {
signature := []byte{0x3C, 0x3F, 0x78, 0x6D, 0x6C}
if len(data) < 5 {
return false
}
return bytes.Equal(data[:5], signature)
}
API Endpoint
GET
/api/v1/xsd
curl https://filesignature.org/api/v1/xsd