Repository navigation
Reject unsupported document URL schemes when private addresses are allowed - #1293
Conversation
The only HTTP(S) scheme check in the built-in document loaders lived inside validatePublicUrl(), which both getDocumentLoader() and getAuthenticatedDocumentLoader() skip when allowPrivateAddress is enabled. An option meant to relax address validation therefore also disabled scheme validation, letting ftp:, file:, data: and other URLs reach the runtime's fetch(). The outcome depended on the runtime: Deno throws a generic TypeError instead of UrlError, so callers can treat it as a retryable failure, while Node.js successfully loads data: URLs, so a redirect or alternate link could make the loader return an arbitrary document. Both loaders now reject non-HTTP(S) URLs with UrlError before fetching, whether or not private addresses are allowed. The check runs on every URL the loaders follow, so redirect targets (including those after a double-knock signature fallback) and alternate documents found via the Link header or HTML <link> elements are covered too. HTTP(S) URLs with private addresses remain allowed. The guards mirror the ones added to 2.4-maintenance by the pull request below to keep the merge forward simple. Fixes fedify-dev#1292 fedify-dev#1291 Assisted-by: Codex:gpt-6-astra Assisted-by: Claude Code:claude-opus-5-5
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The change appears ready to merge after normal checks. No actionable risk remains identified. Pre-merge checks |
|
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
The built-in document loaders checked URL schemes only inside
validatePublicUrl(), and both skip that call whenallowPrivateAddressis enabled. Relaxing address validation therefore also disabled scheme validation, lettingftp:,file:, anddata:URLs reach the runtime'sfetch(). The result depended on the runtime: Deno throws a plainTypeErrorthat callers may treat as retryable, and Node.js actually loadsdata:URLs, so a redirect or alternate link could make the loader return a document of the remote server's choosing.getDocumentLoader()andgetAuthenticatedDocumentLoader()now reject anything other than HTTP and HTTPS withUrlErrorbefore fetching, independent ofallowPrivateAddress. The checks run in the recursiveload()in packages/vocab-runtime/src/docloader.ts and invalidateUrl()in packages/fedify/src/utils/docloader.ts, whichdoubleKnock()calls before following a redirect. Every followed URL already passes through one of these, so redirects and alternate documents need no separate checks. HTTP(S) URLs with private addresses still work.The guards are identical to the ones #1291 adds to 2.4-maintenance, so merging forward should only need the tests reconciled. Tests assert that unsupported URLs never reach
fetch()directly, through redirects or Link header/HTML alternates, or after a double-knock fallback from either signature spec.Fixes #1292.