Skip to content

Sanitize strings to prevent UTF errors#2357

Open
jan-cerny wants to merge 1 commit into
OpenSCAP:mainfrom
jan-cerny:utf8_error
Open

Sanitize strings to prevent UTF errors#2357
jan-cerny wants to merge 1 commit into
OpenSCAP:mainfrom
jan-cerny:utf8_error

Conversation

@jan-cerny
Copy link
Copy Markdown
Member

@jan-cerny jan-cerny commented May 14, 2026

If a string is collected by a probe, we will sanitize this string before converting it to SEXP. This will ensure that no errors related to UTF enconding can happen during the whole processing. This way we will fix multiple errors emitted by pcre2 or libxml2 libraries that are caused by providing non-UTF strings.

Resolves: https://redhat.atlassian.net/browse/RHEL-171005

Review hints:

  1. touch /mnt/$(printf "evil_filename_\334_non_utf8_character")
  2. oscap xccdf eval --remediate --profile xccdf_org.ssgproject.content_profile_cis --rule xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml
  3. oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --rule xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml - this returns error with latest released openscap
  4. install the build by Packit from COPR from this PR
  5. repeat step 3 - it will return pass

@jan-cerny jan-cerny added this to the 1.4.5 milestone May 14, 2026
@jan-cerny jan-cerny force-pushed the utf8_error branch 3 times, most recently from 915fc1c to c2db8ec Compare May 15, 2026 08:17
If a string is collected by a probe, we will sanitize this string
before converting it to SEXP. This will ensure that no errors related
to UTF enconding can happen during the whole processing. This way
we will fix multiple errors emitted by pcre2 or libxml2 libraries that
are caused by providing non-UTF strings.

Resolves: https://redhat.atlassian.net/browse/RHEL-171005
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@jan-cerny jan-cerny marked this pull request as ready for review May 15, 2026 09:20
@jan-cerny jan-cerny changed the title Sanitize strings for regular expression matching Sanitize strings to prevent UTF errors May 15, 2026
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.

1 participant