Resource Interchange File Format --Audio for Windowsfile
audio/vnd.wave
Magic Bytes
Offset: 0
52 49 46 46 2E 2E 2E 2E 57 41 56 45
Waveform Audio File Format (WAV) is a standard based on the Resource Interchange File Format, co-developed by Microsoft and IBM. This format is widely utilized for storing uncompressed, lossless audio and serves as a primary standard in professional music production and sound engineering. Although generally considered safe for playback, malformed headers have historically been leveraged to exploit buffer overflow vulnerabilities in outdated media player applications.
Validation Code
How to validate .wav files in Python
Python
def is_wav(file_path: str) -> bool:
"""Check if file is a valid WAV by magic bytes."""
signature = bytes([0x52, 0x49, 0x46, 0x46, 0x2E, 0x2E, 0x2E, 0x2E, 0x57, 0x41, 0x56, 0x45])
with open(file_path, "rb") as f:
return f.read(12) == signature
How to validate .wav files in Node.js
Node.js
function isWAV(buffer: Buffer): boolean {
const signature = Buffer.from([0x52, 0x49, 0x46, 0x46, 0x2E, 0x2E, 0x2E, 0x2E, 0x57, 0x41, 0x56, 0x45]);
return buffer.subarray(0, 12).equals(signature);
}
Go
func IsWAV(data []byte) bool {
signature := []byte{0x52, 0x49, 0x46, 0x46, 0x2E, 0x2E, 0x2E, 0x2E, 0x57, 0x41, 0x56, 0x45}
if len(data) < 12 {
return false
}
return bytes.Equal(data[:12], signature)
}
API Endpoint
GET
/api/v1/wav
curl https://filesignature.org/api/v1/wav