{"record":{"id":"4b9b7dd55479755d","repo":"prestodb/presto","slug":"invalid-bcrypt-password","errorCode":null,"errorMessage":"Invalid BCrypt password","messagePattern":"Invalid BCrypt password","errorType":"validation","errorClass":"HashedPasswordException","httpStatus":null,"severity":"error","filePath":"presto-password-authenticators/src/main/java/com/facebook/presto/password/file/EncryptionUtil.java","lineNumber":49,"sourceCode":"import static com.google.common.io.BaseEncoding.base16;\nimport static java.nio.charset.StandardCharsets.UTF_8;\nimport static java.util.Objects.requireNonNull;\n\npublic final class EncryptionUtil\n{\n    private static final Logger LOG = Logger.get(EncryptionUtil.class);\n    private static final int BCRYPT_MIN_COST = 8;\n    private static final int PBKDF2_MIN_ITERATIONS = 1000;\n\n    private EncryptionUtil() {}\n\n    public static int getBCryptCost(String password)\n    {\n        try {\n            return BCrypt.Version.VERSION_2A.parser.parse(password.getBytes(UTF_8)).cost;\n        }\n        catch (IllegalBCryptFormatException e) {\n            throw new HashedPasswordException(\"Invalid BCrypt password\", e);\n        }\n    }\n\n    public static int getPBKDF2Iterations(String password)\n    {\n        return PBKDF2Password.fromString(password).iterations();\n    }\n\n    public static boolean doesBCryptPasswordMatch(String inputPassword, String hashedPassword)\n    {\n        return BCrypt.verifyer().verify(inputPassword.toCharArray(), hashedPassword).verified;\n    }\n\n    /**\n     * @Deprecated using PBKDF2WithHmacSHA1 is deprecated and clients should switch to PBKDF2WithHmacSHA256\n     */\n    public static boolean doesPBKDF2PasswordMatch(String inputPassword, String hashedPassword)\n    {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-password-authenticators/src/main/java/com/facebook/presto/password/file/EncryptionUtil.java#L31-L67","documentation":"Catch block in getBCryptCost: the stored password string cannot be parsed as a version-2A BCrypt hash, so its cost factor cannot be extracted. Fires when the password file entry marked $2y is malformed or truncated; wrapped as HashedPasswordException for the authenticator.","triggerScenarios":"Thrown at presto-password-authenticators/src/main/java/com/facebook/presto/password/file/EncryptionUtil.java:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the password entry with a valid BCrypt hash in $2y format","Verify the password file is not corrupted or hand-edited","Log and skip the malformed entry rather than failing the whole file load"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}