Repository navigation
Cut the handle host at a path - #3899
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found this during the security review of #3882. For
acct:,mailto:andxmpp:handles the host is taken off the string itself, and it was only cut at?and#. Soacct:user@example.com/xgave the hostexample.com/x: a domain block onexample.comdid not match, and the WebFinger lookup went tohttps://example.com/x/.well-known/webfinger. That lookup usually fails, so the second block check on the resolved actor URL did not catch it either.Proposed changes:
Webfinger::get_identifier_and_host()cuts the host at/too, like it already does for?and#. The identifier itself is not cut.Other information:
I strip the path instead of rejecting the handle. A rejected handle has no host, and the block check treats a missing host as not blocked, so
user@blocked.example/xwould still get through.The host stays after the last
@. I triedwp_parse_url()instead, but it reads a local part with#,?or/as the host (user#x@evil.comgaveuser) and finds no host inxmpp://guest@example.com. With the last@,user@example.com/@evil.comis looked up onevil.com, and that is also the host the block is checked against.A port stays in the host, as before. With a valid port the lookup works, and the block check on the resolved actor URL catches a blocked domain.
Two side effects: an XMPP address with a resource part (
user@host/resource) now gets the right host, andacct:application@<site>/xis accepted as the application resource, like?xand#xalready were.Testing instructions:
wp eval 'var_dump( \Activitypub\Webfinger::get_host( "acct:user@example.com/x" ) );': it returnsexample.com, on trunkexample.com/x.vendor/bin/phpunit --filter test_get_host_cuts_handle_suffixes.Changelog entry
Changelog Entry Details
Significance
Type
Message
Domain blocks now also apply to handles that have a path after the domain, like @user@example.com/x.