[bug]: http-message-sig accepts a Decimal `created`/`expires` and re-serializes it as an Integer in the signature base
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, typescript
- Ambito
- cryptography, security
Direzione di ricerca
Inizia in packages/http-message-sig/src/core.ts: leggi validateKnownParameters (intorno a L133-L151) e buildSignatureBase (intorno a L569-L580, chiamato vicino a L1032), oltre agli helper esistenti di scansione del testo grezzo rawParameterCount e assertNoRfc9651Syntax. Esegui la riproduzione dall'issue per confermare che il caso Decimal passa oggi, poi aggiungi un test usando created=1800000000.0. Fatto significa che created/expires contenenti un . vengono rifiutati mentre i valori Integer vengono ancora verificati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
RFC 9421 §2.3 defines created and expires as Integers. verifySignature accepts created=1800000000.0 (an RFC 8941 Decimal) and treats it as created=1800000000:
structured-headersparses Integers and Decimals into the same JSnumber(its readme: "Javascript can't differentiate between1.0and1"), so theNumber.isIntegercheck invalidateKnownParameters(core.ts L133) passes.buildSignatureBase(core.ts L569, called at L1032) re-serializes the parsed inner list, so@signature-paramscontainscreated=1800000000. RFC 8941 §4.1.5 serializes that Decimal as1800000000.0.
The value that is checked is the value that was signed, so this is not a forgery or time-window bypass. It is a strictness bug. A fractional value such as 1800000000.5 is already rejected. web-bot-auth verify() inherits the behaviour.
Spec
RFC 9421 §2.3:
created: Creation time as a UNIX timestamp value of type Integer. Sub-second precision is not supported.
expires: Expiration time as a UNIX timestamp value of type Integer. Sub-second precision is not supported.
RFC 9421 §3.2, step 4: "Examine the signature parameters to confirm that the signature meets the requirements described in this document [...]"
RFC 8941 defines Integer (sf-integer = ["-"] 1*15DIGIT, §3.3.1) and Decimal (sf-decimal = ["-"] 1*12DIGIT "." 1*3DIGIT, §3.3.2) as distinct types.
Reproduction
import { generateKeyPairSync, sign, verify } from "node:crypto";
import { verifySignature } from "http-message-sig";
const { privateKey, publicKey } = generateKeyPairSync("ed25519");
const verifier = { algorithm: "ed25519", verify: (data, sig) => verify(null, data, publicKey, sig) };
const signBase = (params) =>
sign(null, Buffer.from(`"@authority": example.com\n"@signature-params": ${params}`), privateKey).toString("base64");
const run = async (name, params, signature) => {
const request = new Request("https://example.com/", {
headers: { "signature-input": `sig1=${params}`, signature: `sig1=:${signature}:` },
});
try {
const r = await verifySignature(request, {
policy: { algorithms: ["ed25519"], requiredComponents: [], requiredParameters: [], now: 1800000010 },
resolveVerifier: () => verifier,
});
console.log(name, "-> verified", JSON.stringify(r.parameters));
} catch (e) {
console.log(name, "->", e.message);
}
};
const integer = `("@authority");created=1800000000;expires=1800003600`;
const decimal = `("@authority");created=1800000000.0;expires=1800003600.0`;
await run("A signed Integer, sent Decimal", decimal, signBase(integer));
await run("B signed and sent Decimal ", decimal, signBase(decimal));
Expected: both rejected, because created and expires are not Integers.
Actual:
A signed Integer, sent Decimal -> verified {"created":1800000000,"expires":1800003600}
B signed and sent Decimal -> Signature verification failed
Possible fix
Reject created/expires whose raw value in Signature-Input contains a .. http-message-sig already scans the raw field text (rawParameterCount, assertNoRfc9651Syntax). A test with created=1800000000.0 would cover it.
Environment
mainat ce5e54fd7e05dd8ae14fd56198cfcba7acb6082e (structured-headers2.1.1), built withnpm ci && npm run build; npm[email protected](structured-headers2.0.3) gives the same output- Node.js v22.23.4, macOS
- Lingua principale
- Rust
- Stelle
- 182
- Fork
- 49
- Merge medio
- 1g 20m
- PR unite (30g)
- 19
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cloudflare/web-bot-auth
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
cloudflare/web-bot-auth#172 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 56/100
cloudflare/web-bot-auth#202 ·
I maintainer di solito rispondono entro 1 giorno
-
Demo verifier rejects the dictionary-form Signature-Agent that draft -01 requires; accepts the legacy formForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 50/100
cloudflare/web-bot-auth#199 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 54/100
cloudflare/web-bot-auth#195 ·
I maintainer di solito rispondono entro 1 giorno
-
http-message-sig: trailing "#" in the target URI ends up in @path / @queryForse già presa @konippi l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 58/100
cloudflare/web-bot-auth#194 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cloudflare/web-bot-auth
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
topgrade-rs/topgrade#2540 ·
I maintainer di solito rispondono entro 1 giorno
-
Invalid JSON options for ngram and edge_ngram silently use defaultsForse già presa @Tilendlesa l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
noemaforge/vimanam#153 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno