@profullstack/threatcrush 0.12.4 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/daemon.js CHANGED
@@ -8530,8 +8530,12 @@ var DEFAULT_RULES = [
8530
8530
  },
8531
8531
  {
8532
8532
  id: "ssh-success-after-failures",
8533
- title: "SSH Login After Failed Attempts",
8534
- description: "Successful SSH login from an IP that had recent failures",
8533
+ title: "SSH Login Accepted",
8534
+ // Honest description: this rule does NOT correlate with earlier failures —
8535
+ // it matches any accepted login. It is an alert, and it declares no
8536
+ // remediation precisely because banning the person who just logged in is
8537
+ // never the right response.
8538
+ description: "Successful SSH login (alert only \u2014 never grounds for a ban)",
8535
8539
  version: "1.0.0",
8536
8540
  category: "auth",
8537
8541
  severity: "critical",
@@ -8558,7 +8562,9 @@ var DEFAULT_RULES = [
8558
8562
  match: {
8559
8563
  field: "message",
8560
8564
  operator: "regex",
8561
- value: "(failed|accepted).*\\broot\\b"
8565
+ // Attempts only. Matching `accepted` here meant a successful root login
8566
+ // banned the administrator who had just made it.
8567
+ value: "failed.*\\broot\\b"
8562
8568
  },
8563
8569
  threshold: 1,
8564
8570
  window_seconds: 60,
@@ -9233,6 +9239,9 @@ var SEVERITY_RANK4 = {
9233
9239
  high: 3,
9234
9240
  critical: 4
9235
9241
  };
9242
+ function isSuccessfulAuth(message) {
9243
+ return /login accepted|accepted (?:publickey|password|keyboard-interactive)|session opened/i.test(message);
9244
+ }
9236
9245
  function explainBlockFailure(err, backend) {
9237
9246
  const raw = err.message || String(err);
9238
9247
  const denied = /not permitted|EACCES|EPERM|permission denied|must be root/i.test(raw);
@@ -9287,6 +9296,11 @@ var RemediationManager = class {
9287
9296
  const eventRank = SEVERITY_RANK4[event.severity] ?? 0;
9288
9297
  const minRank = SEVERITY_RANK4[this.config.min_severity] ?? 3;
9289
9298
  if (eventRank < minRank) return;
9299
+ if (isSuccessfulAuth(event.message)) return;
9300
+ if (event.details?.rule_id) {
9301
+ const remediation = event.details?.remediation;
9302
+ if (remediation?.action !== "block") return;
9303
+ }
9290
9304
  const ip = event.source_ip;
9291
9305
  if (!ip || (0, import_node_net4.isIP)(ip) === 0) return;
9292
9306
  if (this.isAllowlisted(ip)) return;
@@ -9468,14 +9482,25 @@ var RemediationManager = class {
9468
9482
  }
9469
9483
  this.blocklist = live;
9470
9484
  this.saveState();
9471
- if (this.config.dry_run) return;
9472
- let applied = [];
9485
+ let applied = null;
9473
9486
  try {
9474
9487
  applied = await this.adapter.listBlocked();
9475
9488
  } catch {
9476
9489
  }
9490
+ if (applied) {
9491
+ const known = new Set(live.filter((b) => !b.dry_run).map((b) => b.ip));
9492
+ for (const ip of applied) {
9493
+ if (known.has(ip)) continue;
9494
+ this.logLine(`[firewall] reconcile: dropping stale rule for ${ip} (no record of why)`);
9495
+ try {
9496
+ await this.adapter.unblock(ip);
9497
+ } catch {
9498
+ }
9499
+ }
9500
+ }
9501
+ if (this.config.dry_run) return;
9477
9502
  for (const entry of live) {
9478
- if (applied.includes(entry.ip)) continue;
9503
+ if (applied?.includes(entry.ip)) continue;
9479
9504
  try {
9480
9505
  await this.adapter.block(entry.ip);
9481
9506
  } catch {