FileMetadataStripping removes embedded metadata (EXIF, IPTC, XMP, PDF /Info, OOXML/ODF properties, RTF \info, EPUB Dublin Core, SVG title/desc, audio/video tags) from uploaded files before they reach any AI API.File metadata carries arbitrary text invisible to users. An attacker can embed prompt-injection instructions in these fields using standard tools without altering the file visually - and if the file reaches an AI model, the injected text is processed as trusted input.StripFileMetadata(rawFile, stripBodyAuthors) returns a clean file plus a structured JSON audit of what was found. Covers images (JPEG/PNG/GIF/TIFF/WebP/AVIF/HEIC + 40 more), documents (PDF, DOCX/XLSX/PPTX + all template & macro-enabled variants, legacy .doc/.xls/.ppt via CFBF, ODT/ODS/ODP + 9 ODF variants, Flat ODF, Word 2003 XML, RTF, EPUB, ORA, SVG), and audio/video (MP3, MP4, WAV, M4A, MOV, WebM, AIFF, APE, WavPack, MPC).Verified by 1,440 xUnit regression tests.
Embedded objects - OOXML charts, images, and OLE containers retain their own metadata.ICC profiles - removed with image metadata; sRGB fallback.Memory - no size limit; entire file loaded into memory.Unreadable files - encrypted or corrupted files returned unchanged; ExtractedMetadata includes a processingError note.Body authors - stripped only when StripBodyAuthors = True.Excel threaded comments - xl/threadedComments/ retains author names.PDF embedded images - retain their own EXIF; not processed.VBA macros (vbaProject.bin) and digital signatures - not stripped.HEIC / HEIF - transcoded to JPEG; x265 HEVC is GPL-licensed. transcodedFormat key set.APNG - reading fixed; writing needs ffmpeg. Without ffmpeg, output is JPEG.DICOM - PHI tags (patient name, ID, dates) survive; no DICOM SDK bundled.Animated WebP - per-frame metadata survives; libwebpmux native library not bundled.WBMP - no reliable magic bytes; returned as passthrough.
MIT License