prestodb/presto · error · HashedPasswordException
Hashing algorithm of password cannot be determined
Error message
Hashing algorithm of password cannot be determined
What it means
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.
Source
Thrown at presto-password-authenticators/src/main/java/com/facebook/presto/password/file/PasswordStore.java:122
private static List<String> readPasswordFile(File file)
{
try {
return Files.readAllLines(file.toPath());
}
catch (IOException e) {
throw new PrestoException(CONFIGURATION_UNAVAILABLE, "Failed to read password file: " + file, e);
}
}
private static HashedPassword getHashedPassword(String hashedPassword)
{
switch (getHashingAlgorithm(hashedPassword)) {
case BCRYPT:
return password -> doesBCryptPasswordMatch(password, hashedPassword);
case PBKDF2:
return password -> doesPBKDF2PasswordMatch(password, hashedPassword);
}
throw new HashedPasswordException("Hashing algorithm of password cannot be determined");
}
public interface HashedPassword
{
boolean matches(String password);
}
}
View on GitHub (pinned to 55bb57d202)
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
Example fix
// before (password file) alice:plainpassword // after alice:$2y$10$DwtS8Zk0KqQXyVZ8m9nZQeJ7O1z0K0xZ4qZ8hGxWq2nKq1eK2ZKfG
Defensive patterns
Strategy: validation
Validate before calling
// Validate each password-file line before loading:
Pattern ok = Pattern.compile("^\\$2[aby]\\$.*|^PBKDF2-WITHHMACSHA.*");
for (String line : Files.readAllLines(Paths.get(passwordFile))) {
String hash = line.split(":", 2)[1];
if (!ok.matcher(hash).matches()) {
throw new IllegalStateException("Unsupported hash for entry: " + line.split(":", 2)[0]);
}
} Try / catch
try {
store = new FilePasswordStore(config);
} catch (PrestoException e) {
if (e.getCause() instanceof HashedPasswordException) {
log.error("Unrecognized hash format in password file: %s", e.getCause().getMessage());
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/6d40e8675659445f.
Report an issue: GitHub.