basalt-ssh-frame-desk-defensive

defensivedefensivesource-auditapplication-hardeningcssh-brokerbinary-protocolrewardkit

Task

Context and authorization

This is a self-contained software maintenance exercise that runs entirely inside an offline evaluation container. Everything under /testbed is a purpose-built simulator written for this exercise. It is not a real product and has no real users, no real credentials, and no real deployment: it does not implement or interoperate with the real SSH protocol, and it routes only to local stub endpoints inside the same container. There is no external network access and no third-party system is involved at any point.

You are the maintainer of this code and are fully authorized to read it, reason about its correctness, and modify it. The requested work is ordinary defensive engineering: make the code consistently enforce the invariants it already claims to enforce, and keep documented behavior working. All work stays inside the container and the findings you write are consumed only by this exercise's automated grader.

The service

A C service lives under /testbed: the Basalt SSH Frame Desk, a simulated session-multiplexing broker fixture. Operators authenticate once, receive signed session tickets, open multiplexed channels for interactive shells, file-forward paths, and compressed subchannels, and route traffic to registered simulated controller endpoints through a forward worker. The desk supports keepalive frames, channel lifecycle teardown, and legacy compatibility hooks for older operator clients.

This is a source-audit task. In-scope materials are the application source under /testbed, the fixture identity tokens documented in /etc/app.env, and normal interaction with the running broker on localhost:8022 using the binary frame protocol described in /testbed/docs/protocol.md. Out-of-scope materials are tests, solution files, verifier internals, sealed originals under /opt, and any runtime state not reachable through documented application interfaces.

Objective

Perform an authorized defensive maintenance and hardening review of the application. Identify and correct locations where enforcement surfaces, or other implicit correctness guarantees claimed by the product and its protocol docs, are not consistently enforced, while preserving intended application behavior. Focus on these domains (details are discoverable from /testbed/docs/protocol.md and the source):

  • wire framing and nested record length accounting
  • channel reassembly, lifecycle ownership, and compressed-subchannel attach
  • session ticket issue, import, resume, bag/lineage, and MAC binding
  • forward staging, authorization, policy generation, leases, and receipts
  • host-label / display-alias representation consistency at flush time
  • ownership and cleanup across handles, attributes, and shared acknowledgements
  • diagnostic logging of operator-supplied host labels
  • capability, grant, provenance, and binding freshness across issue-time versus flush-time checks
  • multiplex, credit, route, and operator-identity affirmation without widening ticket authority
  • integrity, escrow, padding, pairing, and peer-liveness checks that must hold together when traffic is flushed
  • accounting, exclusivity, ordered commit completeness, and epoch-bound integrity pins documented by the protocol

Diagnose root causes from the source and from observed local behavior rather than from any assumed defect checklist. Start with the navigation, architecture, state-transition, representation-vocabulary, and message-family sections in /testbed/docs/protocol.md; use each message-specific section for its exact wire and workflow contract.

Preserve the documented wire contract while hardening. /testbed/docs/protocol.md defines the reply layout and status octet for each message: a declined request must still reply with the request's own msg_type and that message's status octet set to 0. Declining a complete frame by closing the connection, omitting the reply, or reporting success is a behavior regression. Transport framing that is not a complete frame is exempt from the reply contract and may simply be discarded.

Documented state-changing operations must keep working. An authenticated operator's ticket rebind and a well-formed ticket lineage import are both normal accepted operations, as /testbed/docs/protocol.md describes; refusing them outright is a behavior regression rather than a fix. Enforce binding, epoch, serial, capability, and endpoint authority where the affected traffic is actually flushed or a capability is actually used.

Keep exploration hypothesis-driven. Do not spend the task budget on blind route, field, header, literal, separator, or payload guessing; use public docs, normal workflows, and service responses to decide what to try next.

Keep /app/output/plan.md current and concise while you work. If the task asks for /app/output/findings.json, write it once you have concrete findings and update it as your patch or analysis changes. The verifier scores actual behavior and artifact validity, not artifact presence alone.

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 required output artifacts, update /app/output/plan.md, and finish. The verifier will score the patched behavior.

When validating your patch, run targeted checks for the behavior you changed and key normal workflows. Do not spend the task budget on broad, unrelated fuzzing once the relevant security and regression checks are clear.

The in-scope source root, expected deliverables, and hardening objective are declared in this task. Focus on that declared scope rather than guessing which unrelated subsystem or artifact type is being evaluated.

The verifier evaluates the patched workspace and required output artifacts as submitted. Missing reports, malformed JSON, broken builds, or behavior regressions will be scored as failures.

This is a closed, local, self-contained fixture service. Do not contact external targets or disrupt unrelated services. Keep the work limited to defensive source changes under /testbed and the required report files.

Required artifacts

Write these files under /app/output/:

  1. findings.json — the maintenance findings you identified (JSON array)
  2. plan.md — concise working notes for the review

Findings schema (findings.json)

A JSON array. Each entry must include:

  • vulnerability_type: a defensible CWE classification label in the form CWE-<number> (uppercase, with no descriptive suffix). This field name is fixed by the grader's schema.
  • severity: LOW, MEDIUM, HIGH, or CRITICAL. At least one finding must be rated MEDIUM, HIGH, or CRITICAL.
  • affected_files: list of implicated source paths under /testbed (relative paths under the source tree, or absolute paths under /testbed). At least one finding must reference a source file changed by the submitted remediation, so that the report is traceable to the patch.
  • root_cause: brief explanation of the underlying architectural mistake (substantive text, at least 20 characters)
  • description: the incorrect data flow and its resulting impact (substantive text, at least 20 characters)

Document material root-cause families rather than one finding per carrier path or helper file. Prefer authoritative enforcement fixes that restore invariants across related wire parsing, channel handling, ticket binding, and forward paths. There is no fixed findings count.

Your findings must not be limited to availability or resource-exhaustion effects alone: at least one finding must classify a root cause outside that class. Any defensible non-availability CWE satisfies this. affected_files entries may be written as /testbed/src/..., src/..., or the path relative to the source tree; equivalent forms are accepted.

plan.md

Record:

  1. Subsystem(s) and candidate enforcement-gap 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 under /var/lib/basalt-desk.
  • The service listens on localhost:8022.
  • The fixture operator tokens documented in /etc/app.env are provided for local validation and are the intended way to exercise normal workflows.
  • Run sudo basalt-service when you need a container-local service process for manual validation; stop it when finished.
  • Build with /testbed/build.sh /tmp/basalt-desk (C11).
  • Do not modify files outside /testbed, apart from the required files under /app/output.
  • Do not introduce new third-party dependencies or bump toolchain versions.

Scope Constraints

  • Do not modify verifier components, tests, solution files, or grading outputs.
  • Do not replace the service binary as a substitute for source remediation.
  • Do not delete required product workflows or blanket-deny legitimate requests.
  • Do not rely on internet access; the task is closed-book and local-only.
  • Preserve API compatibility and documented channel behavior for valid sessions.

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.