Repository navigation
Expand file tree
/
Copy pathpamsignal.spec
More file actions
331 lines (302 loc) · 16.2 KB
/
Copy pathpamsignal.spec
File metadata and controls
331 lines (302 loc) · 16.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
Name: pamsignal
Version: 0.8.0
Release: 1%{?dist}
Summary: Real-time PAM login monitor with multi-channel alerts
License: MIT
URL: https://github.com/anhtuank7c/pamsignal
Source0: %{name}-%{version}.tar.gz
BuildRequires: meson >= 0.50
BuildRequires: ninja-build
BuildRequires: gcc
BuildRequires: pkg-config
BuildRequires: systemd-devel
BuildRequires: systemd-rpm-macros
BuildRequires: libcmocka-devel
Requires: systemd
Requires: curl
Requires(pre): shadow-utils
# %files declares %attr(...,pamsignal) which makes RPM auto-generate
# Requires: user(pamsignal) and Requires: group(pamsignal). The user and
# group are created by %pre as part of THIS package's install, so we
# Provides them explicitly; otherwise dnf rejects the transaction at
# resolution time, before %pre has a chance to run.
Provides: user(pamsignal)
Provides: group(pamsignal)
%description
PAMSignal follows the systemd journal for PAM authentication events from
sshd, sudo, su and login. It reports successful and failed logins and
session opens and closes, detects brute-force attempts (remote by source
IP, local sudo/su by account) and a successful login that follows
repeated failures, and sends alerts to Telegram, Slack, Microsoft Teams,
WhatsApp, Discord, or a custom HTTPS webhook (ECS JSON, optional auth
header and mTLS).
The daemon runs as an unprivileged system user with read access to the
journal, ignores entries not written by the real sshd, sudo, su or login
binaries, dispatches alerts through fork+exec of curl with credentials
kept out of argv, and ships with systemd sandboxing (NoNewPrivileges,
ProtectSystem=strict, SystemCallFilter, MemoryDenyWriteExecute, etc.).
%prep
%autosetup -n %{name}-%{version}
%build
%meson
%meson_build
%check
%meson_test
%install
%meson_install
%pre
# Create the pamsignal group and system user before file install. shadow-utils
# provides groupadd/useradd; the Requires(pre) above ensures they're present.
# Group is created explicitly so `Provides: group(pamsignal)` is honored even
# on systems where USERGROUPS_ENAB is unset and useradd would otherwise skip
# auto-creating the matching group.
getent group pamsignal >/dev/null 2>&1 || groupadd -r pamsignal
getent passwd pamsignal >/dev/null 2>&1 || \
useradd -r -g pamsignal -s /sbin/nologin -M -d /nonexistent \
-c "PAMSignal daemon" pamsignal
# Grant read access to the journal.
getent group systemd-journal >/dev/null 2>&1 && \
usermod -aG systemd-journal pamsignal || true
exit 0
%post
%systemd_post pamsignal.service
# The config file holds alert credentials (Telegram tokens, webhook URLs).
# Owner stays root so only admins can edit; group is pamsignal mode 0640 so
# the daemon can read.
if [ -f %{_sysconfdir}/pamsignal/pamsignal.conf ]; then
chown root:pamsignal %{_sysconfdir}/pamsignal/pamsignal.conf
chmod 0640 %{_sysconfdir}/pamsignal/pamsignal.conf
fi
%preun
%systemd_preun pamsignal.service
%postun
%systemd_postun_with_restart pamsignal.service
# The pamsignal user is intentionally NOT removed: it may own journal
# entries or runtime state outside our control.
%files
%license LICENSE
%doc README.md CHANGELOG.md
%{_bindir}/pamsignal
%{_unitdir}/pamsignal.service
# Trailing * matches the .gz suffix added by Fedora's brp-compress hook so
# the file list is correct whether or not compression ran.
%{_mandir}/man8/pamsignal.8*
%{_mandir}/man5/pamsignal.conf.5*
%dir %attr(0750,root,pamsignal) %{_sysconfdir}/pamsignal
%config(noreplace) %attr(0640,root,pamsignal) %{_sysconfdir}/pamsignal/pamsignal.conf
%changelog
* Fri May 08 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.4.0-1
- Feature: webhook_auth_header config key for the custom webhook
channel (#7). Operators can send a single arbitrary HTTP header
(Bearer token, X-API-Key, Splunk HEC, Datadog DD-API-KEY, HMAC,
etc.) with each webhook POST. The header value is rendered into
the existing memfd-backed curl -K config, so the secret never
appears in argv or /proc/<pid>/cmdline. Validator rejects CRLF /
quote / backslash injection and refuses the key set without
webhook_url.
- Feature: optional mTLS client authentication for the custom
webhook channel (#8). Three new keys (webhook_client_cert,
webhook_client_key, webhook_ca_bundle) let operators with PKI
(internal CA, cert-manager, SPIFFE, service-mesh issuance)
authenticate with a client certificate. Combines additively with
webhook_auth_header for the Wazuh / corporate-SIEM pattern.
Cert/key/CA paths flow through the same memfd-backed curl config
as the auth header, so argv stays byte-identical regardless of
which auth modes are configured. Validator: O_NOFOLLOW open,
regular-file, ownership in {root, daemon-uid},
webhook_client_key not group/world-readable, cert/key set
together, and any TLS key without webhook_url rejected.
- Internal API: post_alert() and build_secrets_memfd() in
src/notify.c swap from positional arguments to a curl_config_t
struct. The four legacy callers (Telegram, Slack, Teams, Discord,
WhatsApp) pass struct-literal arguments and produce identical
wire output.
- Documentation: docs/configuration.md gains "Custom webhook
authentication"; docs/alerts.md extends with "Mutual TLS";
docs/architecture.md documents the curl_config_t / memfd-backed
-K dispatch model; docs/deployment.md documents cert/key file
placement; docs/threat-model.md updates attack #3 and rewrites
NS8; examples/nodejs-webhook/README.md adds an mTLS-enabled
Express receiver variant.
- Tests: 20 new CMocka cases in tests/test_config.c (test_config
suite 33 -> 53). ASAN + UBSAN clean; clang-tidy clean.
* Sun May 03 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.3.4-1
- Security: extend the _EXE anti-spoofing allowlist to accept
sshd-session. OpenSSH 9.8 (released 2024-07) split sshd into a
privilege-separated listener and a per-connection auth process
(sshd-session). On Fedora 41+, RHEL/Alma/Rocky once they pick up
the new OpenSSH, and on Ubuntu 26.04 / Debian Trixie, all sshd
PAM auth events come from sshd-session and were dropped by
pamsignal's allowlist. The daemon ran fine, journald accumulated
events fine, the daemon just didn't see them. Fix is a one-line
addition to the basename allowlist. Refactored into a testable
ps_is_trusted_exe helper with eight new CMocka cases covering
canonical paths, sshd-session paths, alternate system prefixes,
and spoofing-rejection paths.
- Tooling: tests/scenario.sh full-stack local end-to-end scenario
test (build, install, real sshd brute-force, real sudo
brute-force, mock HTTPS webhook, SIGHUP reload, cleanup). Twelve
phases with pass/fail per phase and an EXIT trap that always
cleans up. Caught the sshd-session bug above on its first
non-CI run.
- CI: forward-port a hardened Python webhook handler into the
test-deb mock. The default BaseHTTPRequestHandler does dirty TLS
shutdowns which OpenSSL 3.5+ flags as
error:0A000126:SSL routines::unexpected eof while reading. The
CI runner is currently on OpenSSL 3.0 (tolerant) but will
eventually promote to 3.5+ (strict); fix in place.
- Repository hygiene: CONTRIBUTING.md, GitHub issue + PR templates,
rewritten as Linux-daemon reports. These accumulated under
Unreleased since v0.3.3 and ship now alongside the security fix.
* Sun May 03 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.3.3-1
- systemd unit hardening: exposure score drops from 22 to 13
(displayed 2.2 to 1.3, near the achievable floor for a daemon
with the network-egress + journal-access constraints). Nine
new directives, each justified against actual daemon behavior:
UMask=0077, ProtectClock=yes, ProtectHostname=yes,
ProtectProc=invisible, ProcSubset=pid,
SystemCallArchitectures=native, RemoveIPC=yes,
RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6
(allowlists exactly the four families libsystemd and the curl
child use; drops AF_PACKET, AF_BLUETOOTH, AF_VSOCK, AF_TIPC,
AF_RDS, AF_XDP), and DevicePolicy=closed (overrides the
implicit char-rtc:r grant from PrivateDevices=yes). The CI
threshold for the systemd-analyze regression gate tightens
from 30 to 20 to lock in the new baseline.
- docs/threat-model.md: canonical threat model. Five adversary
classes with explicit capabilities. Nine in-scope attacks,
each cross-referenced to the source-line of its mitigation.
Ten explicit out-of-scope non-goals with the reasoning for
each. Trust-boundary table mapping each untrusted-data
crossing to its validator. SECURITY.md scope section now
references the threat model instead of duplicating the
in/out lists.
- CI: AddressSanitizer + UndefinedBehaviorSanitizer run on
every push to main and every PR via a new ci.yml workflow.
Catches use-after-free, OOB heap/stack, double-free, leaks,
signed-integer overflow, narrowing conversions, etc. Initial
run found zero issues on the existing test surface.
* Sun May 03 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.3.2-1
- Adopt Type=notify with sd_notify(READY=1) signaled after the
journal-watch init succeeds; systemd holds the unit in the
activating state until pamsignal can actually process events.
WatchdogSec=30s plus sd_notify(WATCHDOG=1) on every main-loop
iteration auto-restarts a wedged sd_journal_wait instead of
letting the daemon silently stop processing auth events.
NotifyAccess=main confines the notification socket to the
parent process so the fork+exec curl children cannot spoof
readiness or watchdog messages.
- Add SECURITY.md at the repo root: GitHub Security Advisories
is the preferred private-disclosure channel with email
fallback; 90-day coordinated-disclosure timeline; supported
version policy is latest minor only; explicit in-scope vs
out-of-scope table separating parser bypasses and tracker
logic from upstream-dependency bugs.
- CI: add a systemd-analyze security regression gate to the
test-deb job. systemd-analyze --threshold uses a 0-100 internal
scale (the displayed "Overall exposure level" shows the same
value divided by 10). Current internal score is 22 (displayed
2.2, "OK"); the gate threshold is 30. Routine adjustments pass
through but stripping a major hardening directive
(MemoryDenyWriteExecute, SystemCallFilter, CapabilityBoundingSet,
ProtectSystem=strict, etc., each worth 5+ internal points)
trips the gate.
* Sun May 03 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.3.1-1
- BREAKING (revert of v0.3.0 path move): daemon binary moves from
/usr/sbin/pamsignal back to /usr/bin/pamsignal to align with the
systemd-era convention that admin-oriented commands (journalctl,
systemctl, podman, containerd) all live in /usr/bin despite being
administrator tools. Fedora 42+ has formally retired the bin/sbin
split (sbindir == bindir == /usr/bin); Debian Trixie has the
merge on its roadmap. v0.3.0's FHS section 4.10 reading is
historically valid but on the wrong side of where the ecosystem
is moving. rpm handles the relocation atomically on upgrade and
the unit's ExecStart is updated in lockstep via meson
configure_file. Anyone who scripted against the /usr/sbin/pamsignal
path that v0.3.0 introduced for the ~30 minutes it was on the dnf
gh-pages repo needs to revert to /usr/bin/pamsignal.
* Sun May 03 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.3.0-1
- NEW: detect failed sudo/su password attempts and emit a brute-force
alert when the per-actor threshold is crossed. Parser recognizes the
pam_unix authentication-failure message format; tracker keys by source
IP when rhost is set (SSH-to-sudo chains) or by ruser otherwise.
Per-event chat alerts suppressed for sudo/su login failures so a
single mistyped password does not spam channels.
- BREAKING: daemon binary moves from /usr/bin/pamsignal to
/usr/sbin/pamsignal (FHS section 4.10). rpm handles the relocation
atomically on upgrade; the unit's ExecStart is updated in lockstep
via meson configure_file. Update any scripts referencing the
absolute /usr/bin/pamsignal path.
- BREAKING: legacy PAMSIGNAL_ underscore journal fields removed. Update
saved journalctl queries that filter by PAMSIGNAL_EVENT to use
EVENT_ACTION instead. Full field mapping in CHANGELOG.md.
- Packaging: install section drops the post-install mv (out of
/etc/systemd/system) and sed (/usr/bin to /usr/sbin) workarounds; the
meson configure_file emits the unit in the vendor unit dir directly
with the right ExecStart path. The pre script creates the pamsignal
group explicitly before useradd so the group provides resolves even
on hosts with USERGROUPS_ENAB unset.
- Add pamsignal(8) man page; the files list glob tolerates either the
compressed or uncompressed form.
- Security: close two clang-analyzer taint-source findings (config-file
isspace and getgroups malloc); both defensive narrowings with no
exploitable vulnerabilities closed.
- Docs: docs/deployment.md Install and Uninstall sections split by
install path (apt / dnf / source build).
* Sun May 03 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.2.4-1
- Add optional server context tags (`provider`, `service_name`) to alert
payloads. When configured in `pamsignal.conf` they are appended to
chat-text alerts and injected under the ECS `labels.*` dictionary in
JSON webhook payloads.
- docs: TypeScript Express webhook receiver example and Bruno test
collection; expand custom-webhook integration docs.
- ci(test-deb): drive the functional test with real sshd auth events
instead of `logger -t sshd` (the v0.2.3 `_EXE` allowlist drops the
latter).
- ci: pin `environment: release` on every release job so secrets resolve
consistently.
* Sat May 02 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.2.3-1
- Security: enforce a `_EXE` allowlist on every journal entry so
unprivileged users can no longer inject fake PAM events via logger(1)
to trigger false alerts or brute-force lockouts. Only entries whose
`_EXE` resolves to sshd / sudo / su / login / systemd-logind under a
system prefix (/usr/, /bin/, /sbin/, /lib/, /lib64/, /opt/) are
processed; entries with a missing `_EXE` are dropped.
- Fix: brute-force tracker now zeroes `last_brute_alert_usec` on the
evict-and-reuse path so a new IP doesn't inherit the evicted IP's
alert cooldown.
- Fix: `SIGHUP` reload preserves the in-memory brute-force tracking
table instead of zeroing it. Existing per-IP attempt counts and
cooldowns survive a config reload.
* Sat May 02 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.2.2-1
- Republish signed apt + dnf repository on the canonical GitHub Pages URL
(https://anhtuank7c.github.io/pamsignal/) after the custom domain was
removed from the gh-pages site. No source or packaging logic changes:
binary is identical to v0.2.1; this release simply triggers the
publish-repo workflow against the github.io origin so users following
the install instructions in README.md get a working repo.
* Thu Apr 30 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.2.1-1
- Packaging release: signed apt and dnf repositories published to GitHub
Pages. Adds Provides: user(pamsignal) / group(pamsignal) so the auto-
generated user/group Requires from %attr(...,pamsignal) in %files
resolves cleanly under dnf 5 (Fedora 44).
- No source code changes; binary is identical to v0.2.0.
* Thu Apr 30 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.2.0-1
- Align alert payloads with Elastic Common Schema (ECS). Breaking change to
chat text and JSON webhook formats; see CHANGELOG.md for migration.
- Chat text: severity-prefixed key=value with a new pid= field for direct
`kill <pid>` from the alert.
- JSON webhook: nested ECS objects plus pamsignal.* namespace.
- systemd-journal: ECS-aligned fields added alongside legacy PAMSIGNAL_*.
* Wed Apr 29 2026 Tuan Nguyen <anhtuank7c@hotmail.com> - 0.1.0-1
- Initial RPM packaging.
- Six-phase OWASP 2025 / data-integrity / memory-safety audit closed every
Critical, High, Medium, Low, and Info finding identified.
- Alert dispatch hardened: secrets via memfd-backed curl config (not argv);
absolute-path execv; --proto =https forced.
- PID file via openat under O_DIRECTORY|O_NOFOLLOW dirfd; stale removal
only after kill(pid,0) confirms ESRCH.
- Per-source-IP brute-force cooldown.
- Compiler hardening: _FORTIFY_SOURCE=3, stack-clash, CET, separate-code.
- 78 CMocka tests across four suites; opt-in libFuzzer harness for the
PAM message parser.