{"record":{"id":"8b4af47937e09ce3","repo":"peass-ng/PEASS-ng","slug":"invalid-rate-value","errorCode":null,"errorMessage":"invalid rate value","messagePattern":"invalid rate value","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/KeccakDigest.cs","lineNumber":139,"sourceCode":"            switch (bitLength)\n            {\n                case 128:\n                case 224:\n                case 256:\n                case 288:\n                case 384:\n                case 512:\n                    InitSponge(1600 - (bitLength << 1));\n                    break;\n                default:\n                    throw new ArgumentException(\"must be one of 128, 224, 256, 288, 384, or 512.\", \"bitLength\");\n            }\n        }\n\n        private void InitSponge(int rate)\n        {\n            if (rate <= 0 || rate >= 1600 || (rate & 63) != 0)\n                throw new InvalidOperationException(\"invalid rate value\");\n\n            this.rate = rate;\n            Array.Clear(state, 0, state.Length);\n            Arrays.Fill(this.dataQueue, (byte)0);\n            this.bitsInQueue = 0;\n            this.squeezing = false;\n            this.fixedOutputLength = (1600 - rate) >> 1;\n        }\n\n        protected void Absorb(byte data)\n        {\n            if ((bitsInQueue & 7) != 0)\n                throw new InvalidOperationException(\"attempt to absorb with odd length queue\");\n            if (squeezing)\n                throw new InvalidOperationException(\"attempt to absorb while squeezing\");\n\n            dataQueue[bitsInQueue >> 3] = data;\n            if ((bitsInQueue += 8) == rate)","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/KeccakDigest.cs#L121-L157","documentation":"InitSponge computes the sponge rate as 1600 - 2*bitLength and requires it to be positive, below 1600, and 64-bit aligned. A rate violating this invariant leaves the Keccak permutation operating on inconsistent parameters, so InitSponge throws InvalidOperationException.","triggerScenarios":"InitSponge(rate) called (from Init/constructor paths) with a bitLength that yields rate <= 0, rate >= 1600, or a rate not divisible by 64 — e.g. bitLength >= 800 or a bitLength producing a non-aligned rate. Only reachable if Init's case switch was bypassed or a subclass passes odd bitLengths.","commonSituations":"Subclassing KeccakDigest with a custom fixedBitLength not in the supported set; forks that relaxed the constructor check; bitLength of 0 or negative from config defaults.","solutions":["Use only standard Keccak bit lengths (128/224/256/288/384/512) so the computed rate is always valid.","If subclassing, ensure bitLength yields 1600 - 2*bitLength in (0, 1600) and 64-byte aligned.","Fix any modified library code so Init's allow-list runs before InitSponge."],"exampleFix":"// before\nclass CustomKeccak : KeccakDigest { public CustomKeccak() : base(800) { } } // rate = 0\n// after\nclass CustomKeccak : KeccakDigest { public CustomKeccak() : base(256) { } } // rate = 1088","handlingStrategy":"validation","validationCode":"int rate = 1600 - (bitLength << 1);\nif (rate <= 0 || rate >= 1600 || (rate & 63) != 0)\n    throw new ArgumentOutOfRangeException(nameof(bitLength), \"bitLength yields invalid sponge rate\");\nvar keccak = new KeccakDigest(bitLength);","typeGuard":"static bool HasValidRate(int bitLength) { int r = 1600 - (bitLength << 1); return r > 0 && r < 1600 && (r & 63) == 0; }","tryCatchPattern":"try { k.BlockUpdate(data, 0, len); }\ncatch (InvalidOperationException ex) { /* recreate with standard bitLength */ }","preventionTips":["Stick to standard Keccak lengths so rate is always valid","Verify rate math when subclassing KeccakDigest","Reject non-standard bitLengths at configuration time"],"tags":["csharp","cryptography","invalid-operation","keccak"],"backgroundTag":"invalid-sponge-rate","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}