Repository navigation
fix: handle non-ASCII challenge nonces without TypeError - #383
Conversation
Signed-off-by: Imran Siddique <imran.siddique@opaque.co>
|
@lywinged, could you review #383 and approve it if the change looks right? It fixes the non-ASCII nonce crash from #381. Matching and mismatching Unicode cases are covered, and CI is green. Your review of #376 covered the related findings. These separate fixes are also ready for review:
Please start with #383 and review whichever others you have time for. Each PR includes its reproducer and test results. Please flag anything that needs changing before approval. #387 and #388 touch the same URI checker, so both checks need to survive when we combine them. |
lywinged
left a comment
There was a problem hiding this comment.
Checked at 267dbb1 against main at ccbd5b9. Every figure I can recompute here reproduces:
159 in tests/test_sign.py, the eight new cases, six of them failing with the three-line
production change reverted and the tests kept, mypy's 13 files, the 15 other generator tests,
and §3.2.2 carrying the rule. ruff check src tests scripts is clean. The Windows figures I
cannot reach, and your own note already settles what they mean: the five reproduce with the fix
removed, which is a controlled experiment on the machine where they happen. What I can add is
narrow, so take it as narrow: all 20 tests in tests/test_generators_reproduce_fixtures.py pass
on this Linux checkout, 20 of 20, no skips.
The fix is right. Three things, and the first is a line of code.
expected_nonce is verifier configuration and nothing checks its type
>>> verify_record(record, jwk, expected_nonce=b"a-nonce-value")
AttributeError: 'bytes' object has no attribute 'encode' # at sign.py:800
Five shapes, bytes, int, list, bool, dict, all AttributeError on the head. On main
all five are TypeError. So this is not a regression and neither is in the documented contract.
But TypeError is what Python raises for a caller who passed the wrong type, and an
AttributeError leaking out of .encode reads as the verifier breaking rather than as the
caller being told. The house answer is three lines above your change:
Both bounds are verifier configuration, not record data, and a malformed one is checked
before it is used -- see_check_seconds.
max_age_seconds and max_future_skew_seconds get that treatment and expected_nonce does not.
Not folded into the condition you already have, though: _check_seconds' docstring is explicit
that the point is a caller seeing "an error naming the cause" rather than a uniform refusal, and
raise ValueError("record runtime.nonce does not match expected_nonce") is the uniform refusal.
A separate line above it, in its shape:
if not isinstance(expected_nonce, str):
raise ValueError("expected_nonce must be a string")All five shapes then give that message, and your 159 stay green.
Record-side inputs are fine: schema validation at 694 refuses a missing runtime, a non-dict
runtime and a non-string nonce before the compare runs, so the isinstance(actual_nonce, str)
guard is now belt and braces. I could not find a record that reaches a wrong verdict.
The eight cases pin the verdict, not the reason compare_digest is there
Both of these are green on all eight:
actual_nonce.encode("utf-8") != expected_nonce.encode("utf-8")
actual_nonce != expected_nonceYour matrix does what it was written for, and the ("\u00e9", "e\u0301") case, one glyph spelled two ways, earns its place:
normalising both sides to NFC turns that one red and nothing else. This is a separate property,
not a gap in what you claimed. Worth closing while you are here because a constant-time
comparison is unobservable in a verdict, so what can be asserted is that the verdict comes from
it. Watch the first draft of that test, which I wrote and then broke on purpose: patching
compare_digest to record its arguments passes against a version that calls it and then decides
with != anyway. Returning False from the patch is what closes that, and it has to be narrowed
to bytes operands or the thumbprint compare at 771 intercepts it first.
import hmac # tests/test_sign.py does not import it yet
def test_the_nonce_verdict_is_decided_by_compare_digest(monkeypatch):
seen = []
real = hmac.compare_digest
def spy(a, b):
seen.append((type(a).__name__, type(b).__name__))
return False if isinstance(a, bytes) else real(a, b)
monkeypatch.setattr(hmac, "compare_digest", spy)
key = generate_key()
record = _fresh_record()
record["runtime"]["nonce"] = "n\u00f8nce"
signed = sign_record(record, key)
with pytest.raises(ValueError, match="record runtime.nonce does not match"):
verify_record(signed, key_to_jwk(key), expected_nonce="n\u00f8nce")
assert ("bytes", "bytes") in seenPasses on your fix, fails on both lines above and on the discard-the-result version.
compare_digest is imported inside verify_record, so the patch goes on hmac and not on the
module attribute. There are seven call sites in the package and nothing under tests/ asserts
any of them. #381 could not have reached the other six, for two reasons rather than one: five
compare _digest or jwk_thumbprint output, which is ASCII by construction, and
intent_bridge.py:316 compares _jcs output, which is bytes and so has no ASCII requirement
at all. Either way the nonce-only scope is right.
Two smaller ones
A record whose runtime.nonce is a lone surrogate, with expected_nonce set, raises
UnicodeEncodeError at 800, inside the compare that opens at 799. It stays in contract, because
that subclasses ValueError, and it is an improvement on main's TypeError for the same
input. Nothing about the ordering changed: canonicalization is after the compare on both sides,
which is why the same record still reaches CanonicalizationError when expected_nonce is
unset. One line only because it is the last member of #381's family.
#381 offered a second remedy, a base64url pattern on runtime.nonce. Declining it is right,
since it would reject records main accepts, but that leaves a description saying base64url with
nothing enforcing it, which is another instance of the family on #247 you are already tracking.
Worth a sentence there rather than here.
One question on the description: "ASCII controls" reads as a class of string next to the other
three, and there is no character in category Cc in the matrix. If it means control cases, fine.
Approving.
Signed-off-by: Imran Siddique <imran.siddique@opaque.co>
|
@lywinged I added both changes in 7897d82. Invalid non-string All 165 signing tests pass. Ruff, mypy and style checks pass. The full Windows run has 1,975 passing tests, 6 skips and the same five previously reproduced generator-fixture failures. CI is running on the new commit. I also clarified "ASCII control cases" in the description. The nonce format question remains separate from this fix; no base64url restriction was added. Could you confirm the follow-up looks right before we merge? |
lywinged
left a comment
There was a problem hiding this comment.
Checked at 7897d82. Both changes are right.
expected_nonce now raises before the comparison, and all five shapes I named reach it. The
comparison test does what you say: I reverted the production line to plain string comparison, to
plain byte comparison, and to a version that calls compare_digest and then decides with !=
anyway, and each one fails exactly that test. 165 pass here, CI is green on the head.
One thing that arrived while this sat: #386 merged, so the CHANGELOG.md conflict between the two
is now a conflict with main. git merge-tree against 74eafa0 reports that one file and nothing
else.
Approving.
Signed-off-by: Imran Siddique <imran.siddique@opaque.co>
…er has agentrust-io#383, agentrust-io#386, agentrust-io#387 and agentrust-io#388 fixed the four defects this harness reported, so the cases that recorded them stopped diverging and the ledger failed closed on five entries no case reached: the lone-surrogate revocation bundle (agentrust-io#382), `subject` and `appraisal.verifier` under ECMA-262 pattern semantics (agentrust-io#379), the IPv4-in-IPv6 literal with a leading zero (agentrust-io#380), and the non-ASCII nonce (agentrust-io#381). They leave the ledger rather than stay as claims nothing checks. Four counts move with them. The `c23-bundle-lone-surrogate` context used to diverge on every mutation and matched the first entry; now that it verifies like any other context, its cases fall through to the mutation families: m03 23 to 24, m04 23 to 24, m20/m21 30 to 32, m46/m47 16 to 17. The ledger's `reference` and the README's table no longer say 0.10.0 without qualification, because the behaviour under test is the tree's and the four fixes are not in that release. 1644 cases, 1412 identical, 232 known, 0 unexpected; ledger 8 entries, 33 pairs, 0 unreached; 12 published vectors, manifest sha256:869550bf03073ba3. Signed-off-by: chernistry <sanderchernitsky@gmail.com>
…ed against the Python one (#376) * feat(trace-verify-ts): add a TypeScript verifier for TRACE v0.2 records A specification with one implementation says whatever that implementation does. This is a second one, written from spec/trace-v0.2.md and schema/, and it runs on WebCrypto alone: no network, no filesystem, no platform module and no runtime dependency, so a record can be checked where there is no Python runtime. What it implements, with the rule each check comes from: - the profile cutover of section 2, with the superseded v0.1 identifier rejected under its own code rather than as an unknown profile; - RFC 8785 canonicalization, including section 3.2.2's requirement to reject an integer outside the JCS safe range and the I-JSON rule that a lone surrogate has no canonical form; - Ed25519 over the pre-image of section 3.2.2, the record with its signature member absent; - canonical unpadded base64url for the signature and for JWK members (RFC 4648 sections 5 and 3.5), so one byte string has one spelling; - RFC 7638 thumbprints, and the confirmation-key binding of section 3.2.2; - freshness and nonce, with the bounds section 3.2.2 states; - the three revocation outcomes of section 3.2.3 against a bundle the caller passes in, with a bundle defect reported as an outcome rather than thrown; - the chain digest of section 3.1.3, over the complete parent record with its signature present. The schemas are compiled ahead of time with ajv, so nothing is evaluated or fetched at run time, `pattern` is read as ECMA-262 as JSON Schema 2020-12 requires, and `format: uri` is asserted rather than annotated. The generator records the SHA-256 of every schema file it read. The order of the checks is the Python implementation's, so both report the same first failure for the same record. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * test(trace-verify-ts): cover the units, this repository's vectors and the build Three files. The unit tests pin the canonical forms and the refusals that have a published answer: RFC 8785 member ordering by UTF-16 code unit, the number and escape forms, the values that have no canonical form, the base64url alphabet and pad-bit rules, and the RFC 7638 section 3.1 example thumbprint. The vector tests run the canonicalization-boundary and revocation-bundle corpora through the verifier and check the outcome, the cause and every evidence member each vector states, plus the chain digest of every link in the delegation corpus. The third file tests the build rather than the logic: the compiled output imports nothing, so a platform module or a network call cannot arrive unnoticed; the schema digests the validators were generated from still match schema/; and every exported function refuses junk with the package's own error type rather than a TypeError, which is what a caller written against the documented contract catches. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * test(trace-verify-ts): score the two implementations against each other A second implementation is only evidence if something compares them. The harness generates a corpus, runs both sides over it and reports every case where they disagree. The corpus holds each record as text, not as a parsed object, because several cases exist to probe a difference that only survives in text: an iat written 1785000000.0, a lone surrogate in a string, a signature spelled with padding. Both runners parse the same bytes with their own JSON parser, which is part of what is compared. It covers a signed record under 24 verifier configurations with 59 mutations each, an RFC 8785 corpus, RFC 7638 thumbprints, the chain digest of every record in the delegation corpus, this repository's own vectors, and the published conformance vectors from a pinned checkout whose files are recorded by SHA-256 rather than vendored. The Python side reports a rejection as an exception, and two distinct checks raise the same message from the same helper called twice, so the classifier reads the traceback to ask which call site it came from, and looks the line numbers up in the installed source rather than writing them down. An exception it does not recognise is reported, not guessed. 1644 cases: 1280 agree exactly, including every published vector, every thumbprint and every chain digest. The other 364 are 13 classes argued in differential/known-divergences.json, which matches on both the case and the pair of reported reasons, so a new disagreement inside a listed family is reported rather than absorbed. Nothing was adjusted to match the other side. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * ci(trace-verify-ts): run the unit tests and the differential harness Two jobs. The unit job builds and tests on Node 20, 22 and 24: the floor is what the package declares and the ceiling is current, so a runtime leaving that matrix is a supported-versions decision rather than a CI adjustment. The differential job installs the Python implementation from this tree, checks out the published conformance vectors at a pinned commit, runs both sides over the generated corpus and fails on any disagreement that is not in the ledger. The vector checkout is allowed to fail: the corpus without it is this repository's own vectors plus the generated matrix, which is the larger part, and a verifier's CI should not go red because another repository is unreachable. Actions are pinned by commit, as the other workflows here are. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * docs(changelog): record the TypeScript verifier and what the differential run found Signed-off-by: chernistry <sanderchernitsky@gmail.com> * fix(trace-verify-ts): accept uppercase IPvFuture version flag Signed-off-by: Imran Siddique <imran.siddique@opaque.co> * differential: assert the published-vector count and hold the ledger in both directions The workflow tested for the trace-tests checkout at a path relative to trace-verify-ts, so the published-vector group never ran in CI: the one run logged 1632 cases where 1644 were expected, and nothing failed. The checkout is now required, generate_cases.py refuses a root it cannot read or that yields no record, and compare.py --expect-external N fails unless exactly N cases came from it. The manifest of vector digests is always written, printed with the count, and uploaded with the report. The ledger failed in one direction only: a declared divergence that stopped being reached lowered the number the run leads with and exited 0. Each entry now declares how many cases land on it, and an entry, a pair or a count the run does not bear out fails the run. Six pairs that attributed a signature or schema divergence to the bundle or trusted-key context move to the entries whose fix alone resolves them; the 364 is unchanged, its split is now 20/14/23/23/24/96/30/69/23/23/2/16/1. Setting the RFC 4648 unused-bits mask to zero, which one unit test already caught, now also fails the differential: entries 2, 3, 4 and 12 unreached, one pair of entry 1 never observed. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * differential: judge a published vector at a valid now generate_cases.py set now from the vector's own iat whenever that was an int, so a vector whose point is an iat outside the safe-integer range made the TypeScript verifier refuse the caller's argument before it read the record. now is taken from iat only inside [0, 2^53-1]. Against trace-tests cf30e9b the corpus goes from 1660/1295/364/1 to 1660/1296/364/0; the pinned corpus is unchanged. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * differential: a text either runner cannot parse is a verdict, not a crash oracle.py parsed record_json, revocation_bundle_json and value_json outside any try, so a text json.loads refuses, or one nested past the interpreter's stack, took the process down with the output file however far it got, where run.mjs reports parse_error and exits 0. Every runner on the Python side now reports parse_error for such a text, a RecursionError inside rfc8785 classifies as canonicalization_failed, which is what the other side reports for the same input, and run.mjs gains the same parse arm on its thumbprint and chain-digest runners. Latent in the committed corpus, since all 1644 texts parse; live for the external one, which is arbitrary JSON from another repository. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * differential: classify the accepted-profiles refusal main now raises Since #116 the reference refuses a record whose eat_profile is outside the verifier's accepted set with a new message. The oracle mapped only the previous wording, so after merging main the 25 m16-profile-unknown cases reported unclassified against the TypeScript profile_unsupported. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * docs(trace-verify-ts): four acceptances rather than five, and what two sentences hold The changelog entry and the description said five of the 13 divergence classes were records the reference accepts. Four are (entries 3, 8, 9, 10); the other two are rejections of a different shape; and the "patterned field" clause covered signature, where the reference rejects. The clause now names subject (U+000A, U+000D, U+2028) and appraisal.verifier (format: uri, U+000A). The schema-digest test is described by what it holds, that a build came from exactly the schema bytes it names, rather than by a rebuild case no invocation in the repository reaches. The canonicalization divergence is named as its class, magnitude 2^53 and above, of which 1.0e+21 is the corpus's instance. A README paragraph says what the differential cannot observe: a constant-time property, and a length function the schema does not exercise. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * refactor(trust-record-verify): rename the package to @agentrust-io/trust-record-verify The package, its directory, the workflow and its path filters, the README and the changelog entry take the new name. The corpus seed in differential/generate_cases.py keeps its original spelling, as the named constant CORPUS_SEED_DOMAIN: every key in the 1644-case corpus derives from it, so changing it reissues the corpus and moves outcomes that known-divergences.json pins by case and by count. Differential against agentrust-trace 0.10.0 after the rename: 1644 cases, 1280 identical, 364 known, 0 unexpected; ledger 13 entries, 71 pairs, 0 unreached; 12 published vectors, manifest sha256:869550bf03073ba3. Unit tests 74/74 on Node 25. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * test(differential): retire the five divergences the reference no longer has #383, #386, #387 and #388 fixed the four defects this harness reported, so the cases that recorded them stopped diverging and the ledger failed closed on five entries no case reached: the lone-surrogate revocation bundle (#382), `subject` and `appraisal.verifier` under ECMA-262 pattern semantics (#379), the IPv4-in-IPv6 literal with a leading zero (#380), and the non-ASCII nonce (#381). They leave the ledger rather than stay as claims nothing checks. Four counts move with them. The `c23-bundle-lone-surrogate` context used to diverge on every mutation and matched the first entry; now that it verifies like any other context, its cases fall through to the mutation families: m03 23 to 24, m04 23 to 24, m20/m21 30 to 32, m46/m47 16 to 17. The ledger's `reference` and the README's table no longer say 0.10.0 without qualification, because the behaviour under test is the tree's and the four fixes are not in that release. 1644 cases, 1412 identical, 232 known, 0 unexpected; ledger 8 entries, 33 pairs, 0 unreached; 12 published vectors, manifest sha256:869550bf03073ba3. Signed-off-by: chernistry <sanderchernitsky@gmail.com> * fix(trust-record-verify): tighten three input guards encodeBase64url takes a Uint8Array and nothing else that views a buffer: a Uint16Array iterates 16-bit values, which the byte loop encoded as the wrong bytes, and a DataView is not iterable, which reached a native TypeError instead of the package's own error. canonicalJson refuses an object with a symbol-keyed member instead of dropping it: Object.keys never listed the symbol, so a value the module documents as unsupported canonicalized to a form missing a member. verifyDelegationLink holds the same plain-object contract for its options as verifyRecord; an array, a Date or a class instance was accepted before. A test for each, with the same-shaped value that is accepted beside it. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> * differential: the schema location and the key source are part of the verdict; duplicate ids fail the run compare.py treated two schema_invalid verdicts as agreeing whatever member each side faulted, and only listed the difference as commentary. The check order is shared, so the first member faulted must be the same one: the location is now part of the summary a case has to match, and a difference there is a divergence to be argued in the ledger like any other. At this head every one of the 600 schema failures agrees on the member. VerificationResult.trustedKeySource was outside the comparison, so a regression in it would pass as long as the thumbprint matched, which it does whenever the caller passes the key the record embeds. run.mjs now reports it; oracle.py states the same fact the way verify_record resolves it, since the Python result carries no such member; compare.py matches the two. A unit test pins the case the thumbprint cannot tell apart. Both runners key verdicts by case id, so a second case under one id replaced the first without a trace, and the external ids fold "/" into "-", which is one way two files can collide. generate_cases.py fails on a duplicate id and compare.py fails on a verdict file that repeats one. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> * ci(trust-record-verify): run the differential on spec changes too A normative change under spec/ can move the verdict a case is expected to produce without touching the schemas, the examples or either implementation. The path filter listed all of those and not the specification itself, so such a change skipped the differential. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> * docs(trust-record-verify): align the README and the changelog with the ledger at this head The README said the 136 remaining cases were seven classes each appearing once per verifier configuration; three do (24 each), the others land on 32, 17 and 14 cases, and one is in the RFC 8785 corpus, not the mutation matrix. The retired entries were listed as "six" in five items, with two folded into one. The table now carries each entry with its pinned count, and the six retired entries are six items. The changelog entry still gave the first run's figures (1280 identical, 364 in 13 classes); it now gives this head's (1508, 136 in 7) and says what left and what remains. Both also say that the differential compares the location of a schema failure and the source of the verifying key. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> * docs(trust-record-verify): state the section 3.2.3 subset this package implements The revocation consumer checks the bundle signature and applies a statement naming the trusted key as the section's fallback for a record without a usable receipt. It does not verify a statement's own signature against the section 3.2.1 hierarchy, and it takes no inclusion entry ID, so the last_valid_entry_id rule is not applied. The module header said so; the README's limits and the option's own documentation now say it too, and name it as the same subset the Python implementation documents. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> * fix(trust-record-verify): re-baseline the differential on the 0.11.0 reference; decode the signature where it does Against main the differential no longer held. The reference's decoder refuses base64url that is not canonical since #418 (0.11.0), with two messages the oracle did not classify, and it reports a padded signature or one in the standard alphabet at its decoding step, which comes before its schema check. This implementation consulted the schema first. The run read 1644 cases, 1429 identical, 57 known, 158 unexpected, 4 ledger entries unreached. - oracle.py classifies "signature is not canonical base64url" and "JWK 'x' is not canonical base64url". - verifyRecord decodes the signature ahead of the schema, which is the order the module header already promised. A padded signature, one in the standard alphabet, one with a trailing newline and one of an impossible length are signature_malformed on both sides; the empty string decodes to no bytes and is still refused by the schema's pattern on both sides. A test pins all five. - Five ledger entries that no case reaches are retired: non-zero unused bits in a signature, a truncated signature, a non-canonical x in cnf.jwk or in the caller's key (the reference refuses them now), and the trailing newline (the order here moved). Now: 1644 cases, 1611 identical, 33 known, 0 unexpected, 2 ledger entries, none unreached, 12 published vectors. README and CHANGELOG carry those figures, and the CHANGELOG entry is back under Unreleased, where the merge with main had left it inside the 0.11.0 section. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> * fix(trust-record-verify): type tests that do not depend on the realm; run the differential on dependency changes Review points on #376. encodeBase64url tested `instanceof Uint8Array`, which is false for a Uint8Array made in another frame or worker. It now reads the typed array's [[TypedArrayName]] through the %TypedArray% toStringTag getter: true for a Uint8Array of any realm, Buffer included, and false for a Uint16Array, a DataView, an ArrayBuffer, an array, and an object that only carries its own Symbol.toStringTag, which a test on Object.prototype.toString would accept. isPlainObject compared the prototype with this realm's Object.prototype, so a plain object from another realm was refused: the options of verifyDelegationLink and verifyRecord, and equally a record parsed by another frame's JSON.parse, a JWK, and any object reaching the canonicalizer. It now accepts an object with no prototype or with a prototype that has none of its own. Arrays, Dates, class instances and Object.create({}) are refused as before, from either realm. The revocation store was tested with `instanceof Set`, the same fault; it now asks the Set size getter, which answers for a Set of any realm and throws for anything else. Tests build each value in a second realm with node:vm: a record, its options and a revocation set from there verify as the same values do here. The workflow's path filters gain requirements/** and pyproject.toml, which the differential job installs the reference from. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> * fix(trust-record-verify): own-member reads, a stricter plain-object test, profile on the result, symbol keys on arrays Four points from review of 0655596. isPlainObject accepted Object.create(Object.create(null)): a prototype with a null prototype is not Object.prototype. It now accepts a null prototype or a realm's Object.prototype, recognised by its own constructor being that realm's Object, and nothing else; cross-realm {} and Object.create(null) stay accepted. verifyRecord read cnf, iat and runtime through the prototype chain while the signature pre-image is built from own members; every read is now own(), and an inherited cnf or iat stands for nothing. Tests cover the one-hop prototype in both realms, and a record from a realm whose Object.prototype carries a non-enumerable iat or cnf, which the schema sees and verification does not. VerificationResult reports profile and the complete acceptedProfiles set, as section 3.3 requires; ACCEPTED_PROFILES is exported. Both runners of the differential emit the two fields and compare.py folds them into the verified equivalence. canonicalJson refused a symbol-keyed member on an object and not on an array; the array branch now refuses it too, with a test. The differential against current main: 1643 of 1644 identical. The ledger entry for iat written as a float or with an exponent is unreached since #404 and leaves the ledger; README, CHANGELOG and the ledger note carry the figures. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> * fix(trust-record-verify): compile the schema validators with ownProperties Review of e4300b7: the signature pre-image is built from a record's own members, while ajv's required and properties tests and its for-in walks also saw inherited ones. cnf, iat and runtime were read with own(); the other required members (subject, model, policy and the rest) were not held to the same rule by the schema. The validators are now generated with ownProperties: true, so required and properties test own properties and every object walk uses Object.keys. A regression test moves each member of a signed record onto a cross-realm Object.prototype, enumerable and not: a required member is schema_invalid, eat_profile is profile_missing, an optional member falls outside the pre-image and is signature_invalid, and cnf.jwk one level down is schema_invalid at cnf. Without the option 11 of those cases fail. Differential against current main: 1643 of 1644 identical, unchanged. Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> --------- Signed-off-by: chernistry <sanderchernitsky@gmail.com> Signed-off-by: Imran Siddique <imran.siddique@opaque.co> Signed-off-by: Alex Chernysh <73943355+chernistry@users.noreply.github.com> Co-authored-by: Imran Siddique <imran.siddique@opaque.co>
What this changes
A signed record carrying a non-ASCII nonce such as
nøncemadeverify_recordraiseTypeErrorwhen a challenge was supplied. Compare UTF-8 bytes withcompare_digestso matching strings verify and mismatches raise the documentedValueError. No Unicode normalization is applied.Eight regression cases cover ASCII control cases, matching non-ASCII and supplementary-plane strings, mismatches on either side, and visually similar strings with different encodings. Six failed before the fix. Reported by @chernistry in #381.
Closes #381.
Type of change
Implementation bug fix. No schema, wire-format, or normative text changes.
Spec section
Implements the existing challenge-nonce matching rule in TRACE v0.2 section 3.2.2.
Validation
Checklist