Skip to content

fix(zk-tls): refuse a policy redaction that selects nothing - #293

Merged
lolaaimar merged 2 commits into
fix/zk-tls-prover-request-copyfrom
fix/zk-tls-empty-redaction
Nov 25, 2026
Merged

lolaaimar merged 2 commits into
fix/zk-tls-prover-request-copyfrom
fix/zk-tls-empty-redaction

Conversation

@nicolasLuduena

@nicolasLuduena nicolasLuduena commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #211, split out of #248. Stack: #291 → #292 → #293 → #294; merge in that order. Based on #292.

zkFetchPolicySchema accepted a redaction that selects nothing: {}, { regex: '' }, or all three keys empty. Reclaim's attestor-core then threw Expected either xPath, jsonPath or regex for redaction on every prove with a 2xx response. I checked that offline against the installed attestor-core 5.1.6. The schema now refuses it:

 redaction.superRefine
+  if no non-empty regex, jsonPath or xPath
+    issue "a redaction needs a non-empty regex, jsonPath or xPath"
   if regex is non-empty
     check it compiles under RE2

The dApp guide says so. It also fixes a typo there: the escape for a literal * in a body is *, and the guide showed a bare *.

Evidence

  • Before: zkFetchPolicySchema.parse accepted responseRedactions: [{}].
    After: this passes in law.test.ts:

    refuses a redaction that names no regex, jsonPath or xPath
    

Build, types, Biome and the full suite pass with the stack up to this PR: 770 passed, 4 skipped (the opt-in live checks).

No verification skill in this repo.

Merge Danger

Door: two-way

Blast Radius: zk-tls consumers

A policy with an empty redaction now fails when the client or attestor parses it. Before, it failed on every prove.

@nicolasLuduena nicolasLuduena left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lolaaimar

Copy link
Copy Markdown
Contributor

Nit on wording in the two prose spots: "refuses a redaction with no non-empty regex, jsonPath or xPath" is a triple negative, and it reads as if redactions are mandatory. Since the branch is already about empty redactions, say "empty".

.changeset/zk-tls-empty-redaction.md

-`zkFetchPolicySchema` refuses a redaction with no non-empty `regex`, `jsonPath` or `xPath`. Reclaim's attestor-core refused such a redaction on every prove, so a policy that has one now fails when the client starts.
+`zkFetchPolicySchema` refuses an empty redaction: one whose `regex`, `jsonPath` and `xPath` are all absent or empty. Reclaim's attestor-core refused such a redaction on every prove, so a policy that has one now fails when the client starts.

packages/zk-tls/docs/dapp-integration.md (~line 267)

-signed rules carry them is refused too. It also refuses a redaction with no
-non-empty `regex`, `jsonPath` or `xPath`, which Reclaim would refuse on every
-prove.
+signed rules carry them is refused too. It also refuses an empty redaction,
+whose `regex`, `jsonPath` and `xPath` are all absent or empty, which Reclaim
+would refuse on every prove.

"A redaction needs a non-empty regex, jsonPath or xPath" in the JSDoc and the error message is positive phrasing and reads fine, so I'd leave those and the test name alone.

One thing that tripped me up reading this: the paragraph just above says the selected slices are "the only parts of the response the witness, and so the evidence, ever sees". That isn't true for responseRedactions: [] — attestor-core's getBlocksToReveal treats an empty list as reveal-everything, which is the documented way to attest public data with nothing hidden. One clause here would answer "why is an empty array allowed?" before it gets asked.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 71a1c1a2-f979-4aaa-ab4a-2718d48b7dbe
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@lolaaimar
lolaaimar merged commit 93e8679 into main Nov 25, 2026
3 checks passed
@lolaaimar
lolaaimar deleted the fix/zk-tls-empty-redaction branch November 25, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants