Better error response to malformed headers (#35278)

This commit is contained in:
David Roetzel authored and GitHub committed 2025-07-08 09:31:04 +00:00
1 parent 71b2120e5c
commit 8ee6cee36e
4 files changed
+30

No files matched your search

@@ -64,6 +64,9 @@ module SignatureVerification
return (@signed_request_actor = actor) if signed_request.verified?(actor)
fail_with! "Verification failed for #{actor.to_log_human_identifier} #{actor.uri}"
rescue Mastodon::MalformedHeaderError => e
@signature_verification_failure_code = 400
fail_with! e.message
rescue Mastodon::SignatureVerificationError => e
fail_with! e.message
rescue *Mastodon::HTTP_CONNECTION_ERRORS => e
+2
View File
@@ -196,6 +196,8 @@ class SignedRequest
return if body_digest == received_digest
raise Mastodon::SignatureVerificationError, "Invalid Digest value. Computed SHA-256 digest: #{body_digest}; given: #{received_digest}"
rescue Starry::ParseError
raise Mastodon::MalformedHeaderError, 'Content-Digest could not be parsed. It does not contain a valid RFC8941 dictionary.'
end
def created_time