SSH parser: incomplete handling of IPv4-mapped IPv6 addresses and SSH authentication log formats
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by reviewing the SSH parser expressions named in the issue: SSHD_AUTH_FAIL, SSHD_INVALID_USER, SSHD_INVALID_USER_ALT, SSHD_AUTH_TIMEOUT, and SSHD_BAD_VERSION. Compare the supplied reproduction messages and proposed patterns, then check how source addresses are extracted and whether normalization belongs in this parser or another stage. Done means the relevant valid SSH messages parse complete addresses, invalid inputs remain rejected, and regression coverage confirms the behavior.
Written by the indexing model from the issue text.
Description
Summary
During an investigation of SSH log parsing on a Proxmox VE host, we identified several inconsistencies in the CrowdSec SSH parser.
The issues primarily concern:
Recognition of IPv4-mapped IPv6 addresses, including uppercase ::FFFF: notation.
Missing end-of-address boundaries in selected parser expressions.
Parsing of SSH messages reporting invalid protocol version identification.
These issues can cause valid SSH security events to be missed or incorrectly parsed, potentially affecting brute-force detection.
We developed a local parser correction (V1.2) and evaluated it against regression and extended coverage datasets.
Environment
CrowdSec security engine running on Proxmox VE
OpenSSH server (sshd)
Central CrowdSec LAPI hosted on OPNsense
Distributed CrowdSec firewall bouncers
SSH parser: crowdsecurity/sshd-logs
Local parser correction: V1.2
- IPv4-mapped IPv6 addresses
Problem
The original parser defines the following address pattern:
IP_WORKAROUND: (?:%{IPV6}|%{IPv4_WORKAROUND})
This does not reliably handle every IPv4-mapped IPv6 representation encountered in our test cases.
For example:
::FFFF:198.51.100.151
Proposed correction
IP_WORKAROUND: (?:(?i:::ffff:)%{IPv4_WORKAROUND}|%{IPV6}|%{IPv4_WORKAROUND})
The additional alternative explicitly recognizes IPv4-mapped IPv6 addresses, including case variations.
Example log entry:
2026-11-16T20:37:38+01:00 testhost sshd[50033]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=::FFFF:198.51.100.151
The address should be recognized completely rather than partially matched or rejected.
For detection purposes, equivalent IPv4 and IPv4-mapped IPv6 representations should also be normalized consistently.
Note: Address extraction and address normalization are separate concerns. Our functional verification used both the corrected SSH parser and a local normalization stage. The attached parser patch addresses extraction; it is not, by itself, a complete normalization implementation.
- Missing address boundaries
Problem
Several existing SSH parser expressions do not explicitly require an appropriate boundary after a captured source address.
Depending on the surrounding input, this can permit partial matches or otherwise incorrect extraction.
Proposed correction
We added:
(?:[[:space:]]|$)
to selected expressions.
The affected patterns include:
SSHD_AUTH_FAIL
SSHD_INVALID_USER
SSHD_INVALID_USER_ALT
SSHD_AUTH_TIMEOUT
This requires the captured address to be followed by whitespace or the end of the message.
- Invalid SSH protocol version messages
Problem
We identified a parsing issue involving messages such as:
Bad protocol version identification 'TEST-PROTOCOL' from 198.51.100.151
and:
Bad protocol version identification 'TEST-PROTOCOL' from ::FFFF:198.51.100.151
Proposed correction
Our local candidate introduces the following expression:
SSHD_BAD_VERSION_LOCAL: "Bad protocol version identification '%{GREEDYDATA}' from %{IP_WORKAROUND:sshd_client_ip}(?:[[:space:]]|$)"
The corresponding grok node uses SSHD_BAD_VERSION_LOCAL instead of SSHD_BAD_VERSION.
This allows the tested message variants to be parsed using the corrected address expression.
We recognize that the maintainers may prefer to modify the existing shared pattern rather than introduce a local replacement.
- Regression testing
We compared the original parser against the locally corrected V1.2 candidate.
Test suite
Original parser
Corrected V1.2
Regression tests
125/158
158/158
Extended coverage
770/900
900/900
The extended test suite covered 18 groups.
Results for the corrected candidate:
540/540 expected valid events accepted.
360/360 expected invalid events rejected.
No failures in the recorded regression dataset.
These results describe our local test corpus, not an exhaustive validation of every SSH log format supported by CrowdSec.
- Functional detection test
We also performed an isolated functional test using six SSH authentication failures.
The test alternated between the following representations of the same source:
192.0.2.239
::ffff:192.0.2.239
With the corrected parser and local address normalization, CrowdSec associated the events with one source and generated a single crowdsecurity/ssh-bf alert.
The test was conducted in an isolated environment without modifying production firewall decisions.
- Expected behavior
We expect the SSH parsing pipeline to:
Recognize valid IPv4, IPv6 and IPv4-mapped IPv6 source addresses completely.
Avoid partial address matches.
Recognize supported SSH authentication and protocol-error messages.
Normalize equivalent source addresses consistently before detection aggregation.
Continue rejecting invalid input.
- Proposed fix and supporting evidence
We have prepared a sanitized review package containing:
The original SSH parser.
The locally corrected V1.2 parser.
A unified diff.
Synthetic reproduction examples.
A summary of the regression and functional test results.
The package excludes credentials, private infrastructure details, full system logs and firewall snapshots.
The patch is offered as a starting point for review rather than a claim that the proposed implementation is the only appropriate upstream solution.
We would appreciate feedback on whether these changes should be implemented in the SSH parser itself, shared grok patterns, or the address-normalization stage.
- Related issues
We identified several potentially related reports:
crowdsecurity/hub#1458 — SSH parser missing pattern.
crowdsecurity/hub#1880 — Missing OpenSSH patterns.
crowdsecurity/hub#1952 — Duplicate SSH events.
crowdsecurity/crowdsec#938 — IP grok pattern.
Our report focuses specifically on IPv4-mappe
d IPv6 handling, address boundaries and the tested SSH protocol-error formats.
- Disclosure
This investigation was conducted collaboratively by a homelab administrator and an AI assistant.
The AI assistant supported the analysis, test development, interpretation of results and documentation.
The reported test results originate from actual executions in the test environment.
We are happy to provide further sanitized reproduction cases or adapt the patch to the project's contribution guidelines.
Thank you for maintaining CrowdSec and for considering this report.
- Dominant language
- Python
- Stars
- 257
- Forks
- 235
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crowdsecurity/hub
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
crowdsecurity/hub#2020 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
crowdsecurity/hub#2009 ·
Maintainers usually reply within 1 day
-
The Authelia parser (v0.9) doesn't classify `Unsuccessful 1FA authentication attempt by user ''`Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
crowdsecurity/hub#2001 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
crowdsecurity/hub#1999 ·
Maintainers usually reply within 1 day
-
Time format with time zone in Home Assistant parserPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
crowdsecurity/hub#1998 · 6 comments ·
Maintainers usually reply within 1 day
All issues in crowdsecurity/hub
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 62/100
DaoCloud/DaoCloud-docs#7839 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
sav-oss-org/ptusa_main#1610 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug status/accepted type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/apm#4925 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sagemathinc/sagebrush#1701 ·
Maintainers usually reply within 1 day