Skip to content

Fix/xinetd probe memory safety#2371

Open
edznux-dd wants to merge 1 commit into
OpenSCAP:mainfrom
edznux-dd:fix/xinetd-probe-memory-safety
Open

Fix/xinetd probe memory safety#2371
edznux-dd wants to merge 1 commit into
OpenSCAP:mainfrom
edznux-dd:fix/xinetd-probe-memory-safety

Conversation

@edznux-dd

@edznux-dd edznux-dd commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Hi! this is another (and I believe last! 😅 ) followup of #2361

This time I tried to focus on the probe part. This was my focus after investigating a few more crashes (segfault) that we discovered internally.

Some of these parsers are quite complex, but i've tried to keep the change simple and minimal.

I've decided to invert the condition for

if (scur->name != NULL && scur->protocol != NULL &&
		    strlen(scur->name) + strlen(scur->protocol) <= XICFG_STRANS_MAXKEYLEN) {

as otherwise, the Skipping (name, protocol) translation for service branch would have needed a goto (because of the strcpy)

I've added regression test + reproducer inputs for the fuzz harnesses as well.
A few fuzz harnesses have been added as a new commit of the PR #2365

I believe this covers a big part of the "probes" of openscap and should help with the reliability during the parsing of arbitrary data.

The fuzzers were compiled with multiple sanitizer, so it discovered a few uninitialized variable and other UB.

Note:
I am aware of #2349 but this supersedes that PR by fixing other bugs:

  • l_size = inlen on no-newline line -> heap-overflow memcpy (scanner, section)
  • section for(;;) unbounded read past inmem
  • *strchr(buf,' ') NULL-deref on embedded-NUL content (two sites)
  • xiconf_parse_section entry guard (inoff >= inlen reads past buffer)
  • recursive xiconf_service_free -> stack overflow (we made it iterative)
  • scur->type = "" literal later free()'d -> invalid free + leak
  • op_assign_str leak on repeated attribute

Happy to collaborate if you believe the PR 2349 should be merged first.

Thank you!

Comment thread src/OVAL/probes/unix/xinetd_probe.c Fixed

@Mab879 Mab879 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review the finding from Sonar and GitHub security findings.

Comment thread src/OVAL/probes/unix/xinetd_probe.c Fixed
Comment thread src/OVAL/probes/unix/xinetd_probe.c Fixed
@edznux-dd edznux-dd force-pushed the fix/xinetd-probe-memory-safety branch from 38a411a to 68e1aff Compare June 19, 2026 15:55
continue;
}

xiconf_add_cfile (xiconf, pathbuf, xifile->depth + 1);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive:
This path is used as an include in xinetd.... If you control a xinetd include directive, you can already run arbitrary code?
I'm not sure what would be a safe guardrail here.... Removing .. and all would break real configs?

if (inctype == XICONF_INCTYPE_FILE) {
strncpy (pathbuf, inclarg, sizeof(pathbuf)-1);
dD("includefile: %s", pathbuf);
xiconf_add_cfile (xiconf, pathbuf, xifile->depth + 1);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive:
This path is used as an include in xinetd.... If you control a xinetd include directive, you can already run arbitrary code?
I'm not sure what would be a safe guardrail here.... Removing .. and all would break real configs?

@edznux-dd edznux-dd force-pushed the fix/xinetd-probe-memory-safety branch from 68e1aff to 23da35c Compare June 19, 2026 16:35
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

3 participants