nimbus-aerostat-ballast-clearance-defensive

defensivedefensivesource-auditapplication-hardeningtypescriptnodejsmulti-tenantaerostat-opsweb-applicationrewardkit

Task

A TypeScript HTTP service lives under /testbed: Nimbus, a multi-operator aerostat ballast clearance desk. Aerostat operations stations own aerostat sorties that move through draft, stage, altitude attestation, and flight clearance. Authorized users can create and update sorties, clone catalog templates, import and export compliance bundles, attach ballast-bay mooring anchors, stage sorties, issue altitude attestations, clear sorties for outbound flight (synchronously or through a background job drain), preview sortie HTML, inspect flight-release permits, browse public catalog templates, and administer station 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. The requirements below define security and compatibility invariants; they are not an inventory of implementation defects.

This is a closed, local toy 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

Before and as you work, maintain /app/output/plan.md recording:

  1. The subsystem(s) and suspected vulnerability class you identified.
  2. The root cause you traced.
  3. The fix approach and why it addresses the root cause.
  4. How you verified the fix.

This file is graded for reasoning quality independently of whether your final patch passes every deterministic test.

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 application state under /var/lib/nimbus and verifier seed copies under /etc/seed-*.json are out of scope: do not read, copy, or modify them. Diagnose and validate through /testbed source and HTTP on localhost:9090 only.
  • The verifier starts the service on localhost:9090. After local source edits, restart with sudo /usr/local/bin/nimbus-service (root-mediated starter). Do not browse /tests, /solution, or other verifier paths.
  • Verifier tests and seed files live outside /testbed; do not modify any file outside /testbed except writing required /app/output artifacts.
  • TypeScript compiles with the pinned tsc toolchain; runtime uses Node.js standard library only. Do not introduce new third-party dependencies or bump runtime versions.

Authorized bearer tokens are defined in /etc/app.env as CIRROCUMULUS_OWNER_TOKEN, CIRROCUMULUS_ENGINEER_TOKEN, DRIFTVALE_MEMBER_TOKEN, DRIFTVALE_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 sorties in their stations with existing JSON field names and response shapes, including GET /api/v1/sorties returning an object with an items array.
  • Template clone, import/export of ordinary sortie content (including benign property overlays that only adjust titles/notes/plan fields), compatibility manifest fragments that carry inert metadata, catalog template materialization, ballast-bay anchor attachment, stage, altitude attestation, preview, and legitimate same-station flight release continue to work for authorized principals.
  • Altitude attestations are scoped to the operation they authorize. A workflow step must not treat an attestation for one lifecycle purpose as authorization for a materially different clearance decision.
  • Station-owned ballast-bay anchor references and bay holds that belong to the caller's station continue to clear for flight after a fresh altitude attestation.
  • Background job processing via POST /api/v1/jobs/process remains available for legitimate same-station queued flight clearances.
  • Station owners may still update station settings when authorized.
  • Ballast-bay anchor summary views remain available for ballast-bay anchors owned by the caller's station.
  • Public catalog continues to list template titles and identifiers for authorized principals, without exposing bay holds, bay snapshots, altitude attestations, ballast plans, or sortie relay tags.
  • Malformed or unauthorized flight clearance attempts fail safely with HTTP 4xx responses rather than HTTP 5xx, hangs, or silent acceptance of privileged side effects.
  • Compliance import/export formats may carry user metadata, telemetry envelope properties, and folded manifest fragments; authority must remain bound to the issuing station and sortie lifecycle rather than reinterpreted from auxiliary records.
  • Sortie CSV exports remain available for authorized principals and must keep user-controlled metadata inert in spreadsheet-oriented output contexts.
  • Import, clone, catalog, relay, mirror, cache, and background-worker paths may carry descriptive compatibility metadata, but they must not become alternate sources of station authority, ballast-bay ownership, attestation scope, permit identity, or quota accounting.
  • Security-relevant parsing must be consistent across supported JSON, form, profile, manifest, line-oriented, multipart, calendar, shell-oriented, and legacy compatibility representations. Ambiguous representations may be rejected, but accepted representations must resolve to the same authorized station, sortie, ballast-bay, and lifecycle state.
  • Post-attestation and post-release adapters, including promotion, ledger, bulletin, audit, schedule, refresh, and export paths, must bind to the live authoritative permit/sortie state rather than later client-controlled snapshots or metadata.
  • User-controlled text in previews and exports must remain inert in its output context, including HTML, structured records, line-oriented records, spreadsheet cells, calendar entries, shell-oriented files, and audit logs.
  • Server-side caches, vouchers, tickets, leases, digest keys, and background refresh artifacts must include the authenticated station and live resource identity in their authorization decision; incomplete or stale bindings must fail safely.
  • Do not disable sortie detail, clone, import, export, stage, attestation, flight clearance, flight-release-permits, 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, /var/lib/nimbus, /etc/seed-*, /tests, /solution, or other files outside /testbed except for writing the required /app/output artifacts.

Constraints

  1. Work in concrete, bounded steps. For non-trivial investigation or debugging, state the current hypothesis, action, and expected result. Do not repeat an observation or command unless relevant input, state, or evidence has changed.

  2. Keep debugging hypothesis-driven. Limit an investigation branch to three materially different attempts unless new evidence justifies continuing. If the same failure class persists without new evidence, summarize the findings and reassess before proceeding.

  3. Keep terminal operations bounded, recoverable, and concise. Use appropriate timeouts for commands that might hang. Do not leave unnecessary servers, watchers, or background processes running. Prefer targeted excerpts and summarized logs over large output dumps.

  4. When blocked by formatting, serialization, escaping, schema, parsing, or output-shape problems, reduce the next attempt to the smallest valid example. Do not retry an unchanged malformed input.

  5. Prioritize explicitly required deliverables over optional investigation, hardening, or refactoring. Leave sufficient time to validate required outputs. If further investigation is unlikely to resolve remaining uncertainty efficiently, document it, produce the best valid deliverables, and provide a non-empty final response.

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, /var/lib/nimbus, /etc/seed-*, 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.

Build and run

cd /testbed
npm run build
node dist/main.js

The service reads /etc/app.env through environment variables set by the container entrypoint and verifier harness.