[bug]: web-bot-auth (TS): verify() rejects signatures covering another label's Signature-Agent member (§5.2.2)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 56/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- cryptography, node.js, typescript
調査の方向性
Read packages/web-bot-auth/src/index.ts around verifiedSignatureAgent (lines 232–246), then compare its label handling with the cited §5.2.1 and §5.2.2 requirements and the Appendix D.2 example. Reproduce with the supplied script and check the existing test for member keys independent of signature labels. Done means the conformant browser signature verifies while a signature missing a required covered component is rejected.
索引モデルが issue の本文から書いたものです。
説明
Summary
verify() rejects every signature that covers more than one keyed Signature-Agent member (signature must cover exactly one signature-agent member). draft-ietf-webbotauth-httpsig-protocol-01 §5.2.2 lets a signer cover another label's fields, and requires it to cover every component of that label's Signature-Input, which includes that label's Signature-Agent member. So a conformant outer signature always covers two keyed members, and verify() always rejects it. Appendix D.2 has exactly this shape.
The signature itself is valid: http-message-sig verifySignature with label: "browser" verifies the same request. The rejection comes from the count check in verifiedSignatureAgent (index.ts L232–L246).
Conversely, removing "signature-agent";key="agent" from the outer signature makes verify() accept it, although §5.2.2 forbids that (the component is listed in "signature-input";key="agent").
Spec
draft-ietf-webbotauth-httpsig-protocol-01, §5.2.1:
Its member keyed to the signature label MUST be signed as a component as defined in Section 2.1 of [HTTP-MESSAGE-SIGNATURES].
§5.2.2:
A signer MAY cover members from another signature label, which preserves evidence that another signer contributed to the request. A signer that covers "signature";key=X MUST also cover "signature-input";key=X, and MUST cover every component identifier listed in "signature-input";key=X.
Appendix D.2 signs browser=("@method" "@authority" "@path" "signature-agent";key="browser" "signature-agent";key="agent" "signature-input";key="agent" "signature";key="agent") and states: "The origin verifies each signature on its own." The same §5.2.2 paragraph and D.2 example are in draft-meunier-webbotauth-httpsig-protocol-01, the revision cited in the package README.
Reproduction
import { generateKeyPairSync, sign as edSign } from "node:crypto";
import { verify } from "web-bot-auth";
import { verifierFromJWK } from "web-bot-auth/crypto";
async function key() {
const { privateKey, publicKey } = generateKeyPairSync("ed25519");
const verifier = await verifierFromJWK(publicKey.export({ format: "jwk" }));
return { verifier, sign: (base) => edSign(null, Buffer.from(base), privateKey).toString("base64") };
}
const agent = await key();
const browser = await key();
const created = 1800000000;
const params = (k, c) =>
`;created=${c};expires=${created + 3600};keyid="${k.verifier.keyid}";alg="ed25519";tag="web-bot-auth"`;
// Shape of draft-ietf-webbotauth-httpsig-protocol-01, Appendix D.2
const agentInput = `("@method" "@authority" "@path" "signature-agent";key="agent")${params(agent, created)}`;
const agentSig = agent.sign(
`"@method": GET\n"@authority": origin.example\n"@path": /resource\n` +
`"signature-agent";key="agent": "https://agent.example"\n"@signature-params": ${agentInput}`
);
const browserInput =
`("@method" "@authority" "@path" "signature-agent";key="browser" "signature-agent";key="agent" ` +
`"signature-input";key="agent" "signature";key="agent")${params(browser, created + 1)}`;
const browserSig = browser.sign(
`"@method": GET\n"@authority": origin.example\n"@path": /resource\n` +
`"signature-agent";key="browser": "https://browser.example"\n` +
`"signature-agent";key="agent": "https://agent.example"\n` +
`"signature-input";key="agent": ${agentInput}\n` +
`"signature";key="agent": :${agentSig}:\n` +
`"@signature-params": ${browserInput}`
);
const request = () =>
new Request("https://origin.example/resource", {
headers: {
"signature-agent": `agent="https://agent.example", browser="https://browser.example"`,
"signature-input": `agent=${agentInput}, browser=${browserInput}`,
signature: `agent=:${agentSig}:, browser=:${browserSig}:`,
},
});
const keys = [agent.verifier, browser.verifier];
const resolver = (c) => keys.find((v) => v.keyid === c.keyid);
const now = new Date((created + 10) * 1000);
for (const label of ["agent", "browser"]) {
try {
const r = await verify(request(), { label, now, resolver });
console.log(label, "-> verified, signatureAgent:", r.signatureAgent.uri);
} catch (e) {
console.log(label, "->", e.message, "|", e.cause?.message);
}
}
Expected:
agent -> verified, signatureAgent: https://agent.example
browser -> verified, signatureAgent: https://browser.example
Actual:
agent -> verified, signatureAgent: https://agent.example
browser -> Verifier resolution failed | signature must cover exactly one signature-agent member
Possible fix
Pass the candidate label to verifiedSignatureAgent. When more than one keyed member is covered, select the one whose key equals the label (§5.2.1), and reject only if none does. The single-member case stays as it is (it also covers relabeling permitted by §6.6.1), so the existing test "authenticates a member key independent from the signature label" keeps passing. This could be part of #171; related to #102 and #193.
Environment
mainat ce5e54fd7e05dd8ae14fd56198cfcba7acb6082e, built withnpm ci && npm run build; npm[email protected]gives the same output- Node.js v22.23.4, macOS
- 主要言語
- Rust
- スター
- 182
- フォーク
- 49
- 平均マージ
- 1日 20分
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cloudflare/web-bot-auth のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cloudflare/web-bot-auth#203 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
cloudflare/web-bot-auth#172 ·
メンテナーはふだん 1 日以内に返信
-
Demo verifier rejects the dictionary-form Signature-Agent that draft -01 requires; accepts the legacy form対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
cloudflare/web-bot-auth#199 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 54/100
cloudflare/web-bot-auth#195 ·
メンテナーはふだん 1 日以内に返信
-
http-message-sig: trailing "#" in the target URI ends up in @path / @query対応中かも @konippi が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
cloudflare/web-bot-auth#194 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
cloudflare/web-bot-auth の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
pop-os/cosmic-applets#1641 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pop-os/cosmic-store#650 ·
-
CI/CD ignore-for-release
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
eclipse-ankaios/ankaios#844 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
hyperlight-dev/hyperlight-js#459 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信