Repository navigation
Conversation
…eport assets
The report PDF generator used WeasyPrint's default URL fetcher, which
resolves file:// URLs. Template HTML is user-editable, so any <img> or
background URL pointing at file:// made the renderer read arbitrary
local files on the server (e.g. /etc/passwd, /proc/self/environ).
normalize_asset_url(type="pdf") legitimately rewrites asset:// URLs to
file://{asset.file.path} under REPORT_ASSETS_BASE_PATH, so file:// is
kept but restricted to that base path. ftp and other schemes are
rejected as well.
kalt2212
force-pushed
the
fix/reporting-pdf-file-fetcher
branch
from
November 16, 2026 19:15
a405f1c to
b20f562
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ee.reporting.utils.generate_pdfrenders user-editable template HTML with WeasyPrint and the default URL fetcher, which resolvesfile://URLs. Any<img src="file:///etc/passwd">(or CSSurl(), background image, etc.) embedded in report template HTML or rendered markdown makes the PDF renderer read arbitrary local files on the server (e.g./etc/passwd,/proc/self/environ, SSH keys) and embed the content in the generated PDF that is then downloadable by the user.Fix
Adds
ReportAssetURLFetcher, aURLFetchersubclass, and uses it ingenerate_pdf:http,httpsanddataURLs keep working (remote images, remote fonts).file://URLs are kept ONLY when the resolved path is insideREPORT_ASSETS_BASE_PATH, which is whatnormalize_asset_url(..., type="pdf")legitimately produces when it inlinesasset://report assets asfile://{asset.file.path}. Report assets keep rendering exactly as before.file://path (and other non-http(s)/data schemes) is rejected, so the renderer can no longer read arbitrary local files.Verification
Runtime-tested against WeasyPrint 70.0 (the version pinned in
api/tacticalrmm/requirements.txt), exercising the exact patched code:<img src="file:///tmp/poc_red.png">embeds the local file in the PDF (2260 -> 2593 bytes) - arbitrary local read confirmed;file:///tmp/poc_red.pngandfile:///etc/passwdare rejected (image omitted, no file read);file://<REPORT_ASSETS_BASE_PATH>/asset.pngstill embeds (2260 -> 2589 bytes), so the report asset feature is unaffected.Added
api/tacticalrmm/ee/reporting/tests/test_pdf_url_fetcher.pycovering outside-path rejection, inside-path allowance,../traversal and non-http protocol rejection.