COSE HeaderMap: header() and equality use Map reference equality; build() creates duplicate label entries
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- security
Research direction
Start with packages/evolution/src/cose/Header.ts, especially header() and [Equal.symbol], then inspect packages/evolution/src/cose/Key.ts around EdDSA25519Key.build(). Add the described regression test for a text label, and verify that header() returns the bytes, structurally equal HeaderMaps compare correctly, and setHeader does not leave duplicate logical labels.
Written by the indexing model from the issue text.
Description
Summary
HeaderMap stores headers in a JS Map keyed by Label objects, but Label uses structural equality while Map.get/Map.set use reference equality. As a result:
- (a) the public
header()accessor callsthis.headers.get(label)with a freshly builtLabel, so it always returnsundefined; - (b)
HeaderMap[Equal.symbol]looks up keys fromthisinthat's map by reference, so two structurally-equal HeaderMaps never compare equal; - (c)
setAlgorithmIdfollowed bysetHeader(labelFromInt(1n), ...)inserts two distinctLabelobjects for logical key 1, leaving two entries in the map.
No functional or security impact today: the security paths (verifyData, algorithmId, keyId) iterate the map manually with Equal.equals and are unaffected, header() is unused, and the duplicate label-1 entries collapse to a single correct entry on CBOR encode (encode re-keys by primitive value). Latent correctness / cleanup.
Affected
packages/evolution/src/cose/Header.ts
- header() (L260-262):
this.headers.get(label)uses reference equality -> always undefined - [Equal.symbol] (L43-51):
that.headers.get(key)uses reference equality -> HeaderMaps never equal
packages/evolution/src/cose/Key.ts
- EdDSA25519Key.build() (L248-252):
setAlgorithmId(1n)thensetHeader(labelFromInt(1n), ...)create two entries at logical key 1
Fix
Stop keying a JS Map by objects with custom equality. Either intern Label instances so structurally-equal labels share a reference, or replace the map lookups (header(), equality, setHeader overwrite) with Equal.equals-based iteration (as the working accessors already do). Making setHeader overwrite an existing logical key also removes the duplicate label-1 entries in build().
Regression test
- given: a HeaderMap built with
setHeader(labelFromText("address"), bytes) - before fix:
hm.header(labelFromText("address"))returns undefined - after fix: returns the bytes
Must FAIL on main today and PASS after the fix.
Reference
Reported informally (HeaderMap reference-equality). No live security impact; cleanup for a broken public accessor and a fragile build path.
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 30
- Avg merge
- 13h
- Merged PRs (30d)
- 14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IntersectMBO/evolution-sdk
-
dependencies good first issue
Difficulty 1/5 Under an hour Newbie friendliness 93/100
IntersectMBO/evolution-sdk#541 ·
-
bug external-review
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
IntersectMBO/evolution-sdk#530 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
IntersectMBO/evolution-sdk#518 ·
-
enhancement external-review
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
IntersectMBO/evolution-sdk#456 · 1 comment ·
-
bug external-review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
IntersectMBO/evolution-sdk#398 ·
All issues in IntersectMBO/evolution-sdk
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
linagora/twake-calendar-frontend#1377 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
EclipseFdn/open-vsx.org#13385 · 1 comment ·
-
front-end UI/UX
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
S: triage
Difficulty 1/5 Under an hour Newbie friendliness 85/100