Skip to content

arkscript: Tighten custom policy validation - #1144

Open
sputn1ck wants to merge 2 commits into
mainfrom
kon/arkscript-reject-op-success
Open

arkscript: Tighten custom policy validation#1144
sputn1ck wants to merge 2 commits into
mainfrom
kon/arkscript-reject-op-success

Conversation

@sputn1ck

@sputn1ck sputn1ck commented Aug 13, 2026

Copy link
Copy Markdown
Member

What changed

  • require custom predicates to parse as complete standalone script fragments
  • reject unsupported tapscript opcodes in custom predicates
  • restrict typed CSV values to canonical non-zero block delays
  • apply the checks consistently across direct policy admission and the standard
    VTXO, vHTLC, and checkpoint builders
  • add regression coverage for malformed predicates and noncanonical CSV
    encodings

Why

Policy templates should have one interpretation across semantic validation,
script generation, persistence, and recovery. These changes align compiler and
validator behavior so malformed or ambiguous custom templates fail closed.

Compatibility and rollout

Built-in policy templates and canonical production delays are unchanged.
Persisted custom templates that use unsupported predicate fragments or
noncanonical CSV values will no longer compile and should be audited before
rollout.

Checks

  • go test ./lib/arkscript ./lib/tx/checkpoint ./lib/tx/oor
  • make lint-changed-local
  • make build
  • make fmt-changed
  • make tidy-module-check
  • make commitmsg-lint range="origin/main..HEAD"
  • git diff --check

Opaque condition predicates were assumed to only add restrictions, but
OP_SUCCESS makes tapscript succeed before the typed inner clause
executes. A partial data push can also consume that inner clause as push
data.

Require predicates to parse as complete fragments, reject OP_SUCCESS,
and compile each leaf during direct policy validation so every admission
path fails closed.
@sputn1ck
sputn1ck marked this pull request as ready for review August 13, 2026 14:01
Copilot AI lite review requested due to automatic review settings August 13, 2026 14:01
@sputn1ck

Copy link
Copy Markdown
Member Author

@claude please review

@claude

claude Bot commented Aug 13, 2026

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@sputn1ck
sputn1ck marked this pull request as draft August 13, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the lib/arkscript Condition.Predicate escape hatch so opaque predicate bytes cannot (a) short-circuit tapscript execution via OP_SUCCESSx or (b) change parsing boundaries via incomplete pushes that consume the typed inner clause.

Changes:

  • Validate Condition.Predicate as a complete standalone script fragment and reject any tapscript OP_SUCCESSx opcodes during Condition.Script() compilation.
  • Make ValidatePolicy fail closed by compiling every leaf upfront (and rejecting nil leaves) before applying structural policy invariants.
  • Add regression tests for OP_SUCCESSx opcodes, “OP_SUCCESS byte in pushdata”, and incomplete-push boundary smuggling; update predicate bytes in existing tests to remain valid under the new rules.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/arkscript/validate.go Compiles/leaves upfront (and rejects nil) so admission fails closed on unsafe/invalid predicate fragments.
lib/arkscript/validate_test.go Adds policy-level regression for OP_SUCCESS predicate rejection; updates predicate bytes to avoid incomplete pushes.
lib/arkscript/policy_template_test.go Updates test predicates to use a valid opcode (OP_NOP) under the new predicate completeness rules.
lib/arkscript/node.go Adds predicate safety validation (complete fragment + reject OP_SUCCESSx) to Condition.Script().
lib/arkscript/node_test.go Adds comprehensive predicate-safety regressions (all OP_SUCCESSx, pushed bytes, incomplete pushes).
docs/policy_arkscript_review_guide.md Documents the predicate safety boundary and the new bypass prevention guarantees.
docs/arkscript_spec.md Updates spec text to describe predicate validation constraints and removes brittle line references.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@claude

claude Bot commented Aug 13, 2026

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@sputn1ck
sputn1ck marked this pull request as ready for review August 13, 2026 14:05
Policy validation compared raw CSV operands even though consensus masks
reserved bits and treats the disable bit as a no-op. Restrict typed CSV
locks to canonical non-zero block delays so structural validation and
script execution enforce the same value.
@sputn1ck sputn1ck changed the title arkscript: Reject unsafe condition predicates arkscript: Reject predicate and CSV policy bypasses Aug 13, 2026
@sputn1ck
sputn1ck marked this pull request as draft August 13, 2026 14:51
@sputn1ck sputn1ck changed the title arkscript: Reject predicate and CSV policy bypasses arkscript: Harden predicate and CSV validation Aug 13, 2026
@sputn1ck sputn1ck changed the title arkscript: Harden predicate and CSV validation arkscript: Tighten custom policy validation Aug 13, 2026
@claude

claude Bot commented Aug 13, 2026

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@sputn1ck
sputn1ck marked this pull request as ready for review August 13, 2026 18:31
@claude

claude Bot commented Aug 13, 2026

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

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