Run a deep security/vulnerability audit of an rsyslog component (input, parser, message modification, output, or runtime subsystem) with per-input-surface threat modeling, worst-case offset/length tracing of every write, ASan/UBSan reproduction with hostile inputs, and chain analysis. Findings stay private. Use for "security review of <module>", vulnerability hunting, or audits beyond a PR delta.
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Use this skill for a full security review of one rsyslog component or
subsystem: an input module, a parser, a message-modification module, an output,
or a runtime area such as message properties, string handling, queues, or
transport drivers. For reviewing only the delta of a pull request, use
rsyslog-security-pr-review instead;
this skill may still be applied to a risky PR when a maintainer asks for a deep
audit of the touched component.
The method is deliberately exhaustive. Surface-level pattern scanning misses the bugs that matter in a C logging daemon: an offset that grows across several copies in one function, a length check performed on a different value than the one later used, or a "harmless" hardening item that feeds a later write.
doc/ai/security_triage_rubric.md.
A risky-looking pattern is a hypothesis until source, reachability, sink,
missing guard, and impact are established.SECURITY.md: scope, triage criteria, configuration
preconditions, and coordinated disclosure.doc/ai/security_triage_rubric.md:
classification, proof standard, severity, and public wording.doc/security/project-threat-model.md
and the component's entry in
doc/security/threat-model-components.json:
actors, trust boundaries, invariants, and test hints.doc/source/, and
the shared runtime helpers it calls (for example runtime/msg.c,
runtime/stringbuf.c, runtime/datetime.c, runtime/parser.c).Record the audited revision (git rev-parse HEAD), the component, and its
exposure: built in, default-loaded, explicitly configured, contrib, or
testbench-only.
Enumerate every input surface, not only the obvious socket read. For each
surface record: entry function and file:line, the actor that controls it
(per the threat-model actor list), the maximum size that can arrive, framing
and delimiters, privilege level at that point (before or after the privilege
drop), and the configuration preconditions needed to reach it.
Typical surfaces by component class:
im*): payload bytes from recv/recvmsg/read/library
callbacks; ancillary data and kernel-supplied metadata (credentials, peer
addresses, socket names); values derived from the payload such as hostname,
tag, PID, or timestamps; reverse DNS results; TLS peer certificate fields;
file names and file content (imfile); journal fields (imjournal); compressed
streams and their decompressed size; connection and session counts.pm*, runtime/parser.c): the raw message buffer and its
length, and every offset the parser advances; partial or missing header
fields; numeric fields that become lengths or indexes.mm*): message properties, JSON trees, regex
captures, lookup-table keys, and external data sources.om*): template-rendered strings (attacker-controlled
properties reaching SQL, JSON, HTTP, command lines, or file paths through
dynafile templates); responses, error bodies, and acknowledgements from
remote destinations or helper programs.Configuration is administrator-controlled (TB-CONFIG). Still record which
settings widen exposure, for example a larger maxMessageSize, an option that
enables an extra parsing path, or relaxed TLS authentication, because the
severity and advisory wording depend on them.
Inventory every write into fixed-size or pre-sized storage in the audited code and in helpers it calls with attacker-influenced data:
memcpy, memmove, strcpy, strcat, strncpy, strncat, strlcpy;sprintf, snprintf, vsnprintf (the return value is the would-be length,
not the written length; check every place it is used as an offset or length);buf[i++] = c, NUL termination buf[len] = '\0',
and loops that copy or unescape character by character;alloca, struct members with fixed sizes, and heap buffers
sized once and filled later;buf[len], strlen on unterminated data,
lookahead such as p[1]), which matter for crashes and information leaks.For each write, determine:
sizeof versus the allocated
size versus a constant used elsewhere. Confirm the constant matches the
declaration that is actually in effect.offset + length an attacker can reach, compared with the
capacity. Do the arithmetic explicitly.len does not protect a write at
offset + len when offset has already advanced.Patterns to look for in rsyslog code:
len - offset or size - used underflow when the offset can exceed the
length, turning into a huge size_t;int lengths compared against unsigned sizes or converted to
size_t, including negative values from parsed numeric fields;n * size, len + extra), more
likely on 32-bit builds;maxMessageSize;snprintf followed by use of its return value.Also cover the non-memory classes that apply to the component: format-string use of message data, path traversal or symlink issues in derived paths, command or query injection through templates, unbounded allocation or CPU (decompression ratios, regex backtracking, session counts), NULL dereference on missing fields, lifecycle bugs such as use-after-free between session close and worker threads, data races, TLS verification or permitted-peer bypass, and log forgery (control characters, injected record separators, spoofed trusted properties such as hostname, PID, or credentials-derived fields).
Breadth checklist. These areas are easy to under-cover; confirm each one was reviewed or state why it does not apply:
#ifdef/#if branch for other operating
systems or libc variants (for example BSD, Solaris, or macOS branches), and
the defaults those platforms select. Code that is not compiled on the audit
host is still shipped; review it statically and say it was not executed.MSG_TRUNC and
MSG_CTRUNC from recvmsg, ancillary data of unexpected type, size, or
count, and short reads treated as complete records.Keep a working table outside the repository tree, one row per write:
| file:line | destination (capacity) | offset origin | length origin | worst case | guard | verdict |
|---|
A write is cleared only when its worst case is proven to fit. "Probably fine" stays open and moves to Phase 3.
Build an instrumented tree in a separate worktree or scratch directory, never
in the coordination checkout. Start from the ubuntu_26_san lane in
.github/workflows/run_checks.yml and keep its sanitizer set, including
nullability and unsigned-integer-overflow, which catch the length and
offset arithmetic bugs Phase 2 hunts for. With the CI dev container
(rsyslog/rsyslog_dev_base_ubuntu:26.04, clang-21) that is:
# Set to the configure switches that build the audited component.
MODULE_FLAGS="--enable-imfoo"
export CC=clang-21
export CFLAGS="-g -O1 -fno-omit-frame-pointer \
-fsanitize=address,undefined,nullability,unsigned-integer-overflow \
-fno-sanitize-recover=undefined,nullability,unsigned-integer-overflow \
-fno-sanitize=function -fsanitize-blacklist=$(pwd)/tests/asan.supp"
export LDFLAGS="-fsanitize=address,undefined,nullability,unsigned-integer-overflow \
-fno-sanitize=function"
./autogen.sh --enable-debug --enable-testbench --enable-imdiag \
--enable-omstdout --disable-libfaketime --disable-valgrind \
--without-valgrind-testbench $MODULE_FLAGS
make -j"${RSYSLOG_LOCAL_BUILD_JOBS:-10}" check TESTS=""
export ASAN_OPTIONS='abort_on_error=1:halt_on_error=1'
export LSAN_OPTIONS='detect_leaks=0'
export UBSAN_OPTIONS='print_stacktrace=1'Two deviations from the CI lane are intentional: -O1 instead of -O3 keeps
stack traces and variable state readable, and -fstack-protector and
-D_FORTIFY_SOURCE=2 are left out so ASan reports the first bad access itself;
their effect is checked in the production-like build described below. The
function sanitizer is excluded because the module ABI uses generic callback
pointers. Check that the build actually contains the audited module.
unsigned-integer-overflow also reports intentional wraparound (for example in
hashing); confirm each report against the code before treating it as a
finding.
If linking fails with a missing libclang_rt.asan or libclang_rt.ubsan
library, clang is installed without its sanitizer runtime. Install it before
considering a fallback: on Debian and Ubuntu that is
libclang-rt-<version>-dev for the installed clang (for example
libclang-rt-21-dev); other distributions ship it as compiler-rt or
clang-rt. Confirm with a one-line program that indexes past a stack array and
must produce an ASan report.
Only if the runtime cannot be installed, fall back to GCC: set CC=gcc, use
-fsanitize=address,undefined -fno-sanitize-recover=undefined in CFLAGS and
-fsanitize=address,undefined in LDFLAGS, drop the clang-only
nullability, unsigned-integer-overflow, and -fsanitize-blacklist options,
and add -Wno-error if warnings-as-errors stop the build. Every sanitizer that
was not run is a coverage gap that the report must list (see Phase 5).
For each open or suspicious write from Phase 2, craft inputs that drive it
to its worst case, and run them against a real rsyslogd instance configured
like a plausible deployment (start from a testbench config via
tests/diag.sh). At minimum cover:
maxMessageSize, with both default and enlarged
settings.Use the tools that fit the surface: tests/tcpflood for TCP/TLS/RELP framing,
small Python scripts for UDP, Unix sockets, or raw bytes, imdiag injection
for pipeline-only paths, and the existing libFuzzer targets described in
tests/fuzz/README.md
(--enable-fuzzing). A throwaway libFuzzer harness around a single parsing
function is often the fastest way to exercise one write in isolation.
Rules for this phase:
-O2 -D_FORTIFY_SOURCE=2, no sanitizers): ASan changes memory
layout, and fortified builds may turn the overflow into an abort.Re-examine every hardening item and every cleared-but-close write, especially the write-related ones, and ask whether it combines with something else into a real vulnerability:
size_t), compiler, or library version?Reclassify any item that chains into a vulnerability, and record the chain explicitly.
For every confirmed or potential memory-safety finding, enumerate all attacker-controlled preconditions that make it reachable, not just the first enabling cause you found. Typical preconditions are earlier parsing steps that let the attacker move the affected field's position or shrink the remaining length: unbounded runs of digits or whitespace before the field, optional fields that can be omitted, delimiters that can be repeated, or a size check performed before a later adjustment. Walk the path from the input surface to the sink and ask at each step whether a different input would still reach the sink if this step were fixed.
List each precondition as a required fix point. A fix that removes only one enabling cause leaves the sink reachable through the others, so the report must make the complete set visible to whoever writes the fix.
Classify every finding using the rubric:
Report one line per finding, most severe first:
[VULN|HARDENING] path/file.c:LINE <sink and missing guard>; <attacker and preconditions>; <impact>; tested|untestedFollow the list with:
nullability or unsigned-integer-overflow in a GCC
fallback build), platform-specific branches that were reviewed but not
executed, breadth-checklist items that do not apply and why, and what was
out of scope. Absence of findings is a statement about this coverage, not
proof that the component is safe.SECURITY.md.SECURITY.md.rsyslog-security-pr-review:
security review of a PR delta.rsyslog_build and
rsyslog_test: building and running focused
tests.rsyslog_local_container_testing:
CI-equivalent sanitizer lanes in the dev container.rsyslog/rsyslog
382d2a2
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.