fix: WebSub hardening from the adversarial review (v2.10.1)
- Per-item error handling in the worker; hard time limits on requests - Notes with photos announced after attach; feed cache/ETag follow content_version - Keep failing subscriptions until lease end; retry DNS and render errors; hub.mode=denied for gone topics - Spec 5.1: decode unreserved chars, echo requested topic, ignore lease and secret on unsubscribe, case-insensitive Content-Type, refuse empty secret - Limits count pending requests per callback address; callback validation; request_id guards the verification race (migration 017) - Render once per topic per pass; likes only push /likes; Vary: Accept Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
409b8b31b4
commit
b2043286fa
17 files changed
+825
-151
No files matched your search
@@ -141,7 +141,12 @@ def _generate_feed_with_cache(format_name: str, non_streaming_generator):
|
||||
|
||||
# Caching enabled - use FeedCache
|
||||
feed_cache = get_cache()
|
||||
notes_checksum = feed_cache.generate_notes_checksum(notes)
|
||||
# The content version covers changes the note list doesn't show, such as
|
||||
# photos attached or captions edited (v2.10.1)
|
||||
from starpunk.database import get_db
|
||||
from starpunk.websub import get_content_version
|
||||
notes_checksum = (feed_cache.generate_notes_checksum(notes)
|
||||
+ ":" + get_content_version(get_db(current_app)))
|
||||
|
||||
# Check If-None-Match header for conditional requests
|
||||
if_none_match = request.headers.get('If-None-Match')
|
||||
@@ -508,15 +513,15 @@ def feed():
|
||||
)
|
||||
|
||||
# Route to appropriate generator
|
||||
if format_name == 'rss':
|
||||
return feed_rss()
|
||||
elif format_name == 'atom':
|
||||
return feed_atom()
|
||||
if format_name == 'atom':
|
||||
response = feed_atom()
|
||||
elif format_name == 'json':
|
||||
return feed_json()
|
||||
response = feed_json()
|
||||
else:
|
||||
# Shouldn't reach here, but be defensive
|
||||
return feed_rss()
|
||||
response = feed_rss()
|
||||
# The format (and its rel=self) depends on Accept (v2.10.1)
|
||||
response.headers.add('Vary', 'Accept')
|
||||
return response
|
||||
|
||||
|
||||
@bp.route("/feed.rss")
|
||||
|
||||
Reference in new issue
Block a user