Skip to content

Accept HTTP Signature requests for standalone key objects#2935

Merged
pfefferle merged 5 commits intotrunkfrom
fix/standalone-key-verification
Feb 19, 2026
Merged

Accept HTTP Signature requests for standalone key objects#2935
pfefferle merged 5 commits intotrunkfrom
fix/standalone-key-verification

Conversation

@pfefferle
Copy link
Member

Fixes #2934

Proposed changes:

  • Accept HTTP Signature requests where the keyId points to a top-level ActivityPub key object (e.g. CryptographicKey with publicKeyPem at the top level) instead of only supporting fragment identifiers on actor objects (e.g. #main-key).
  • For standalone keys, the owner actor is fetched and verified to confirm it references the same key ID, preventing spoofing.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Send an activity from a server that uses top-level signing keys (e.g. activitypub.bot) to a WordPress site with the ActivityPub plugin.
  • The signature should now be verified successfully instead of being rejected with "No Public-Key found".
  • Alternatively, run npm run env-test -- --filter=test_verify_http_signature_with_standalone_key_object to verify the new test passes.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch

Type

  • Fixed - for any bug fixes

Message

Accept incoming activities from servers that use standalone key objects for HTTP Signatures.

When a remote server uses a top-level ActivityPub object as its signing
key (e.g. https://example.com/user/ok/publickey) instead of a fragment
identifier (e.g. https://example.com/users/evan#main-key), signature
verification failed because the code expected a nested publicKey
structure on an actor object.

Extract key PEM resolution into a dedicated method that handles both
formats: standard actors with nested publicKey.publicKeyPem, and
standalone CryptographicKey objects with top-level publicKeyPem and
owner. For standalone keys, the owner actor is fetched and verified to
prevent spoofing.

Fixes #2934
Copilot AI review requested due to automatic review settings February 18, 2026 21:17
@pfefferle pfefferle added the Bug label Feb 18, 2026
@pfefferle pfefferle self-assigned this Feb 18, 2026
@pfefferle pfefferle requested a review from a team February 18, 2026 21:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for verifying HTTP Signatures when keyId points to a standalone ActivityPub key object (top-level publicKeyPem), and prevents spoofing by verifying the key relationship via the key’s owner.

Changes:

  • Extend remote public key extraction to handle standalone key objects and verify ownership by fetching the owner actor.
  • Add PHPUnit coverage for successful verification and rejection when the owner’s referenced key does not match.
  • Add changelog entry for the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/phpunit/tests/includes/class-test-signature.php Adds tests for verifying signatures with standalone key objects and mismatched-owner rejection.
includes/collection/class-remote-actors.php Extracts public key PEM from either actor publicKey.publicKeyPem or standalone key objects and verifies ownership.
.github/changelog/2935-from-description Adds changelog entry describing the fix.

- Add same-origin check: owner URL must share the same host as the key
  ID before fetching, preventing cross-origin spoofing attempts.
- Wrap test assertions in try/finally to ensure filter cleanup even on
  test failure.
The existing mismatched-owner test used different hosts, which was
caught by the same-host guard. This new test uses same-host key and
owner but with a non-matching publicKey.id to exercise the
back-reference verification path.
@pfefferle pfefferle merged commit dcc0cd0 into trunk Feb 19, 2026
10 checks passed
@pfefferle pfefferle deleted the fix/standalone-key-verification branch February 19, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accept HTTP Signature requests for keys that are top-level ActivityPub objects

3 participants