{"record":{"id":"6d40e8675659445f","repo":"prestodb/presto","slug":"hashing-algorithm-of-password-cannot-be-determined","errorCode":null,"errorMessage":"Hashing algorithm of password cannot be determined","messagePattern":"Hashing algorithm of password cannot be determined","errorType":"validation","errorClass":"HashedPasswordException","httpStatus":null,"severity":"error","filePath":"presto-password-authenticators/src/main/java/com/facebook/presto/password/file/PasswordStore.java","lineNumber":122,"sourceCode":"    private static List<String> readPasswordFile(File file)\n    {\n        try {\n            return Files.readAllLines(file.toPath());\n        }\n        catch (IOException e) {\n            throw new PrestoException(CONFIGURATION_UNAVAILABLE, \"Failed to read password file: \" + file, e);\n        }\n    }\n\n    private static HashedPassword getHashedPassword(String hashedPassword)\n    {\n        switch (getHashingAlgorithm(hashedPassword)) {\n            case BCRYPT:\n                return password -> doesBCryptPasswordMatch(password, hashedPassword);\n            case PBKDF2:\n                return password -> doesPBKDF2PasswordMatch(password, hashedPassword);\n        }\n        throw new HashedPasswordException(\"Hashing algorithm of password cannot be determined\");\n    }\n\n    public interface HashedPassword\n    {\n        boolean matches(String password);\n    }\n}\n","sourceCodeStart":104,"sourceCodeEnd":130,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-password-authenticators/src/main/java/com/facebook/presto/password/file/PasswordStore.java#L104-L130","documentation":"PasswordStore.getHashedPassword throws HashedPasswordException(\"Hashing algorithm of password cannot be determined\") when a stored password entry does not match a recognized hash format. getHashingAlgorithm() recognizes bcrypt ($2a$/$2b$/$2y$ prefixes) and PBKDF2-WITHHMACSHAx entries; anything else (plaintext, crypt, malformed line) is rejected at load time.","triggerScenarios":"loadPasswordFile() parses each line via getHashedPassword(); a line whose prefix does not identify BCRYPT or PBKDF2 (plaintext password, crypt hash, truncated/malformed hash) triggers the exception while loading the password file.","commonSituations":"Password file generated by a tool writing plaintext or crypt-style hashes; hand-edited file with a truncated hash; migration from another system (htpasswd crypt, LDAP) without rehashing; stray comment or blank lines confusing the parser.","solutions":["Rehash the offending entry with bcrypt or PBKDF2-WORKOUT/S (e.g. htpasswd -bnBC 10) so the line has a recognizable $2x$ or PBKDF2-WITHHMACSHAx prefix","Audit every line of the password file for plaintext, crypt, or malformed entries and fix or remove them","Ensure no comment/blank/garbage lines; each line must be user:validhash","Regenerate the file entirely with supported hash tooling if many entries are invalid"],"exampleFix":"// before (password file)\nalice:plainpassword\n// after\nalice:$2y$10$DwtS8Zk0KqQXyVZ8m9nZQeJ7O1z0K0xZ4qZ8hGxWq2nKq1eK2ZKfG","handlingStrategy":"validation","validationCode":"// Validate each password-file line before loading:\nPattern ok = Pattern.compile(\"^\\\\$2[aby]\\\\$.*|^PBKDF2-WITHHMACSHA.*\");\nfor (String line : Files.readAllLines(Paths.get(passwordFile))) {\n    String hash = line.split(\":\", 2)[1];\n    if (!ok.matcher(hash).matches()) {\n        throw new IllegalStateException(\"Unsupported hash for entry: \" + line.split(\":\", 2)[0]);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    store = new FilePasswordStore(config);\n} catch (PrestoException e) {\n    if (e.getCause() instanceof HashedPasswordException) {\n        log.error(\"Unrecognized hash format in password file: %s\", e.getCause().getMessage());\n    }\n    throw e;\n}","preventionTips":["Generate entries only with bcrypt (htpasswd -bnBC) or PBKDF2-WORKOUT/S tooling","Add a CI check that lints the password file format before deploy","Do not copy crypt/MD5 entries from htpasswd or other systems; rehash them","Keep lines strictly user:hash with no comments or extra whitespace"],"tags":["hashing","password-file","format","configuration"],"backgroundTag":"unsupported-hash-format","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"}