Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Fix webhook signature verification for payloads containing special characters

オープン
#351 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

@IamPritamAcharya がすでに取り組んでいます。

2026年4月15日 から。

  • #352 @IamPritamAcharya による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
java
領域
security

調査の方向性

Utils.verifyWebhookSignature から始めて、HMAC 検証の前に現在の String ペイロードと webhook secret がどのように変換されているかを調べます。特殊文字またはマルチバイト文字を含むペイロードで Scala Play のシナリオを再現し、その後、raw byte 入力と UTF-8 の明示的な処理によって期待される署名が生成されることを、ASCII として有効な入力の動作を変更せずに確認します。

索引モデルが issue の本文から書いたものです。

説明

In certain environments, such as Scala Play 2.8/2.9, Utils.verifyWebhookSignature may return false for valid webhook requests when the payload contains special characters or multi-byte text. The issue appears to come from the SDK accepting only a String, while framework-level parsing can alter the raw request body before verification.

Problem

Utils.verifyWebhookSignature currently accepts only a String.

This issue is especially likely when a user uses a framework such as Play to read the request body into a String before passing it to the SDK, since webhook validation is safest when performed on the raw body bytes rather than a parsed or re-encoded string.

Reproduction

  1. Receive a Razorpay webhook containing special characters or multi-byte characters in fields such as customer name or notes.
  2. Parse the HTTP body as a String in Scala Play.
  3. Pass the resulting string to Utils.verifyWebhookSignature(...).
  4. Observe that the method returns false even though the webhook is valid.

Proposed Fix

1. Add an overload that accepts raw bytes

Introduce a new method in Utils that accepts byte[] so developers can pass the raw request body directly:

public static boolean verifyWebhookSignature(byte[] payload, String expectedSignature, String webhookSecret) throws RazorpayException {
    // Use raw bytes directly to avoid encoding issues
}
2. Use UTF-8 explicitly in string-based hashing

Update the existing implementation so string payloads are always converted using UTF-8:

// Current
byte[] hash = sha256_HMAC.doFinal(payload.getBytes());

// Proposed
byte[] hash = sha256_HMAC.doFinal(payload.getBytes(UTF-8));
//Similar charset as used for encoding the webhook secret to bytes

This makes the behavior deterministic across environments and avoids platform-dependent failures.

Why This Matters

Razorpay’s webhook validation flow depends on the exact payload used to generate the HMAC signature. Any transformation of the request body — including charset conversion, normalization, or parsing into a framework-specific string type — can break verification. A byte-array overload would let developers verify the webhook against the exact raw request body, which is the safest approach for cryptographic checks.

Related Reference

A similar webhook signature verification issue has already been documented here Python SDK, Issue 65, where valid webhook signatures failed to verify in real-world setups.

I am happy to submit a PR for this if the approach is approved.

主要言語
Java
スター
75
フォーク
83
PR マージ指標
30日以内にマージされた PR はありません

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

razorpay/razorpay-java のほかの issue

razorpay/razorpay-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。