sanitize build slugs against path injection and match registry domains on parsed hostname - #15
Merged
Merged
Conversation
…registry domains on parsed hostname
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.
1. Path injection in static site builder (py/path-injection, alerts #12 - #20 )
_rel_slug() built the output path of each resource page directly from
the prefix and local name of IRIs in the loaded ontology - i.e. from
user-controlled input. An ontology containing an IRI whose local part
was e.g. "../../../../etc/x" would make build_html() create directories
and write .html/.ttl/.rdf files outside the build directory.
'-' for everything else), strips leading/trailing '.'/'-' so '..'
can never survive, and caps length at 100 chars. A segment reduced
to empty is treated as "namespace IRI, no local part" and the page
is skipped, same as before.
path and skips it unless it is inside the resources directory.
(resource_url_index/resource_url_resource) and file paths stay
consistent.
2. Incomplete URL substring sanitization (py/incomplete-url-substring-
sanitization, alert #3)
_is_likely_ontology() matched registry domains with a substring check
on the whole URL, so "https://evil.com/w3id.org/x" was classified as
a trusted ontology registry. It now matches the parsed hostname
exactly (or as a subdomain), and the W3C namespace check matches
against the URL path instead of the raw string. Impact was limited to
the is_visualizable UI flag - the API re-validates URLs on load - but
the check is now correct.