{"record":{"id":"38765ecbed7eaf69","repo":"alibaba/spring-ai-alibaba","slug":"invalid-parallel-parameter","errorCode":null,"errorMessage":"Invalid parallel parameter","messagePattern":"Invalid parallel parameter","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/utils/security/PasswordCryptUtils.java","lineNumber":118,"sourceCode":"\t\t\tint version = Integer.parseInt(parts[0].substring(2));\n\t\t\tbuilder.withVersion(version);\n\t\t}\n\n\t\tString[] perfParams = parts[3].split(\",\");\n\t\tif (perfParams.length != 3) {\n\t\t\tthrow new IllegalArgumentException(\"Amount of performance parameters invalid\");\n\t\t}\n\n\t\tif (!perfParams[0].startsWith(\"m=\")) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid memory parameter\");\n\t\t}\n\t\tbuilder.withMemoryAsKB(Integer.parseInt(perfParams[0].substring(2)));\n\t\tif (!perfParams[1].startsWith(\"t=\")) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid iterations parameter\");\n\t\t}\n\t\tbuilder.withIterations(Integer.parseInt(perfParams[1].substring(2)));\n\t\tif (!perfParams[2].startsWith(\"p=\")) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid parallel parameter\");\n\t\t}\n\t\tbuilder.withParallelism(Integer.parseInt(perfParams[2].substring(2)));\n\n\t\tbuilder.withSalt(b64decoder.decode(parts[4]));\n\n\t\tbyte[] decoded = b64decoder.decode(parts[5]);\n\t\tbyte[] hashBytes = new byte[decoded.length];\n\n\t\tArgon2BytesGenerator generator = new Argon2BytesGenerator();\n\t\tgenerator.init(builder.build());\n\t\tgenerator.generateBytes(password.toCharArray(), hashBytes);\n\n\t\tint result = 0;\n\t\tfor (int i = 0; i < decoded.length; i++) {\n\t\t\tresult |= decoded[i] ^ hashBytes[i];\n\t\t}\n\t\treturn result == 0;\n\t}","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/utils/security/PasswordCryptUtils.java#L100-L136","documentation":"In PasswordCryptUtils.match(), the third performance parameter of the stored Argon2 hash must start with 'p=' to supply the parallelism factor. When perfParams[2] lacks the 'p=' prefix, match() throws this IllegalArgumentException.","triggerScenarios":"Calling match(rawPassword, storedHash) where the hash's parameter segment's third item is not prefixed with 'p=' (e.g. 'm=65536,t=2,par=1').","commonSituations":"Hashes serialized by a non-standard Argon2 implementation, hand-edited credentials, or corrupted hash strings after copying between environments.","solutions":["Check parts[3] of the stored hash and fix the third parameter to 'p=<parallelism>'","Regenerate the password hash with PasswordCryptUtils.encode() to guarantee the canonical format","Add a format check (regex on m=,t=,p=) before persisting hashes to catch bad formats at write time"],"exampleFix":"// before\nm=65536,t=2,par=1\n// after\nm=65536,t=2,p=1","handlingStrategy":"validation","validationCode":"String perfSeg = storedHash.split(\"\\\\$\")[3];\nboolean hasP = perfSeg.split(\",\")[2].startsWith(\"p=\");\nif (!hasP) throw new IllegalStateException(\"Hash missing p= parallelism param: \" + perfSeg);","typeGuard":"static boolean hasParallelismParam(String hash) {\n    String[] parts = hash.split(\"\\\\$\");\n    if (parts.length < 4) return false;\n    String[] perf = parts[3].split(\",\");\n    return perf.length == 3 && perf[2].startsWith(\"p=\");\n}","tryCatchPattern":"try {\n    cryptUtils.match(rawPassword, storedHash);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Hash parallelism param invalid: {}\", e.getMessage());\n    throw new AuthenticationException(\"Credential format invalid\");\n}","preventionTips":["Verify hash format against the PHC spec before storing","Use one canonical Argon2 serialization library across services","Add startup smoke test: encode then match a known password"],"tags":["security","password-hashing","argon2","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}