Skip to content

postgres_proxy: fix partial initial message leaking to upstream - #46776

Open
tsaarni wants to merge 2 commits into
envoyproxy:mainfrom
Nordix:fix/postgres-proxy-partial-forward
Open

postgres_proxy: fix partial initial message leaking to upstream#46776
tsaarni wants to merge 2 commits into
envoyproxy:mainfrom
Nordix:fix/postgres-proxy-partial-forward

Conversation

@tsaarni

@tsaarni tsaarni commented Aug 18, 2026

Copy link
Copy Markdown
Member

Commit Message: postgres_proxy: fix partial initial message leaking to upstream

Additional Description:

Before this PR the postgres_proxy filter forwarded partial bytes of the initial message (SSLRequest or Startup) to upstream when the message arrives split across multiple onData() calls. The upstream PostgreSQL server received an incomplete message fragment and logs an error.

This PR changes the decoder logic to return Stopped when processing incomplete initial message, which avoids forwarding the incomplete data to the next filter. The filter drains the connection buffer and waits for more data.

Risk Level: Low
Testing: Unit tests were added.
Release Notes: Fixed the postgres_proxy filter forwarding incomplete initial message bytes to upstream when the message arrives in multiple TCP segments, causing PostgreSQL to reject the connection.

Fixes #46774

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

@fabriziomello fabriziomello left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@tsaarni

tsaarni commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

/retest

@agrawroh agrawroh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks okay to me but I'd still let @cpakulski take a look to make sure we have not missed any edge cases.

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.

postgres_proxy: partial initial message bytes forwarded to upstream before fully decoded

4 participants