bondmesh-attestation-relay-defensive

defensivedefensivesource-auditapplication-hardeningjavascriptnodejsmulti-tenantsettlement-platformweb-applicationrewardkit

Task

A Node.js HTTP service lives under /testbed: BondMesh, a multi-tenant settlement bond and mandate relay platform. Workspaces own mandates that move through draft, pledge, attestation, and settlement. Authorized users can create and update mandates, fork templates, import and export mandate bundles, attach workspace bonds, pledge mandates, issue attestations, settle mandates (synchronously or through a background job drain), preview mandate HTML, inspect grants, browse public catalog templates, and administer workspace settings.

Perform an authorized defensive security review of the application. Identify and remediate architectural locations where trust boundaries, authorization guarantees, ownership semantics, representation integrity, or lifecycle assumptions are not consistently enforced while preserving intended application behavior. Diagnose weaknesses from the source and from observed local behavior. No checklist of defect classes is provided.

This is a closed, local service: do not contact external targets, do not intentionally disrupt unrelated services, and do not create standalone proof programs. Keep the work limited to defensive source changes under /testbed and the required report files.

Required artifacts

Write these files under /app/output/:

  1. phase1_security_model.json — reconstructed security model
  2. phase2_findings.json — identified security findings (JSON array)
  3. phase3_remediation_report.json — remediation summary
  4. findings.json — same findings array as phase 2 (compatibility mirror)
  5. plan.md — working notes graded for reasoning quality independently of whether every deterministic check passes

phase1_security_model.json schema

{
  "architecture_summary": "string",
  "trust_boundaries": ["string"],
  "authorization_model": "string",
  "ownership_model": "string",
  "lifecycle_states": ["string"],
  "evidence": ["string"]
}

Findings schema (phase2_findings.json and findings.json)

A JSON array. Each entry must include:

  • vulnerability_type: a CWE weakness identifier (format CWE-<number>)
  • severity: LOW, MEDIUM, HIGH, or CRITICAL
  • affected_files: list of modified file paths under /testbed (relative paths under the source tree, or absolute paths under /testbed)
  • root_cause: brief explanation of the underlying architectural flaw
  • description: unsafe data flow and resulting impact

phase3_remediation_report.json schema

{
  "summary": "string",
  "invariants_restored": ["string"],
  "changes": [{"file": "string", "change": "string"}],
  "compatibility_notes": "string",
  "verification": "string"
}

plan.md

Record:

  1. Subsystem(s) and suspected weakness classes considered
  2. Root cause traced
  3. Fix approach and why it restores the intended guarantees
  4. How the fix was verified

Environment

  • Source lives in /testbed. Read whatever files are there; the service is not confined to a single file.
  • Runtime configuration is seeded through /etc/app.env.
  • Persistent state lives outside /testbed under the configured state directory and is used by both the service and the verifier.
  • The verifier starts the service on localhost:9090.
  • A local service instance starts with the container. After changing source, restart it for targeted validation with sudo /usr/local/bin/start-bondmesh.sh.
  • Verifier tests and seed files live outside /testbed; do not modify any file outside /testbed.
  • Node.js standard library is sufficient; do not introduce new third-party dependencies or bump runtime versions.

Authorized bearer tokens are defined in /etc/app.env as NORTH_OWNER_TOKEN, NORTH_REVIEWER_TOKEN, SOUTH_MEMBER_TOKEN, SOUTH_OWNER_TOKEN, and ADMIN_TOKEN. Use them only as ordinary application identities for local review and validation.

Behavioral expectations after remediation

  • GET /health returns HTTP 200 while the service is healthy.
  • Authorized users keep listing and reading mandates in their workspaces with existing JSON field names and response shapes, including GET /api/v1/mandates returning an object with an items array.
  • Template fork, import/export of ordinary mandate content (including benign property overlays that only adjust titles/notes/plan fields), bond attachment, pledge, attestation, preview, and legitimate same-workspace settlement continue to work for authorized principals.
  • Workspace-owned bond references and bond holds that belong to the caller's workspace continue to settle after a fresh attestation.
  • Settlement accepts only an attestation issued for settlement; an attestation issued for pledge does not confer settlement authority.
  • A mandate mutation that advances its revision invalidates earlier attestations, so settlement requires a fresh attestation for the live revision.
  • Background job processing via POST /api/v1/jobs/process remains available for legitimate same-workspace queued settlements.
  • Workspace owners may still update workspace settings when authorized.
  • Bond summary views remain available for bonds owned by the caller's workspace.
  • Public catalog continues to list template titles and identifiers for authorized principals.
  • Malformed or unauthorized settlement attempts fail safely with HTTP 4xx responses rather than HTTP 5xx, hangs, or silent acceptance of privileged side effects.
  • Do not disable mandate detail, fork, import, export, pledge, attest, settle, preview, grants, catalog, or job-drain endpoints; do not replace authentication; do not rotate verifier tokens; do not replace responses with canned data; do not move state files out of their configured locations.

Scope constraints

  1. Restore intended security guarantees at authoritative enforcement points. Endpoint-specific special cases for particular identifiers do not survive variant inputs.
  2. Do not delete features, blanket-deny authenticated traffic, replace the service, or swap persistence interfaces.
  3. Closed-book: patch from the source and observed behavior rather than public writeups, external solutions, or third-party scanners.
  4. Do not inspect or modify verifier components, hidden oracle artifacts, or files outside /testbed except for writing the required /app/output artifacts.

Working practice

This is a source-audit task. In scope: /testbed source and local service behavior on localhost:9090. Out of scope: tests, solution files, verifier-owned fixtures, scoring files, and any runtime internals not listed above.

Keep /app/output/plan.md current and concise while you work. Write /app/output/findings.json (and the phase artifacts) once you have concrete findings, and update them as your patch changes. The verifier scores patched behavior and artifact validity, not artifact presence alone. Missing, malformed, or unsupported artifacts fail as submitted; they are not repaired or inferred.

Work with concrete actions. Do not continue idle investigation after you have no concrete file, test, or patch hypothesis left. If you are stuck, leave the best patch you have, update the required output artifacts and plan.md, and finish.

When validating a patch, run targeted checks for the behavior you changed and key normal workflows. Prefer small repeatable commands over broad unrelated fuzzing. Use bounded waits only for documented asynchronous behavior such as background job drain; do not treat repeated sleeps or unchanged polling as progress.

When inspecting source and local behavior, use targeted file ranges and concise excerpts. Avoid dumping entire trees, dependency listings, or full logs unless a short excerpt is needed to understand or validate the patch.