Skip to content

Add MD5 authentication support#122

Draft
EDsCODE wants to merge 1 commit intomainfrom
feature/modern-auth
Draft

Add MD5 authentication support#122
EDsCODE wants to merge 1 commit intomainfrom
feature/modern-auth

Conversation

@EDsCODE
Copy link
Contributor

@EDsCODE EDsCODE commented Jan 30, 2026

Summary

  • Implements PostgreSQL MD5 password authentication
  • Alternative to cleartext auth (both protected by TLS)

Changes

  • Add AuthMethod config type with "cleartext" (default) and "md5" options
  • Add writeAuthMD5Password() to send 4-byte random salt
  • Add verifyMD5Password() to validate MD5 hash response
  • Add auth_method YAML config and DUCKGRES_AUTH_METHOD env var

MD5 Auth Flow

  1. Server generates random 4-byte salt
  2. Server sends AuthenticationMD5Password message with salt
  3. Client computes: "md5" + md5(md5(password + username) + salt)
  4. Server verifies the hash matches

Configuration

auth_method: "md5"  # or via DUCKGRES_AUTH_METHOD=md5

Test plan

  • Set auth_method to md5, connect with psql - should authenticate
  • Verify wrong password fails authentication
  • Verify cleartext still works as default

🤖 Generated with Claude Code


expected := "md5" + outerHex
return clientResponse == expected
}

Check failure

Code scanning / CodeQL

Use of a broken or weak cryptographic hashing algorithm on sensitive data High

Sensitive data (password)
is used in a hashing algorithm (MD5) that is insecure for password hashing, since it is not a computationally expensive hash function.
Implements PostgreSQL MD5 password authentication as an alternative to
cleartext (both protected by TLS):
- New AuthMethod config field ("cleartext" default, "md5")
- writeAuthMD5Password sends 4-byte random salt to client
- verifyMD5Password validates md5(md5(password + username) + salt)
- DUCKGRES_AUTH_METHOD env var and auth_method YAML config support
- Cleartext remains default for backwards compatibility

The MD5 auth flow:
1. Server generates random salt, sends AuthenticationMD5Password
2. Client computes "md5" + md5(md5(password+username) + salt)
3. Server verifies the hash matches

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@EDsCODE EDsCODE force-pushed the feature/modern-auth branch from 402cdb0 to 3bc943f Compare January 30, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant