Skip to content

Dev/new pattern sshd logs for synology#1798

Open
lachapette wants to merge 7 commits into
crowdsecurity:masterfrom
lachapette:dev/new-pattern-sshd-logs-for-synology
Open

Dev/new pattern sshd logs for synology#1798
lachapette wants to merge 7 commits into
crowdsecurity:masterfrom
lachapette:dev/new-pattern-sshd-logs-for-synology

Conversation

@lachapette
Copy link
Copy Markdown

@lachapette lachapette commented May 13, 2026

Description

Add Synology-specific patterns and tests for invalid user authentication (SSH and DSM logs API)

Impact: Enhances detection of brute force attacks on Synology devices (SSH and DSM API) with patterns specific to Synology DSM 7.x log formats.

1. SSH Parser (sshd-logs.yaml)

New pattern for Synology DSM 7.x:

  • Added Pattern: SSHD_INVALID_USER_SYNO: 'pam_%{DATA:pam_type}(sshd:auth): Can.t get user uid (%{USERNAME: sshd_invalid_user})'
    • Associated grok node with metadata:
      • log_type: ssh_failed-auth
      • target_user: evt.Parsed.sshd_invalid_user
    • Example log covered:
      • pam_syno_log_fail(sshd:auth): Can't get user uid (zm)

2. DSM Parser (synology-dsm-logs.yaml)

Updated Pattern:

  • Old: AUTH_LOG_FAIL: 'pam_unix(webui:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=%{IP_WORKAROUND:src_ip}'
  • New: Added (\s+user=%{USERNAME:sshd_invalid_user})? to capture the username
  • Example log covered:
    • pam_unix(webui:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=10.4.2.116 user=admin

3. New Scenario

synology-dsm-bf-slow-1h.yaml:

  • Type: leaky
  • Filter: evt.Meta.log_type == 'synology-dsm_failed_auth'
  • Strategy: Slow detection over 1 hour (leakspeed: "1h", capacity: 10)
  • Group by: source_ip
  • Blackhole: 10h
  • Added to the crowdsecurity/synology-dsm collection

4. Tests Added

Component Files created Lines
SSH BF Tests config.yaml, parser.assert (760 lines), scenario.assert, synology-dsm-ssh-bf.log (21 lines) 802+
DSM Slow Tests config.yaml, parser.assert (829 lines), scenario.assert (49 lines), synology-dsm-logs-bf-slow.log (61 lines) 952+
Existing DSM Tests Updated parser.assert (+65 lines) and synology-dsm-logs.log (+5 lines) 71+

Checklist

  • I have read the contributing guide
  • I have tested my changes locally
  • For new parsers or scenarios, tests have been added
  • I have run the hub linter and no issues were reported (see contributing guide)
  • Automated tests are passing
  • AI was used to generate any/all content of this PR

@lachapette
Copy link
Copy Markdown
Author

lachapette commented May 13, 2026

@crowdsecurity/team-hub , @dimatha , @maximelouet , @buixor , @sabban Could you please review this PR ?

@lachapette lachapette force-pushed the dev/new-pattern-sshd-logs-for-synology branch 3 times, most recently from 12f3e98 to b002c0d Compare May 14, 2026 13:18
actions-user and others added 7 commits May 14, 2026 16:15
…ynology machines

- Add a pattern log detection into sshd parser and scenario SSH BF specific to invalid users Synology DSM 7.x logs formats
- Updated a pattern log detection into synology-dsm-logs parser specific to invalid users Synology DSM 7.x logs formats
@lachapette lachapette force-pushed the dev/new-pattern-sshd-logs-for-synology branch from b002c0d to 560f448 Compare May 14, 2026 14:15
state: open
- name: Comment PR if errors
if: ${{ (env.taxonomy_errors == '1') && (github.event_name == 'push') && (github.ref != 'refs/heads/master') }}
if: ${{ (env.taxonomy_errors == '1') && (github.event_name == 'push') && (github.ref != 'refs/heads/master') && (steps.findPr.outputs.pr != 'false') }}
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.

Unrelated change ?

state: open
- name: Comment PR if errors
if: ${{ (env.taxonomy_errors == '1') && (github.event_name == 'push') && (github.ref != 'refs/heads/master') }}
if: ${{ (env.taxonomy_errors == '1') && (github.event_name == 'push') && (github.ref != 'refs/heads/master') && (steps.findPr.outputs.pr != 'false') }}
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.

Unrelated change ?

@@ -0,0 +1 @@
len(results) == 0 No newline at end of file
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.

This file being empty for a scenario test likely means your scenario did not work as expected.

SSHD_AUTH_FAIL: 'pam_%{DATA:pam_type}\(sshd:auth\): authentication failure; logname= uid=%{NUMBER:uid}? euid=%{NUMBER:euid}? tty=ssh ruser= rhost=%{IP_WORKAROUND:sshd_client_ip}( %{SPACE}user=%{USERNAME:sshd_invalid_user})?'
SSHD_MAGIC_VALUE_FAILED: 'Magic value check failed \(\d+\) on obfuscated handshake from %{IP_WORKAROUND:sshd_client_ip} port \d+'
SSHD_INVALID_USER: 'Invalid user\s*%{USERNAME:sshd_invalid_user}? from %{IP_WORKAROUND:sshd_client_ip}( port \d+)?'
SSHD_INVALID_USER_SYNO: 'pam_%{DATA:pam_type}\(sshd:auth\): Can.t get user uid \(%{USERNAME:sshd_invalid_user}\)'
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 like there's a typo in the pattern: can.t vs can't.

The logs you provided for the tests are using can't.

expression: "evt.Parsed.src_ip"
- meta: service
value: synology-dsm
- meta: source_ip
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.

Don't move the statics, if we ever add another pattern in the file, we would need to move them back on top level

@@ -0,0 +1,18 @@
# Synology DSM auth.log bruteforce
type: leaky
name: crowdsecurity/synology-dsm-bf-slow-1h
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.

Don't use the crowdsecurity namespace.

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.

Unrelated changes

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.

Unrelated changes

Comment thread .gitignore
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.

Unrelated changes

Comment thread README.md
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.

Unrelated change

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