WorkScope latest pointer accepts a contract that contradicts its verified bundle

Open Beginner friendly
#148 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, security

Research direction

Read src/devostasis/workscope/bundle.py, focusing on latest() lines 169–183, and inspect the existing tests that use the build() and publish() helpers. Confirm that a canonical pointer passes, then change only its contract to the other supported value and verify latest() raises ScopeError("latest pointer binding mismatch"); a matching historical v1 pointer should still pass.

Written by the indexing model from the issue text.

Description

Finding — the WorkScope latest pointer admits a contradictory contract field

Pinned repository source: release/0.6.0@6d935ee111e2efab7a5f7d7c8f8d050af8d35567; src/devostasis/workscope/bundle.py Git blob 2de1ef2b47b983ffad6f45bd32262cb4b8d655b1, latest() lines 169–183; src/devostasis/workscope/__init__.py blob a2cfa113dbc7904c6f0ca7c24ae85f2d749358ed. The source and CONTRIBUTING.md were read on 2026-11-17.

The canonical publish() writes the actual bundle contract into latest.json:

atomic(pointer, canonical_bytes({
    "contract": decoded["manifest.json"]["contract"],
    "bundle_id": bundle_id,
    "manifest_digest": digest_bytes(content["manifest.json"]),
    "project": identity(scope["subject"])
}))

latest() only requires data["contract"] in CONTRACTS, which currently includes both devostasis.work.v1 and devostasis.work.v2. It then validates the referenced bundle's digest, ID, project and CANONICAL context, but never compares the pointer's contract to decoded["manifest.json"]["contract"].

Thus a canonical, verified WorkScope v2 bundle can be left untouched while the mutable latest.json pointer is edited to say "contract":"devostasis.work.v1". The pointer remains shape-valid, and every existing binding predicate can pass, despite the pointer falsely naming a different replay contract. devostasis work verify --latest / replay --latest can then report VERIFIED for a pointer with internally contradictory metadata. The immutable bundle still independently verifies; this is a pointer metadata-consistency false acceptance, not proof that the returned bundle's contents are corrupt or that Vital evaluation changes.

Reproduction / verification boundary

An isolated exact-predicate control with both contracts in the actual CONTRACTS tuple produced: allowed-pointer-contract=True; bundle_id-match=True; digest-match=True; project-match=True; canonical-context=True; pointer-contract-equals-manifest-contract=False; the conjunction of all currently enforced predicates was True. This is a source/predicate reproduction, not imported full-package pytest or a live WorkScope CLI invocation.

Focused implementation (no semantic policy change)

Inside latest()'s final binding require, add the missing equality without changing the supported contract set:

 require(digest_bytes(content["manifest.json"]) == data["manifest_digest"] and
+        decoded["manifest.json"]["contract"] == data["contract"] and
         decoded["manifest.json"]["bundle_id"] == data["bundle_id"] and
         identity(decoded["scope.json"]["subject"]) == data["project"] and
         decoded["scope.json"]["subject"]["context"] == "CANONICAL", "latest pointer binding mismatch")

This is an implementation-local consistency check: canonical publish() already emits matching fields. It neither changes version dispatch nor the verified bundle's identity/replay.

Acceptance and verification shape
  1. Build/publish a real canonical WorkScope v2 bundle with the existing build()/publish() test helpers. Verify that latest(root), work verify --latest, and work replay --latest accept the unmodified pointer.
  2. Edit only latest.json["contract"] from the actual v2 value to the other supported v1 value; keep bundle_id, manifest_digest, project and every immutable bundle byte unchanged. Require latest(root) to raise ScopeError("latest pointer binding mismatch"); both CLI variants must fail, never emit VERIFIED. A later canonical publish() must not silently promote/rely on the contradictory pointer.
  3. Historical legitimate v1 WorkScope bundles/pointers whose two contracts match must still pass; existing pointer-digest tamper and replay regressions stay green. Add an implementation-local test and docs/conformance citation only if a permanent case ID is introduced.
  4. Run real offline pytest, bundle replay and installed-wheel verification, plus exact-head CI. Use a focused fix branch targeting release/0.6.0 and independent review before merging.
Deduplication and boundary

Searched open and closed Issues and PRs for "latest.json" "contract", "pointer" "contract", and "latest pointer" "binding". Existing #147 is about the unbounded actual read of latest.json, not a mismatched-but-allowed contract; #146 is about member read budgets. The fix may share a focused release PR with #147 if convenient, but preserve separate test coverage.

Permissions / limits: authenticated andy-zen-dev has pull=true, push=false, triage=false, maintain=false, admin=false. This issue is the actual durable deliverable; no branch, code commit, PR, merge or release is claimed. Full Devostasis pytest/CLI/CI on a fixing commit: NOT_RUN.

Dominant language
Python
Stars
6
Forks
1
Avg merge
6m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from drevendev/Devostasis

All issues in drevendev/Devostasis

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.