8000 🛡️ Fix security, delivery, failover, and detection bugs from code audit by abahmed · Pull Request #523 · abahmed/kwatch · GitHub
[go: up one dir, main page]

Skip to content

🛡️ Fix security, delivery, failover, and detection bugs from code audit - #523

Merged
abahmed merged 2 commits into
mainfrom
fix/code-audit-findings
Sep 27, 2026
Merged

abahmed merged 2 commits into
mainfrom
fix/code-audit-findings

Conversation

@abahmed
@abahmed abahmed commented Sep 27, 2026
Copy link
Copy Markdown
Owner

Summary

Fixes found in a code-only audit of the repository. Two commits:

Security

  • Redact secret-bearing URLs from transport, Slack, and Discord errors before logging.
  • Escape Telegram Markdown, Matrix HTML, and Slack mrkdwn; disable Discord mentions; neutralize broadcast mentions in Mattermost and Rocket.Chat.
  • Reject proxy, TLS trust, CA bundle, pprof, diagnostics, and audit-log path overrides in KwatchConfig.
  • Redact env values and ConfigMap data in recorded change history.

Providers

  • Paging providers (iLert, Squadcast, GoAlert, Splunk On-Call, SIGNL4, Alerta, Sensu, incident.io, Datadog, New Relic) keep one alert per incident and resolve it on recovery.
  • Issue trackers (GitHub, Gitea, GitLab, Jira, ClickUp) file one issue per incident, comment on updates, and close or comment on recovery; the mapping persists.
  • Cap provider Retry-After waits at one minute.

Failover and persistence

  • Release the Lease only after delivery drains and final state is written; fence writes on leadership loss.
  • Scope state ConfigMaps per installation (default install keeps kwatch-*, with legacy read fallback).
  • Readiness recovers after a transient write failure; RBAC grants the shard ConfigMap verbs.
  • Restored never-announced incidents stay unannounced; restarts no longer produce duplicate creates.

Detection

  • Scoped silences no longer suppress other namespaces; admission-rejected pods alert; Job backoff off-by-one fixed; Deployment conditions respect the sustain window.
  • Root cause names a node or owner only when it is unhealthy.
  • Out-of-order announcements are dropped by revision; webhook and custom-resource kinds no longer collide.
  • Owner-level kubelet incidents, node pressure, and PVC status resolve correctly.

Upgrade notes

  • Alerts and issues opened by the reworked providers before this change will not be matched; close them once by hand.
  • Open webhook-endpoint and custom-resource incidents get new keys; the janitor closes the old ones.
  • GoAlert now uses /api/v2/generic/incoming; not verified against a live GoAlert server.
  • Jira and ClickUp comment on recovery instead of closing (their closed states are per project).

Testing

  • make verify passes (build, vet, lint, race tests with coverage, line check, architecture, test layout, catalogs, docs).
  • Every fix has focused tests.

Security
- Redact request URLs from transport, Slack, and Discord errors so bot
  tokens and webhook secrets never reach logs.
- Escape Matrix HTML bodies, Telegram Markdown fields, and disable Discord
  mentions so workload logs cannot inject markup or ping channels.
- Reject proxy, TLS trust, CA bundle, pprof, diagnostics, and audit log
  path overrides in KwatchConfig resources.
- Redact env values and ConfigMap data in recorded change history.

Delivery and lifecycle
- Cap provider Retry-After waits at one minute.
- Restore leader readiness after a transient persistence write failure.
- Fix optional component backoff reset and cap.
- Keep never-announced incidents unannounced across restarts.
- Only promote updates to creates after a suppressed delivery or a
  resolve, not after a restart.
- Count notifications dropped after delivery stops.
- Stop standby replicas waiting for a controller that never ran.
- Start and drain delivery in kwatch replay.
- Allow the default 30s pprof CPU profile.

Detection
- Apply scoped or multi-field silences only at delivery time.
- Report pods rejected at admission.
- Alert on Job backoff only after the limit is exceeded.
- Keep Deployment rollout conditions inside the sustain window.
- Only name a node or owner as root cause when it is unhealthy.
- Keep global image-pull incidents open until they recover cluster-wide.
- Resolve only the PVC status reason on healthy PVCs.
- Give each control-plane probe its own timeout.

Deployment
- Grant configmap list, update, and delete for incident shards.
Providers
- Paging providers (iLert, Squadcast, GoAlert, Splunk On-Call, SIGNL4,
  Alerta, Sensu, incident.io, Datadog, New Relic) keep one alert per
  incident and resolve it on recovery; notices deduplicate at low severity.
- Issue trackers (GitHub, Gitea, GitLab, Jira, ClickUp) file one issue per
  incident, comment on updates, and close or comment on recovery; the
  mapping persists across restarts.
- Escape Slack mrkdwn and neutralize broadcast mentions in Mattermost and
  Rocket.Chat.
- Escape GitLab project paths and warn that LINE Notify is discontinued.

Failover and persistence
- Release the Lease only after delivery drains and final state is written;
  fence persistence before cancelling on leadership loss.
- Scope state ConfigMaps to the installation's Lease name with a legacy
  read fallback; grant namespace-local configmap get.
- Persist container, node, and image on incidents (additive fields).

Detection and correlation
- Drop announcements older than the last announced revision.
- Keep webhook and custom-resource incidents of different kinds apart.
- Resolve owner-level kubelet incidents only when no replica still fails.
- Resolve node resource and filesystem levels when they clear.
- Detect restarts without a prior observation and respect node silences
  when seeding.
- Watch only the storage version of each CRD and keep dynamic graph edges
  across hourly rebuilds.
@abahmed
abahmed merged commit b69e688 into main Sep 27, 2026
9 checks passed
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.

1 participant

0