Skip to content

Aggregate HA proxy line before parsing it - #286

Merged
andsel merged 7 commits into
logstash-plugins:mainfrom
andsel:fix/aggregate_proxy_line_before_parsing
Sep 7, 2026
Merged

Aggregate HA proxy line before parsing it#286
andsel merged 7 commits into
logstash-plugins:mainfrom
andsel:fix/aggregate_proxy_line_before_parsing

Conversation

@andsel

@andsel andsel commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Release notes

Fix for processing the HA Proxy protocol, considering the line can be splitted in multiple buffers.

What does this PR do?

Adds an aggregator to collect all the bytes up to the first newline before move on to the decoding part done by DecoderImpl class. This message decoder is added only if proxy setting is enabled.

Why is it important/What is the impact to the user?

Avoids error that could rise if the TCP stack decides to break the HA Proxy v1 headline before the newline terminator in multiple byte arrays.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

@andsel andsel self-assigned this Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Changelog and Version Management

No changelog or version changes detected. You can either update them manually or use a comment command to update them automatically on merge:

/pr_prepare release:<patch|minor|major> — bump version + update changelog
/pr_prepare changelog:add — changelog entry only (no version bump)

/pr_prepare release:patch
- Add the changelog entry here
  - (Additional details can be provided in multiple lines, respecting markdown formatting)

Omit the entry line to use the PR title. If multiple commands are posted, the last one wins.

@andsel

andsel commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Note for reviewer

  • the commit c361409 clearly made evident the problem with partial processing of HA proxy header, when a non complete line is parsed by DecoderImpl it return a nil that crashes the processing making the pop block on something that is never sent. The commit add also a timeout to the Queue.pop operation to avoid waiting indefinitely. This is 🔴 CI
  • the commit ea983d5 enable the ProxyLineAgrgeagtor plus another fix needed to correctly identify the sequence of \r\n in the ByteBuf. This is 🟢 CI

@donoghuc donoghuc 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.

Take or leave some of these (especially the LLM one), i'll put a request change on this until we decide. But overall this is cool to see our tests catching this kind of bug!

Comment thread spec/inputs/tcp_spec.rb Outdated
Comment thread src/main/java/org/logstash/tcp/InputLoop.java
Comment thread src/main/java/org/logstash/tcp/ProxyLineAggregator.java
andsel and others added 2 commits September 4, 2026 08:45
Co-authored-by: Cas Donoghue <cas.donoghue@gmail.com>
…he proxy, it's passed through and the handler removes itself from the channel's pipeline
@andsel
andsel requested a review from donoghuc September 4, 2026 08:22

@donoghuc donoghuc 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. Looks like we will want a release. just need a pr_prepare comment!

@andsel

andsel commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

/pr_prepare release:patch

  • Fix for processing the HA Proxy protocol, considering the line can be split in multiple buffers.

@andsel
andsel merged commit 798a681 into logstash-plugins:main Sep 7, 2026
11 checks passed
github-actions Bot added a commit that referenced this pull request Sep 7, 2026
andsel added a commit that referenced this pull request Sep 7, 2026
Avoids error that could rise if the TCP stack decides to break the HA Proxy v1 headline before the newline terminator in multiple byte arrays.

Adds an aggregator to collect all the bytes up to the first newline before move on to the decoding part done by DecoderImpl class. This message decoder is added only if proxy setting is enabled.

Co-authored-by: Cas Donoghue <cas.donoghue@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy protocol erroneously parsed

2 participants