Repository navigation
Hold drawcustom images and fonts to Home Assistant's allowlists - #149
Open
g4bri3lDev wants to merge 1 commit into
Open
g4bri3lDev wants to merge 1 commit into
g4bri3lDev wants to merge 1 commit into
Conversation
g4bri3lDev
marked this pull request as draft
October 13, 2026 14:04
drawcustom passed its payload straight to the renderer, which opens any absolute path and fetches any http(s) URL that a `dlimg` url or a font names. upload_image already checks URLs against `allowlist_external_urls`; drawcustom checked nothing. Bump odl-renderer to 0.5.15, which asks the caller before it loads a source, and answer with Home Assistant's own allowlists: - a `dlimg` http(s) URL must be in `allowlist_external_urls` - a `dlimg` file path and an absolute font path must be in an allowed folder (`www`, the media folders, or `allowlist_external_dirs`) 0.5.15 also stops a font name from climbing out of the font folders with `..`, and limits each image download to 30 seconds and 32 MB. Data URIs, hidden elements and fonts given by name are unaffected. Payloads that load images from URLs outside the allowlist stop working until the URL is added to `allowlist_external_urls` in configuration.yaml.
g4bri3lDev
force-pushed
the
fix/drawcustom-allowlist
branch
from
October 13, 2026 14:10
50ff6cd to
a653338
Compare
g4bri3lDev
marked this pull request as ready for review
October 13, 2026 14:10
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.
Summary
drawcustompassed its payload straight to the renderer, which opens any absolute path and fetches any http(s) URL that adlimgurl or a font names.upload_imagealready checks URLs againstallowlist_external_urls;drawcustomchecked nothing.This bumps
odl-rendererto 0.5.15, which asks the caller before it loads a source (OpenDisplay/odl-renderer#43), and answers with Home Assistant's own allowlists:dlimghttp(s) URL must be inallowlist_external_urls(the same rule asupload_image, reusingurl_not_allowed).dlimgfile path and an absolute font path must be in a folder Home Assistant allows:www, the media folders, orallowlist_external_dirs. The check ishass.config.is_allowed_path, so symlinks and..out of an allowed folder are refused. The renderer calls it from its drawing thread, not the event loop.The integration only supplies the policy (
_source_guard). Which element fields name a source is the renderer's knowledge and stays there, so new element types are covered without a change here. A refusal arrives asSourceNotAllowedErrorand is turned into aServiceValidationErrorfor the whole call, since the payload is the same for every target.The renderer bump also brings two fixes that need no integration code:
...Data URIs, hidden elements (the renderer never loads them) and fonts given by name are unaffected.
Breaking change for existing payloads
A
dlimgthat loads from an http(s) URL stops working until that URL is added toallowlist_external_urlsinconfiguration.yaml. This includes URLs that point at the user's own Home Assistant. Files underwwwand the media folders keep working without configuration, as do the documented font locations.Not in this PR
The service registrations are unchanged; the actions are not made admin-only.
Strings
New exception
path_not_allowedinstrings.jsonandtranslations/en.json. Other languages are left to the translation workflow.Testing
scripts/test: 247 passedscripts/test --min-ha: 247 passeduv run ruff check .,uv run ruff format --check .,scripts/verify_translations.py: cleanThe new tests run the real renderer rather than a mock: each refused source (image URL, image path, font path, font name with
..) fails with the right error and makes no HTTP request; a symlink and a..path out of an allowed folder are refused; an allowlisted file and a bundled font still render with a hidden disallowed element in the payload. The URL allowlist is tested on the guard directly, because Home Assistant's HTTP test mock lackscontent_length, which the renderer's size limit reads.