http-message-sig: trailing "#" in the target URI ends up in @path / @query

Aperta
#194 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@konippi ci sta già lavorando.

Dal 19/11/2026.

  • #200 di @konippi — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start by reading requestTarget in core.ts and trace how it handles URL fragments for @path, @query, and @target-uri. Reproduce the examples in the issue and check how the project tests cover target URI fragments. The change is complete when a URI ending in a bare # is handled consistently with fragments and the signature matches the target sent on the wire; the issue asks whether to reject or strip it, so that behavior needs a decision.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A target URI with a fragment is rejected, but one ending in a bare # gets through and the # lands in the signature base.

import { createSignature } from "http-message-sig";

const signer = {
  algorithm: "ed25519",
  sign(data) {
    console.log(new TextDecoder().decode(data) + "\n");
    return new Uint8Array(64);
  }};

for (const targetUri of ["https://example.com/path#", "https://example.com/a?b#"]) {
  await createSignature(
    { kind: "request", method: "GET", targetUri, fields: [] },
    { signer, components: ["@path", "@query"], parameters: { created: 1794312000 } }
  );
}

0.3.0 and main at 01c0d10:

"@path": /path#
"@query": ?
"@signature-params": ("@path" "@query");created=1794312000

"@path": /a
"@query": ?b#
"@signature-params": ("@path" "@query");created=1794312000

requestTarget in core.ts checks url.hash !== "", but url.hash is empty for a bare #. fetch drops the # on the wire, so the server computes /path and the signature doesn't verify. @target-uri has the same problem.

I can send a PR. Should it be rejected like #frag, or stripped?

Lingua principale
Rust
Stelle
182
Fork
49
Merge medio
1g 20m
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cloudflare/web-bot-auth

Tutte le issue di cloudflare/web-bot-auth

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.