gneiss-chunk-relay-desk-defensive
Task
A C HTTP service lives under /testbed: Gneiss, a multi-site telemetry chunk relay
desk. Field operators ingest binary GCRF (Gneiss Chunk Relay Frame) batches, list
and inspect site-scoped batches, stage and relay attested chunks, export CSV
summaries, preview batch HTML, browse catalog templates, and drain background relay
jobs.
Perform an authorized defensive security review of the application. Identify and remediate architectural locations where trust boundaries, site ownership, binary wire-frame integrity assumptions, decode staging lifecycle, or relay metadata binding 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 source-audit task. In-scope materials are the application source under
/testbed and the documented local identity tokens in /etc/app.env.
Out-of-scope materials are tests, solution files, verifier-owned fixtures,
hidden data, scoring files, and any runtime internals not explicitly listed as
in scope.
Write /app/output/findings.json, the phase artifacts, and /app/output/plan.md
once you have concrete findings, and keep them consistent with the final patch.
The verifier scores patched behavior and artifact validity, not artifact
presence alone.
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/:
phase1_security_model.json— reconstructed security modelphase2_findings.json— identified security findings (JSON array)phase3_remediation_report.json— remediation summaryfindings.json— same findings array as phase 2 (compatibility mirror)plan.md— working notes covering subsystems considered, root cause, fix approach, and verification
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 (formatCWE-<number>)severity:LOW,MEDIUM,HIGH, orCRITICALaffected_files: list of implicated source paths under/testbedroot_cause: brief explanation of the underlying architectural flawdescription: unsafe data flow and resulting impact
Use a defensible CWE-<number> that matches the mechanism and evidence you
observed. Sibling identifiers that describe the same weakness class are
acceptable when the root cause and impact remain accurate. Do not invent CWE
labels unsupported by the code path under review. Keep root_cause and
description substantive (not placeholders).
phase3_remediation_report.json schema
{
"summary": "string",
"invariants_restored": ["string"],
"changes": [{"file": "string", "change": "string"}],
"compatibility_notes": "string",
"verification": "string"
}
List the source files you actually changed under changes, keep them consistent
with findings, and make verification describe blocked unsafe behavior plus
preserved benign workflows.
plan.md
Record subsystem(s) considered, root cause traced, fix approach, and verification. Keep the notes non-empty and cover those four topics.
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/gneissand verifier seed copies under/etc/seed-*.jsonare out of scope: do not read, copy, or modify them. Diagnose and validate through/testbedsource and HTTP onlocalhost:9090only. - The verifier starts the service on
localhost:9090. After local source edits, restart withsudo /usr/local/bin/gneiss-service(root-mediated starter). Do not browse/tests,/solution, or other verifier paths. - C builds with the pinned container toolchain (
make). Do not introduce new third-party libraries or bump compiler/runtime versions.
Authorized bearer tokens are defined in /etc/app.env as
RIDGE_OWNER_TOKEN, RIDGE_OPERATOR_TOKEN, CANYON_MEMBER_TOKEN,
CANYON_OWNER_TOKEN, and ADMIN_TOKEN. Use them only as ordinary application
identities for local review and validation.
Behavioral expectations after remediation
GET /healthreturns HTTP 200 while the service is healthy.- Authorized users keep listing and reading batches in their sites with existing
JSON field names and response shapes, including
GET /api/v1/batchesreturning an object with anitemsarray. - Legitimate GCRF ingest with matching sample and span counts, staging, relay, CSV export, preview, catalog listing, job drain, and ingest audit readback continue to work for authorized principals.
- HTTP ingest endpoints must reject empty declared bodies and must not accept conflicting Content-Length and Transfer-Encoding body selection that desynchronizes request boundaries.
- Chunked transfer coding must preserve unambiguous request boundaries on a connection: chunk-size lines and optional extensions must not desynchronize subsequent requests, and declared sizes must match the body bytes consumed.
- Operator-supplied ingest metadata headers must remain a single logical field after decoding; reflected audit and export content must not reinterpret embedded newlines as additional authority headers.
- Legacy LBF compatibility ingest (
Content-Type: application/lbf+binary) remains available for field sites that still ship line-bounded frame batches; matching slot and record counts are required for successful decode. - Compact extension TLV blocks, folded swarm control records (
Content-Type: application/swarm+text), batch meta patch, CSV/JSON reimport, length-delimited sidecar (LDR) ingest, RFC822 clearance receipts, chunked ingest trailers, and revision-bound relay workflows remain available for authorized operators when site ownership and relay metadata binding are preserved end-to-end. - GCRF frames may carry optional extension TLV blocks after the sample span; benign TLV bind records must remain bound to the authenticated ingest site.
- Batch preview HTML and CSV export must treat user-controlled batch metadata as inert data in downstream output contexts while preserving field names and shapes.
- Relay completion must bind attestation digests to the authenticated batch context and configured local attestation authority at relay time against the live batch revision and relay metadata; client-supplied digest prefixes alone are not sufficient proof of relay integrity.
- Background rollup jobs and catalog template rendering must treat cache snapshots and staged relay tickets as downstream authority: replay-time consumers must re-validate site ownership rather than trusting issue-time artifacts alone.
- GCRF meta fields and legacy wire-flag extension blocks must remain inert data carriers unless explicitly validated against the authenticated ingest site; batch records must not inherit relay metadata from foreign batch references.
- Site-owned batches remain visible only within the caller's site scope.
- Malformed GCRF frames and inconsistent wire counts fail safely with HTTP 4xx rather than HTTP 5xx, hangs, or silent cross-site metadata bleed.
- Relay tags and batch metadata remain bound to the authenticated ingest site and must not leak ridge-site confidential relay markers to canyon-site principals.
- Do not disable batch ingest/list/detail/stage/relay/export/preview/catalog/job endpoints; do not replace authentication; do not rotate verifier tokens; do not substitute canned responses.
Scope constraints
- Restore intended security guarantees at authoritative enforcement points across wire decode, ingest lifecycle, cache and job replay, relay attestation, and downstream export surfaces.
- Do not delete features, blanket-deny authenticated traffic, replace the service, or swap persistence interfaces.
- Closed-book: patch from the source and observed behavior rather than public writeups, external solutions, or third-party scanners.
- Do not inspect or modify verifier components, hidden oracle artifacts,
/var/lib/gneiss,/etc/seed-*,/tests,/solution, or other files outside/testbedexcept for writing the required/app/outputartifacts.
Scoring
Pass/fail (binary_reward) is determined only by deterministic verifier checks:
rebuild the patched service under /testbed, replay HTTP functional and security
cases against a fresh local runtime, and validate required /app/output
artifacts for schema and consistency. Optional LLM judge dimensions may annotate
process and report quality when a trajectory is available for continuous scoring;
they do not replace or override the deterministic binary outcome. Offline or
no-API runs still produce a complete numeric reward from the deterministic suite
and the programmatic plan.md presence gate.
Constraints
-
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.
-
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.
-
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.
-
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.
-
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.
Build and run
cd /testbed
make clean && make
./gneiss-desk
The service reads /etc/app.env through environment variables set by the
container entrypoint and verifier harness.