Skip to content

Commit cff1c31

Browse files
committed
Clarify that -p has no effect with --recurse
The previous help text, inline comment, changelog entry, and CLI docs all stated that -p/--allow-private-address affects URLs discovered via --recurse, but recursive fetches hardcode `allowPrivateAddress: false` and never honor the option. Update the CLI help, the loader-split comment in `runLookup`, the 2.1.6 changelog entry, and the `-p` section of `docs/cli.md` so that they all describe the same actual behavior: the option only gates URLs discovered during --traverse, while --recurse always disallows private addresses. #696 #698 Assisted-by: Claude Code:claude-opus-4-7
1 parent 6924183 commit cff1c31

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

CHANGES.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ To be released.
1515
regression introduced in Fedify 2.1.0 when the CLI began forwarding
1616
the `allowPrivateAddress` option to the underlying document loader.
1717
URLs explicitly provided on the command line now always allow private
18-
addresses, while URLs discovered via [`-t`/`--traverse`] or [`--recurse`]
19-
still honor the option to mitigate SSRF attacks against private
20-
addresses. [[#696], [#698] by Chanhaeng Lee]
18+
addresses, while URLs discovered during [`-t`/`--traverse`] honor the
19+
option to mitigate SSRF attacks against private addresses. Recursive
20+
fetches via [`--recurse`] continue to always disallow private
21+
addresses regardless of the option. [[#696], [#698] by Chanhaeng Lee]
2122

2223
[`-t`/`--traverse`]: https://fedify.dev/cli#t-traverse-traverse-the-collection
2324
[`--recurse`]: https://fedify.dev/cli#recurse-recurse-through-object-relationships

docs/cli.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,10 +991,9 @@ fedify lookup http://localhost:8000/users/alice
991991
~~~~
992992

993993
The `-p`/`--allow-private-address` option additionally allows private
994-
addresses for URLs discovered via traversal or recursion. It only has an
995-
effect when used together with
996-
[`-t`/`--traverse`](#t-traverse-traverse-the-collection) or
997-
[`--recurse`](#recurse-recurse-through-object-relationships), since URLs
994+
addresses for URLs discovered during traversal. It only has an effect
995+
when used together with
996+
[`-t`/`--traverse`](#t-traverse-traverse-the-collection), since URLs
998997
embedded in remote responses are otherwise rejected to mitigate SSRF
999998
attacks against private addresses.
1000999

@@ -1004,7 +1003,7 @@ fedify lookup --traverse --allow-private-address http://localhost:8000/users/ali
10041003

10051004
> [!NOTE]
10061005
> Recursive fetches enabled by
1007-
> [`--recurse`](#recurse-recurse-through-object-relationships) continue to
1006+
> [`--recurse`](#recurse-recurse-through-object-relationships) always
10081007
> disallow private addresses regardless of this option.
10091008
10101009
### `-s`/`--separator`: Output separator

packages/cli/src/lookup.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ const suppressErrorsOption = bindConfig(
8484
const allowPrivateAddressOption = bindConfig(
8585
flag("-p", "--allow-private-address", {
8686
description: message`Allow private IP addresses for URLs discovered \
87-
via traversal or recursion. This option only has an effect \
88-
when used together with ${optionNames(["-t", "--traverse"])} \
89-
or ${optionNames(["--recurse"])}, since URLs explicitly \
90-
provided on the command line always allow private addresses.`,
87+
during traversal. This option only has an effect when used together \
88+
with ${optionNames(["-t", "--traverse"])}, since URLs explicitly \
89+
provided on the command line always allow private addresses and \
90+
recursive fetches via ${optionNames(["--recurse"])} always disallow \
91+
them.`,
9192
}),
9293
{
9394
context: configContext,
@@ -721,8 +722,10 @@ export async function runLookup(
721722
let server: TemporaryServer | undefined = undefined;
722723
// URLs explicitly provided by the user always allow private addresses,
723724
// so that local servers can be looked up without -p/--allow-private-address.
724-
// URLs discovered via traversal or recursion follow the option, since they
725-
// originate from remote responses and must be protected against SSRF.
725+
// URLs discovered during traversal follow the option to mitigate SSRF
726+
// against private addresses, while recursive fetches always disallow
727+
// private addresses regardless of the option (see the --recurse branch
728+
// below, which hardcodes `allowPrivateAddress: false`).
726729
const initialBaseDocumentLoader = await getDocumentLoader({
727730
userAgent: command.userAgent,
728731
allowPrivateAddress: true,

0 commit comments

Comments
 (0)