Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abnormal message causes Segmentation fault #3328

Closed
aleksandrgilfanov opened this issue Jun 17, 2020 · 4 comments · Fixed by #3364
Closed

Abnormal message causes Segmentation fault #3328

aleksandrgilfanov opened this issue Jun 17, 2020 · 4 comments · Fixed by #3364
Labels

Comments

@aleksandrgilfanov
Copy link

syslog-ng

Version of syslog-ng

syslog-ng 3 (3.27.1)
Config version: 3.22
Installer-Version: 3.27.1
Revision:
Module-Directory: /usr/local/lib/syslog-ng
Module-Path: /home/sense/test-fuzz/syslog-ng-3.27.1/inst/usr/local/lib/syslog-ng
Include-Path: /usr/local/share/syslog-ng/include
Available-Modules: stardate,basicfuncs,add-contextual-data,xml,examples,hook-commands,disk-buffer,appmodel,azure-auth-header,confgen,map-value-pairs,afsocket,affile,tfgetent,graphite,syslogformat,cryptofuncs,kvformat,secure-logging,cef,linux-kmsg-format,csvparser,tags-parser,afprog,afsql,afuser,timestamp,system-source,pseudofile,dbparser
Enable-Debug: on
Enable-GProf: off
Enable-Memtrace: off
Enable-IPv6: on
Enable-Spoof-Source: off
Enable-TCP-Wrapper: off
Enable-Linux-Caps: off
Enable-Systemd: off

Platform

Debian 10

Issue

The message, that contains just bytes: "4\0 " causes Segmentation fault

Steps to reproduce

printf '4\0  ' | syslog-ng \
        --foreground \
        --cfgfile=$CONFIG
Segmentation fault

Configuration

@version:3.22

source s_src {
        stdin(follow-freq(1));
};

destination d_dst {
        file("/tmp/dest.log");
};

log {
        source(s_src);
        destination(d_dst);
};
@aleksandrgilfanov
Copy link
Author

Possible fix: aleksandrgilfanov@25a3f8b

@Kokan
Copy link
Collaborator

Kokan commented Jun 17, 2020

Hello, nice findings. This turned out once when I tweaked a fuzzer[1] (and some other issue like this). I had a slightly different fixture for this error: Kokan@d4b4496 (Note this commit contains other possible fixes.)

Your patch imho is not correct, as the src and left should be in sync, but yours increment the src unconditionally and not later assignes it to data.

  *data = src;
  *length = left;

The data and length could be inconsistent, that may cause additional issues later on.
The reson I did not submit my version is that I had an open question what to do when this error occurs:

  1. pretend that seq id not present and let the parsing continue
    • parsing continue after seq id
    • parsing continue at seq id
  2. make the whole parser fail, and wrap the not parse-able message into a new one (msg_format_inject_parse_error).

I think the option 2 would be a good choose.
@aleksandrgilfanov Would you mind doing a pull request from it ?

[1] The comment describes how to use the fuzzer ed178e5 that works on this branch: master...Kokan:libfuzz-syslog-parser

@aleksandrgilfanov
Copy link
Author

@Kokan #3329

@bazsi
Copy link
Collaborator

bazsi commented Jun 18, 2020 via email

Kokan added a commit to Kokan/syslog-ng that referenced this issue Jul 26, 2020
Fixes syslog-ng#3328 and hopefully a few similuar not discovered crashes like that.

Signed-off-by: Kokan <kokaipeter@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants