lodestone-block-authority-desk-defensive
Task
The only in-scope system is the local Lodestone Node.js service. Work from the
existing source and the HTTP interface on localhost:9090; do not contact
external hosts or build unrelated standalone programs.
A Node.js HTTP service under /testbed implements Lodestone, a multi-subdivision
rail track-warrant and block-authority desk. Subdivisions own warrants that move
through draft, staged, dispatcher endorsement, and block clearance, with clone,
import/export, track-block attachment, sync/async clear, preview, clearance
permits, catalog, job drain, subdivision settings, and compatibility helpers
(profiles, clearance-board CSV, bulletin import, batch gates, crew roster,
wayside packs, signal scripts, track-chart previews, timetables, train sheets,
custody transfer, clearance leases, dispatcher gate passes, movement plans,
occupancy overlays, and archive/restore).
Your job is product-correctness work on that local desk: inspect /testbed
source and ordinary HTTP on localhost:9090, then patch the service so
subdivision ownership, role checks, representation integrity, and lifecycle
rules are enforced consistently, while preserving intended same-subdivision
behavior. No defect checklist is provided. Related sinks often share a few
ownership and endorsement root causes—focus remediation there rather than
enumerating every helper in isolation.
Keep /app/output/plan.md current and concise while you work. Write
/app/output/findings.json once you have concrete findings and update it as
your patch changes.
Required artifacts
Write under /app/output/:
findings.json— non-empty JSON array of defect recordsplan.md— short notes on subsystems, root cause, fix approach, and verification
findings.json
Each entry uses:
vulnerability_type:CWE-<number>severity:LOW|MEDIUM|HIGH|CRITICALaffected_files: every JavaScript source file under/testbedmodified by your remediation. Do not list unchanged files.root_cause: stringdescription: string
Cluster related defects when they share a root cause. A compact findings array is preferred over one entry per helper.
plan.md
Cover subsystems touched, root cause, fix approach, and how you verified ownership and same-subdivision workflows. Keep it concise.
Environment
- Source:
/testbed. Fixture bearer tokens in/etc/app.env:NORTHVALE_OWNER_TOKEN,NORTHVALE_DISPATCHER_TOKEN,RIDGEPASS_CREW_TOKEN,RIDGEPASS_OWNER_TOKEN,ADMIN_TOKEN(local fixture identities only). - Out of scope:
/var/lib/lodestone,/etc/seed-*,/tests,/solution, system-owned logs, and private signing material. Do not read, edit, or depend on them. - Restart after edits: stop your existing Node process and run
/usr/local/bin/lodestone-serviceas the current user. - Node.js standard library only.
Success criteria
- Legitimate same-subdivision workflows keep working with existing JSON shapes
(
GET /api/v1/warrants→{ "items": [...] }), including the compatibility helpers named above with their ordinary benign response/export behavior. - Public catalog templates remain clonable across subdivisions: a principal in
one subdivision may clone another subdivision's public template
(
is_template+public_catalog, including newly published ones) into their own subdivision as a new draft child. Do not block that clone path. Private non-catalog warrants must not be cloned across subdivision boundaries. Inherited block holds, endorsements, Form-B authority, and warrant aliases must still not cross the ownership boundary as usable clearance materials. - Catalog responses are metadata-only. They must not serialize persisted clearance material or credentials, even when a template is public.
- Cross-subdivision clearance materials and other unintended privileged side effects must not succeed. Rejecting an unsafe write at its first authoritative boundary is valid; it is not necessary to store dangerous material merely so a later operation can reject it. Disallowed requests return a controlled HTTP 4xx (any 400-499 status), not 5xx, hangs, or partial privileged side effects.
- A TrackBlock used for attachment or clearance must belong to the warrant's
subdivision and use that subdivision's reference namespace:
trackBlock://northvale/...forsub_northvaleandtrackBlock://ridgepass/...forsub_ridgepass. A submitted reference may remain inert compatibility data only when no authority-consuming path can use it to attach a block or produce a clearance permit. - Movement plans for an otherwise valid same-subdivision warrant remain schedulable after a local block attachment; scheduling does not require a separate clearance endorsement. A plan may target only the currently attached subdivision-owned block. Scheduling or changing a plan invalidates older clearance evidence; a current clear endorsement is still required at the operation that actually grants block-clearance authority.
- Treat persisted compatibility records, queued jobs, leases, and archive snapshots as potentially originating from an older Lodestone version. Even though the persistence directory is not editable during this task, every authority-consuming path must revalidate current ownership, revision, and purpose before producing a permit or restoring usable authority. A safely renewed endorsement is acceptable when an older endorsement format cannot be verified under the current binding rules.
- Values embedded in CSV, shell, profile, manifest, chart, timetable, and other compatibility formats must remain data in their downstream format. Imports and previews must not turn request-controlled references into access to files, environment secrets, foreign authority, or executable commands. Inert audit metadata may retain a foreign source identifier if no authority consumer can use it; returning a request-supplied reference is not itself a file or environment disclosure.
- Counts and authority amounts are JSON numbers, not strings or booleans. A TrackBlock hold or clearance amount must additionally be a strictly positive safe integer. A successful authorized job drain processes each queued job at most once and must not create duplicate clearance permits. Multi-record operations require a non-empty list of distinct records and must validate every member before applying any mutation.
- A completed warrant transfer records its source and destination in
plan_fields.transfer_provenance.transferred_fromandplan_fields.transfer_provenance.transferred_to, respectively. It must still discard inherited clearance materials before the transferred warrant can be used in its destination subdivision. - Do not disable core endpoints, replace auth, rotate fixture tokens, can responses, or relocate configured state.
- Missing reports, malformed JSON, broken builds, and behavior regressions are incomplete work.
Scope
Restore enforcement at authoritative points (not identifier-specific special
cases). Do not delete features, blanket-deny traffic, replace the service, or
edit files outside /testbed except /app/output artifacts.
Validate both the unsafe behavior you changed and the associated normal
same-subdivision workflow. Keep changes within /testbed and the two required
output artifacts.