Skip to content

Don't keep the password in connect state after authentication - #807

Closed
Don-Yin wants to merge 1 commit into
elixir-ecto:masterfrom
Don-Yin:drop-password-after-auth
Closed

Don-Yin wants to merge 1 commit into
elixir-ecto:masterfrom
Don-Yin:drop-password-after-auth

Conversation

@Don-Yin

@Don-Yin Don-Yin commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

The connect state keeps the password in opts after authentication, so when the NotificationResponse in #806 crashes the connection, the MatchError puts the password in the crash log. I drop the password once authentication succeeds and left the notification crash itself alone. Fixes the second point of #806.

password no longer in the crash log

Signed-off-by: Don Yin <Don_Yin@outlook.com>
Comment thread lib/postgrex/protocol.ex
buffer
)
else
status = %{status | opts: Keyword.delete(status.opts, :password)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

💡 One suggestion: the password is not the only secret in the connect state. status.ssl can hold the client private key and its passphrase, and status.opts also has the username, hostname and database, which DBConnection treats as sensitive.

Suggested change
status = %{status | opts: Keyword.delete(status.opts, :password)}
status = Map.drop(status, [:opts, :ssl])

@josevalim josevalim closed this in 87afeb9 Oct 31, 2026
@josevalim

Copy link
Copy Markdown
Member

THank you, I pushed a fix based on this one. The test made the bug something we assert on, and if we fix that in other ways, then the test is wrong, so I went with a simpler fix.

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.

3 participants