{"record":{"id":"7cf836af2e011458","repo":"dotnet/wpf","slug":"decompression-of-packet-data-failed","errorCode":null,"errorMessage":"Decompression of packet data failed.","messagePattern":"Decompression of packet data failed\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/Compress.cs","lineNumber":89,"sourceCode":"            byte[] compressedInput,\n            ref uint size,\n            int[] decompressedPackets)\n        {\n#if OLD_ISF\n            //\n            // lock to prevent multi-threaded vulnerabilities \n            //\n            lock (_compressSync)\n            {\n#endif\n                if (compressedInput == null ||\n                    size > compressedInput.Length ||\n                    decompressedPackets == null)\n                {\n                    //we don't raise any information that could be used to attack our ISF code\n                    //a simple 'ISF Operation Failed' is sufficient since the user can't do \n                    //anything to fix bogus ISF\n                    throw new InvalidOperationException(StrokeCollectionSerializer.ISFDebugMessage(SR.DecompressPacketDataFailed));\n                }\n#if OLD_ISF\n                uint size2 = size;\n#endif\n\n                size = AlgoModule.DecompressPacketData(compressedInput, decompressedPackets);\n\n#if OLD_ISF\n                MS.Win32.Penimc.CompressorSafeHandle safeCompressorHandle = (compressor == null) ?\n                                                    MS.Win32.Penimc.CompressorSafeHandle.Null :\n                                                    compressor._compressorHandle;\n\n                int[] decompressedPackets2 = new int[decompressedPackets.Length];\n                byte algo = AlgoModule.NoCompression;\n                int hr = MS.Win32.Penimc.UnsafeNativeMethods.IsfDecompressPacketData(safeCompressorHandle,\n                                                                                            compressedInput,\n                                                                                            ref size2,\n                                                                                            (uint)decompressedPackets2.Length,","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/Compress.cs#L71-L107","documentation":"Preconditions for native packet decompression failed or the native decompression call produced a bad result (size out of range, null output buffer, or non-zero HR). The library throws 'Decompression of packet data failed.' as a deliberately vague guard against attacks on the ISF decompressor.","triggerScenarios":"Loading ISF strokes where the compressed packet chunk's declared size exceeds the actual input length, the decompressed-buffer request fails, or AlgoModule.DecompressPacketData returns an inconsistent result.","commonSituations":"Truncated or maliciously crafted .isf files; ink streams across clipboard/persistence round-trips losing bytes; third-party ISF writers emitting invalid chunk sizes.","solutions":["Re-save or re-export the ink file from a trusted application","Validate the ISF stream (chunk sizes consistent with buffer length) before deserializing","Catch InvalidOperationException in stroke deserialization and degrade gracefully (drop the stroke/ink payload)"],"exampleFix":"// before\nvar strokes = new StrokeCollection(stream); // throws Decompression of packet data failed\n// after\ntry { strokes = new StrokeCollection(stream); }\ncatch (InvalidOperationException) { strokes = null; ReportCorruptIsf(); }","handlingStrategy":"try-catch","validationCode":"if (chunkSize > input.Length) throw new InvalidDataException(\"ISF packet chunk exceeds buffer\");","typeGuard":"bool IsSanePacketChunk(byte[] b, uint declared) => b != null && declared <= (uint)b.Length;","tryCatchPattern":"try { return new StrokeCollection(stream); } catch (InvalidOperationException) { ReportCorruptInk(); return null; }","preventionTips":["Validate chunk sizes against buffer lengths before decoding","Recover ink from the original application when decode fails","Treat untrusted ISF as untrusted input and sandbox its parsing"],"tags":["wpf","ink","isf","decompression"],"backgroundTag":"unexpected-response-shape","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}