Hi hackers,

  When a login fails with LDAP search+bind authentication, the
  ldapbindpasswd value from pg_hba.conf is written to the server log in
  plaintext.

  auth_failed() adds a detail line that quotes the matching pg_hba.conf
  line verbatim.  For a search+bind line, that includes the bind
  password:

    DETAIL:  Connection matched file "/home/edb/edbdata/pg_hba.conf" line
    119: "host all test1 127.0.0.1/32 ldap ldapserver=127.0.0.1
    ldapport=3890 ldapbasedn="dc=example,dc=net"
    ldapbinddn="cn=Manager,dc=example,dc=net" ldapbindpasswd=secret
    ldapsearchattribute=uid"

  (Wrapped here for readability; it is a single line in the log.)

 The attached patch changes this narrowly.  If the matched line uses
  LDAP and has ldapbindpasswd set, the detail names only the file and
  line number:

    DETAIL:  Connection matched file "/home/edb/edbdata/pg_hba.conf" line
    119

All other lines, including LDAP lines without a bind password, are
logged exactly as before, so their messages and translations are
unchanged.

Successful LDAP logins do not have this problem: with log_connections
enabled they log only the file name and line number, for example:

    LOG:  connection authenticated: identity="uid=test1,dc=example,dc=net"
    method=ldap (/home/edb/edbdata/pg_hba.conf:119)

  So only the authentication-failure path is affected.

  Shall we omit the line text, as this patch does, or log it with the
  secret masked?

Thanks & Best Regards,
Ajit

Attachment: 0001-Don-t-log-ldapbindpasswd-in-the-Connection-matched-d.patch
Description: Binary data

Reply via email to