Can WebFinger resolve subject to a different domain?

My immediate assumption is yes, it can, because someone may use a specific domain merely as a gateway, and point to a different domain for resolution.

e.g. https://activitypub.directory/.well-known/webfinger?resource=acct%3Ajulian%40activitypub.space (note the different TLD)

Resolving to:

{"subject":"acct:julian@activitypub.space","aliases":["https://activitypub.space/uid/1","https://activitypub.space/user/julian"],"links": ...

However, this is a potential security issue because said directory could then poison the resulting data, especially if cached by a user of that webfinger directory.

Am I wrong about that? In the meantime I’ve updated NodeBB’s code to strictly enforce webfinger lookups so if a response subject has a different hostname, then the webfinger query result is considered invalid.