{"record":{"id":"3984a2426eb66dd2","repo":"gchq/CyberChef","slug":"no-s-value-in-the-signature-json","errorCode":null,"errorMessage":"No \"s\" value in the signature JSON","messagePattern":"No \"s\" value in the signature JSON","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ECDSASignatureConversion.mjs","lineNumber":115,"sourceCode":"            case \"Auto\":\n                throw new OperationError(\"Signature format could not be detected\");\n            case \"ASN.1 HEX\":\n                signatureASN1Hex = input;\n                break;\n            case \"P1363 HEX\":\n                signatureASN1Hex = r.KJUR.crypto.ECDSA.concatSigToASN1Sig(input);\n                break;\n            case \"JSON Web Signature\":\n                if (!inputBase64) inputBase64 = fromBase64(input, \"A-Za-z0-9-_\");\n                signatureASN1Hex = r.KJUR.crypto.ECDSA.concatSigToASN1Sig(toHexFast(inputBase64));\n                break;\n            case \"Raw JSON\": {\n                if (!inputJson) inputJson = JSON.parse(input);\n                if (!inputJson.r) {\n                    throw new OperationError('No \"r\" value in the signature JSON');\n                }\n                if (!inputJson.s) {\n                    throw new OperationError('No \"s\" value in the signature JSON');\n                }\n                signatureASN1Hex = r.KJUR.crypto.ECDSA.hexRSSigToASN1Sig(inputJson.r, inputJson.s);\n                break;\n            }\n        }\n\n        // convert ASN.1 hex to output format\n        let result;\n        switch (outputFormat) {\n            case \"ASN.1 HEX\":\n                result = signatureASN1Hex;\n                break;\n            case \"P1363 HEX\":\n                result = r.KJUR.crypto.ECDSA.asn1SigToConcatSig(signatureASN1Hex);\n                break;\n            case \"JSON Web Signature\":\n                result = r.KJUR.crypto.ECDSA.asn1SigToConcatSig(signatureASN1Hex);\n                result = toBase64(fromHex(result), \"A-Za-z0-9-_\");  // base64url","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ECDSASignatureConversion.mjs#L97-L133","documentation":"Thrown in ECDSASignatureConversion.run, Raw JSON branch, after the r check passed but inputJson.s is falsy. Companion to the r guard: a raw-JSON ECDSA signature needs both scalars, and a missing s is caught right after r is confirmed.","triggerScenarios":"Input Format resolved to Raw JSON and the JSON has a valid r but no s - e.g. {\"r\":\"...\"} or {\"r\":\"...\",\"sig\":\"...\"} where the second scalar is under a different key.","commonSituations":"Truncated JSON missing the trailing s; a field named differently by the producing tool ('S' uppercase, 'sValue'); only the r half of a split signature was serialised.","solutions":["Ensure the JSON contains a lowercase 's' hex string alongside 'r': {\"r\":\"...\",\"s\":\"...\"}.","Rename mismatched field names from your source data before input.","Re-extract both scalars from the original signature if only one was captured."],"exampleFix":"// before\nrun('{\"r\":\"bb...\"}', ['Raw JSON', ...]);  // missing s\n// after\nrun('{\"r\":\"bb...\",\"s\":\"a3...\"}', ['Raw JSON', ...]);","handlingStrategy":"validation","validationCode":"const o = JSON.parse(sig);\nif (!o || typeof o !== \"object\" || !o.s) throw new Error(\"signature JSON needs an 's' field\");","typeGuard":"const hasS = (o) => o != null && typeof o === \"object\" && Object.prototype.hasOwnProperty.call(o, \"s\");","tryCatchPattern":null,"preventionTips":["Serialise both r and s together; never split them across files.","Validate both scalars exist before building the recipe JSON."],"tags":["crypto","ecdsa","signature","json","operation-error"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}