Private
Public Access
Allow only http(s) URLs from feeds and OPML, at storage and render (R2-S1, #33)
A feed's channel link, an entry's link and an OPML htmlUrl were stored as given and rendered in href attributes (bulk writes skip model validation), so a malicious feed could supply a javascript: or data: link. CSP is a second layer, not the control. apps.core.urlutils accepts only absolute http(s) URLs. Fetching stores channel/entry links through it — relative links now resolve against the feed's own URL instead of being stored as dead relative paths — OPML import skips non-http(s) feed URLs and blanks unsafe htmlUrl, and the add-feed form rejects non-http(s) (URLField also allows ftp). A safe_http_url template filter guards the two places a feed-supplied URL becomes a link (the article's "Original" link and the dashboard), so values already in the database from before this fix are neutralized too. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
85914f9107
commit
41f99e9405
13 files changed
+192
-7
No files matched your search
@@ -192,3 +192,21 @@ class TestExportOPML:
|
||||
exported = export_opml(alice)
|
||||
assert b"<opml" in exported
|
||||
assert b"<outline" not in exported
|
||||
|
||||
|
||||
class TestUnsafeOPMLUrls:
|
||||
def test_non_http_feed_urls_are_skipped_and_unsafe_html_urls_blanked(self):
|
||||
from io import BytesIO
|
||||
|
||||
from apps.feeds.opml import parse_opml
|
||||
|
||||
xml = b"""<?xml version="1.0"?><opml version="2.0"><head/><body>
|
||||
<outline text="Bad" xmlUrl="javascript:alert(1)"/>
|
||||
<outline text="FTP" xmlUrl="ftp://example.com/feed.xml"/>
|
||||
<outline text="Good" xmlUrl="https://example.com/feed.xml" htmlUrl="javascript:alert(2)"/>
|
||||
</body></opml>"""
|
||||
|
||||
entries = parse_opml(BytesIO(xml))
|
||||
|
||||
assert [e["feed_url"] for e in entries] == ["https://example.com/feed.xml"]
|
||||
assert entries[0]["site_url"] == ""
|
||||
Reference in new issue
Block a user