Skip to content

in_syslog: Treat a PRI above 191 as invalid - #5635

Merged
Watson1978 merged 2 commits into
fluent:masterfrom
lbarrosby:fix-syslog-pri-range
Nov 16, 2026
Merged

Watson1978 merged 2 commits into
fluent:masterfrom
lbarrosby:fix-syslog-pri-range

Conversation

@lbarrosby

@lbarrosby lbarrosby commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:
Fixes #5632

What this PR does / why we need it:

message_handler built the tag from FACILITY_MAP[pri >> 3] without checking the range. A PRI above 191 has no facility, so the tag got an empty part. <200> gave syslog..emerg. With with_priority false, SYSLOG_REGEXP accepts any number of digits, so <1234> gave syslog..crit.

PRI must now be in 0..191, the range RFC 5424 defines. Otherwise in_syslog logs invalid syslog priority and returns. With emit_unmatched_lines true it emits the line as syslog.unmatched, the same way it handles other invalid messages.

test_space_after_input_owned_priority_preserves_input_priority_syntax used <1234> as a valid PRI. It now uses <0134> and still checks that the space after PRI makes no difference.

Tests:

  • New test_priority_out_of_range_is_unmatched (default parse and with_priority false) sends <192>, <1234> and <191>. It expects two syslog.unmatched events and then syslog.local7.debug. On master, with_priority false emits syslog..emerg and syslog..crit, and the default parse emits syslog..emerg.
  • bundle exec ruby -Ilib -Itest test/plugin/test_in_syslog.rb: 56 tests, 0 failures. test/plugin/test_parser_syslog.rb: 204 tests, 0 failures.
  • The steps from the issue with with_priority false:
master:
syslog..emerg: {"host":"host","ident":"app","message":"msg"}
syslog..crit: {"host":"host","ident":"app","message":"msg"}
syslog.local7.debug: {"host":"host","ident":"app","message":"msg"}

branch:
[warn]: invalid syslog priority data="<200>Apr 25 16:43:29 host app: msg"
[warn]: invalid syslog priority data="<1234>Apr 25 16:43:29 host app: msg"
syslog.local7.debug: {"host":"host","ident":"app","message":"msg"}

Docs Changes:
None.

Release Note:
in_syslog: Treat a PRI above 191 as invalid instead of emitting the message with an empty facility in the tag.

in_syslog built the tag from FACILITY_MAP[pri >> 3] without checking
the range. For a PRI above 191 the facility was nil, so <200> was
emitted with the tag syslog..emerg. With with_priority false, the PRI
comes from SYSLOG_REGEXP with any number of digits, so <1234> gave
syslog..crit.

RFC 5424 limits PRI to 0..191. Warn and drop such a message, or emit
it as unmatched with emit_unmatched_lines, like other invalid messages.

The space test used <1234> as a valid PRI, so it now uses <134>.

Fixes fluent#5632

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@Watson1978 Watson1978 added the bug Something isn't working label Nov 16, 2026

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

Thanks for the fix. The range check looks correct to me.

I compared master and this branch with both parser engines, with_priority true and false, message_format rfc3164, rfc5424 and auto, @type none, and severity_key/facility_key. The only change was for messages that master emitted with an empty facility in the tag. They are now rejected, as #5632 expects. They go to syslog.unmatched with emit_unmatched_lines true and are dropped otherwise. Messages with a PRI in 0..191 behave the same as on master.

I left two comments on the tests.

Comment thread test/plugin/test_in_syslog.rb Resolved
Comment thread test/plugin/test_in_syslog.rb Resolved
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@lbarrosby

Copy link
Copy Markdown
Contributor Author

Thanks. Pushed c070e5a with both suggestions:

  • The with_priority false test uses <0134>, with and without the space, so the more-than-3-digits case is back.
  • The out-of-range test uses <192> instead of <200>.

test/plugin/test_in_syslog.rb: 56 tests, 0 failures. With the lib from master, test_priority_out_of_range_is_unmatched still fails in both cases.

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

Thanks for the update. Both changes look good to me.

I ran test/plugin/test_in_syslog.rb on c070e5a: 56 tests, 0 failures. The new test still fails with the lib from master. It also fails if PRI_RANGE is 0..199. I also limited SYSLOG_REGEXP to 3 digits. Then the space-after-PRI test failed with both parser engines.

@Watson1978 Watson1978 added the backport to v1.19 We will backport this fix to the LTS branch label Nov 16, 2026
@Watson1978 Watson1978 added this to the v1.21.0 milestone Nov 16, 2026
@Watson1978
Watson1978 merged commit 0487234 into fluent:master Nov 16, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v1.19 We will backport this fix to the LTS branch bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

in_syslog: PRI values above 191 are accepted and the tag gets an empty facility

2 participants