CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

rsyslog-security-audit

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.

Quality

88%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

SKILL.md
Quality
Evals
Security

rsyslog Security Audit

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.

Ground rules

  1. Confidentiality comes first. rsyslog/rsyslog is a public community repository. A real or suspected vulnerability must never appear in a public issue, pull request, PR or review comment, commit message, branch name, tracked file, CI log, or public chat. See Reporting and confidentiality.
  2. Model and effort. Run the audit on the strongest available reasoning model at high effort. Do not delegate the per-write tracing (Phase 2) or the chain analysis (Phase 4) to a lighter or faster model to save cost; that is exactly where shallow passes miss real issues. Lighter models may help with mechanical tasks such as building or running prepared reproducers.
  3. Review independently. Form your own conclusions from the source. Do not anchor on earlier reviews, tool output, issue text, or hints about where a bug "probably" is; read them only after your own pass, then reconcile.
  4. Proof over pattern. Follow doc/ai/security_triage_rubric.md. A risky-looking pattern is a hypothesis until source, reachability, sink, missing guard, and impact are established.
  5. Do not change behavior during the audit. Audit the current source of the requested revision. Fixes are a separate, explicitly authorized step.

Required reading

Phase 1: Scope and threat model per input surface

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:

  • Inputs (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.
  • Parsers (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.
  • Message modification (mm*): message properties, JSON trees, regex captures, lookup-table keys, and external data sources.
  • Outputs (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.
  • Runtime: property getters and setters, string builders, datetime parsing, RainerScript functions on message data, queue disk files and spool state, transport drivers.

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.

Phase 2: Per-write worst-case tracing

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);
  • indexed stores such as buf[i++] = c, NUL termination buf[len] = '\0', and loops that copy or unescape character by character;
  • stack arrays, alloca, struct members with fixed sizes, and heap buffers sized once and filled later;
  • reads that may run past the end (buf[len], strlen on unterminated data, lookahead such as p[1]), which matter for crashes and information leaks.

For each write, determine:

  1. The destination and its real capacity: sizeof versus the allocated size versus a constant used elsewhere. Confirm the constant matches the declaration that is actually in effect.
  2. The offset expression and the length expression, each traced back through the whole function, earlier loop iterations, and callers to its origin. Note which terms are attacker-controlled and which depend on configuration.
  3. The worst-case offset + length an attacker can reach, compared with the capacity. Do the arithmetic explicitly.
  4. Every guard on the path: what value it checks, and whether that is the same value used at the write. A check on len does not protect a write at offset + len when offset has already advanced.
  5. Position control: how an attacker can place a short or minimal field at the very end of the buffer, so that a fixed-size read or write at that field runs past the end. Look at everything that moves a field: preceding fields of attacker-chosen length, unbounded runs of digits, spaces, or delimiters that the parser skips, and optional fields that may be omitted. Repeat the analysis on both sides of every buffer-size threshold, for example a small inline or stack buffer versus a heap allocation, or a default versus an enlarged maximum size: a field that is harmless in one layout can end exactly at the edge in the other.

Patterns to look for in rsyslog code:

  • an offset accumulated across several copies (header pieces, then a prefix, then the message), where each copy is bounded on its own but the sum is not;
  • len - offset or size - used underflow when the offset can exceed the length, turning into a huge size_t;
  • signed int lengths compared against unsigned sizes or converted to size_t, including negative values from parsed numeric fields;
  • integer overflow in allocation sizes (n * size, len + extra), more likely on 32-bit builds;
  • off-by-one in terminator space, or a loop that advances an index for skipped or escaped characters without rechecking the bound;
  • a "validated earlier" assumption made in a different function or module, or one that holds only for the default maxMessageSize;
  • truncation by 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:

  • Platform-specific paths: every #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.
  • Compression and decompression reachable from input: output size limits, ratio limits, partial streams, and errors in the middle of a stream.
  • Error paths and cleanup: resource leaks (memory, file descriptors, sockets, received descriptors), shallow frees that leave nested allocations behind, double frees, and state left half-initialized when parsing fails part-way. An attacker who can trigger an error path repeatedly turns a leak into resource exhaustion.
  • Truncation and control-message flags: handling of 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:linedestination (capacity)offset originlength originworst caseguardverdict

A write is cleared only when its worst case is proven to fit. "Probably fine" stays open and moves to Phase 3.

Phase 3: Dynamic verification with ASan and UBSan

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:

  • Oversize fields: each attacker-controlled field larger than the buffer it lands in, at exactly the capacity, and at capacity plus or minus one; whole messages at and above maxMessageSize, with both default and enlarged settings.
  • Minimal inputs: empty payload, a single byte, only a delimiter, only a header, a header without a message.
  • Truncated fields: a header cut in the middle of a field, a missing terminator or closing bracket, a length prefix claiming more bytes than are present, and a stream that ends mid-frame.
  • Hostile values: embedded NUL bytes, non-UTF-8 and control characters, extreme or negative numeric fields, deeply nested structures.

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:

  • Mark every finding tested (an ASan/UBSan report, crash, or observed misbehavior reproduced against actual rsyslog code paths) or untested (static reasoning only). Never present an untested finding as reproduced.
  • When ASan reports an overflow, confirm the impact on a production-like build as well (-O2 -D_FORTIFY_SOURCE=2, no sanitizers): ASan changes memory layout, and fortified builds may turn the overflow into an abort.
  • Keep reproducers, crash inputs, and logs outside the repository tree or in an ignored scratch directory. Never commit or push them during the audit.

Phase 4: Chain analysis

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:

  • Does an off-by-one, unchecked return value, or over-advanced offset feed a later write or length elsewhere in the same function or in a caller?
  • Does a "configuration only" precondition become realistic in common deployments (enlarged message sizes on central collectors, an option that distributions enable)?
  • Does a read overflow leak memory into an output, a forwarded message, or a log file that an attacker can read back?
  • Does a denial-of-service item become memory corruption on a different architecture (32-bit size_t), compiler, or library version?
  • Can two individually bounded inputs (for example a header field and the message body, or two ancillary values) together exceed a bound?

Reclassify any item that chains into a vulnerability, and record the chain explicitly.

Root-cause completeness

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.

Phase 5: Classification and output

Classify every finding using the rubric:

  • Potential vulnerability: the rubric's confirmed issue or potential issue: plausible or proven attacker-controlled path to memory corruption, privilege or file-integrity impact, confidentiality loss, authentication bypass, or meaningful denial of service. State which one.
  • Hardening: robustness improvement where exploitability is config-only, deployment-dependent, testbench-only, or not demonstrated after chain analysis.
  • Not actionable: attacker control, reachability, or impact does not hold.

Report one line per finding, most severe first:

[VULN|HARDENING] path/file.c:LINE  <sink and missing guard>; <attacker and preconditions>; <impact>; tested|untested

Follow the list with:

  • for each vulnerability, its fix points from the root-cause completeness step;
  • the chains found in Phase 4, if any;
  • a short "not actionable" list of investigated and cleared hypotheses;
  • coverage: audited revision, input surfaces covered, which writes were only reviewed statically, build and configurations used, sanitizers that were not run (for example 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.

Reporting and confidentiality

  • Deliver the full report only through a private channel to the requesting maintainer. Potential vulnerabilities go through GitHub Private Vulnerability Reporting or the maintainer contact in SECURITY.md.
  • Never create a public issue, pull request, PR comment, discussion, commit, or branch on rsyslog/rsyslog that describes or hints at a potential vulnerability. That includes suggestive branch names, test names, commit messages, and "harmless" refactors that obviously fix it.
  • Fixes for vulnerabilities are prepared on a private maintainer branch or a GitHub security advisory fork and are merged publicly only when coordinated disclosure allows, as described in SECURITY.md.
  • Hardening items may go through normal public PRs only when chain analysis showed that they do not contribute to any vulnerability finding, and only with the rubric's public wording. If in doubt, keep the item private and ask the maintainer.
  • Do not store findings in tracked files, public CI logs, or shared memory that other contributors can read; keep working notes outside the repository.

Common pitfalls

  • Stopping after the first bug in a function. Finish the trace; a second write with a different worst case is common.
  • Checking the guard that exists instead of the arithmetic at the write.
  • Naming only the first enabling cause of a finding, so that the fix leaves other ways to reach the same sink.
  • Testing only the default buffer layout, when a different size threshold lets an attacker place a field at the buffer's end.
  • Assuming library or kernel data (DNS answers, ancillary data, certificate fields, remote responses) is well-formed or bounded.
  • Reporting a finding as reproduced when only the static trace exists.
  • Treating configuration control as attacker control, or the reverse: a non-default setting can still be a realistic exposure.
  • Leaking a finding through a public artifact while asking for help or preparing a fix.

Related skills

Repository

rsyslog/rsyslog

Path

.agent/skills/rsyslog-security-audit/SKILL.md

Last updated
First committed

Is this your skill?

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.