{"record":{"id":"05d2706570202fd4","repo":"peass-ng/PEASS-ng","slug":"msg","errorCode":null,"errorMessage":"msg","messagePattern":"msg","errorType":"exception","errorClass":"OutputLengthException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/Check.cs","lineNumber":20,"sourceCode":"{\n    internal class Check\n    {\n        internal static void DataLength(bool condition, string msg)\n        {\n            if (condition)\n                throw new DataLengthException(msg);\n        }\n\n        internal static void DataLength(byte[] buf, int off, int len, string msg)\n        {\n            if (off > (buf.Length - len))\n                throw new DataLengthException(msg);\n        }\n\n        internal static void OutputLength(byte[] buf, int off, int len, string msg)\n        {\n            if (off > (buf.Length - len))\n                throw new OutputLengthException(msg);\n        }\n    }\n}\n","sourceCodeStart":2,"sourceCodeEnd":24,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/Check.cs#L2-L24","documentation":"Check.OutputLength validates that reading 'len' bytes at 'off' from a buffer stays in bounds; if off > buf.Length - len it throws the caller-supplied msg wrapped in an OutputLengthException (a DataLengthException subclass). The literal message 'msg' means the caller passed a placeholder/unused message string, but the real cause is an out-of-range offset/length pair on an output buffer.","triggerScenarios":"Calling a cipher/mac/digest DoFinal or ProcessBytes-style API with an output buffer whose off+len exceeds the buffer length, where the library routes the check through Check.OutputLength.","commonSituations":"Allocating output buffers from the input size without padding, reusing undersized buffers, using wrong offsets after partial processing, hard-coded 'msg' placeholder from copy-pasted code.","solutions":["Size the output buffer to at least off+len for the operation (use GetOutputSize/GetUpdateOutputSize where available)","Check off and len values passed to the API against buf.Length","Replace placeholder 'msg' arguments with descriptive messages to make future failures diagnosable"],"exampleFix":"// before\nbyte[] out = new byte[input.Length];\ncipher.DoFinal(input, 0, input.Length, out, 0);\n// after\nint needed = cipher.GetOutputSize(input.Length);\nbyte[] out = new byte[needed];\ncipher.DoFinal(input, 0, input.Length, out, 0);","handlingStrategy":"validation","validationCode":"bool OutputBufferOk(byte[] buf, int off, int len) => buf != null && off >= 0 && len >= 0 && off + len <= buf.Length;","typeGuard":null,"tryCatchPattern":"try { engine.DoFinal(input, 0, input.Length, output, 0); }\ncatch (OutputLengthException ex) { logger.Error(ex, \"output buffer too small\"); throw; }","preventionTips":["Size output buffers via GetOutputSize/GetUpdateOutputSize","Assert off+len <= buf.Length before calling crypto APIs","Avoid placeholder message strings like 'msg' in Check calls"],"tags":["csharp","bouncycastle","buffer-overflow","crypto"],"backgroundTag":"buffer-output-length-exceeded","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}