Fix entity resolution for DocBook 4 SYSTEM entities

Enable DTD loading and entity resolution in yelp-build and yelp-check
XML parsers so that DocBook 4 SYSTEM entity declarations are processed
correctly. Also harden PathResolver against XXE file disclosure by
validating that resolved paths remain within the source directory.

Resolves: RHEL-46281
This commit is contained in:
Radek Duda 2026-08-04 17:49:03 +02:00
parent 012f30c3d0
commit 87c5ae13cf
3 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,23 @@
--- a/tools/yelp-build.in
+++ b/tools/yelp-build.in
@@ -285,7 +285,7 @@
return None
def get_xml(self, infile, path):
- parser = lxml.etree.XMLParser()
+ parser = lxml.etree.XMLParser(load_dtd=True, resolve_entities=True, no_network=True)
parser.resolvers.add(PathResolver(os.path.realpath(infile.absdir), path))
tree = lxml.etree.parse(infile.absfile, parser=parser)
def pathloader(href, parse, encoding=None):
--- a/tools/yelp-check.in
+++ b/tools/yelp-check.in
@@ -234,7 +234,8 @@
def get_xml(self, xmlfile):
# FIXME: we can cache these if we add a feature to run multiple
# checkers at once
- tree = lxml.etree.parse(xmlfile.absfile)
+ parser = lxml.etree.XMLParser(load_dtd=True, resolve_entities=True, no_network=True)
+ tree = lxml.etree.parse(xmlfile.absfile, parser=parser)
if self.xinclude:
lxml.etree.XInclude()(tree.getroot())
return tree

View File

@ -0,0 +1,16 @@
--- a/tools/yelp-build.in
+++ b/tools/yelp-build.in
@@ -147,7 +147,12 @@
def resolve(self, uri, id, context):
if os.path.exists(uri):
- return self.resolve_filename(uri, context)
+ realpath = os.path.realpath(uri)
+ if realpath.startswith(self.srcdir) or any(
+ realpath.startswith(os.path.realpath(p) + '/') for p in self.path
+ ):
+ return self.resolve_filename(uri, context)
+ return None
if uri.startswith(self.srcdir):
ref = uri[len(self.srcdir):]
else:

View File

@ -4,7 +4,7 @@
Name: yelp-tools
Version: 42.1
Release: 8%{?dist}
Release: 9%{?dist}
Summary: Create, manage, and publish documentation for Yelp
License: GPL-2.0-or-later
@ -14,6 +14,8 @@ BuildArch: noarch
# https://gitlab.gnome.org/GNOME/yelp-tools/-/merge_requests/12
Patch: url-handler.patch
Patch: yelp-fix-entity-resolution.patch
Patch: yelp-harden-xxe-pathresolver.patch
BuildRequires: meson
BuildRequires: pkgconfig(yelp-xsl)
@ -64,6 +66,11 @@ wraps things up in a developer-friendly way.
%{_datadir}/aclocal/yelp.m4
%changelog
* Fri Jul 31 2026 Radek Duda <rduda@redhat.com> - 42.1-9
- Fix entity resolution for DocBook 4 SYSTEM entities
- Harden PathResolver against XXE file disclosure
Resolves: RHEL-46281
* Mon Jan 27 2025 Michael Catanzaro <mcatanzaro@redhat.com> - 42.1-8
- Add URL handler to open help files in web browser
Resolves: RHEL-76398