Skip to content

fix(ssh): validate bounded raw response bytes and strict JSON framing #116

Closed

Description

@abruption

Priority and scope

P2. Planning-only bounded ordinary SSH response parser correction. Prerequisite/reference for #115; separate from #69–#72 opt-in handoff and Draft107–109 private frames/app-server parsing. No release approval.

Source finding (not a fresh reproduction)

Published0.3.2 source f335f07352c842f2f6ceb12bd2ca6274b52f69f7, current main 332df52e559c398b83592e550a8cf08284506178 runtime diff0.

process.run() lines80–84 applies replacement UTF-8 decoding before counting the resulting string; remote() line209 uses plain JSON.parse. Malformed bytes inside strings can become replacement characters and duplicate keys are overwritten. There is no explicit JSON depth budget. JSON.parse already rejects ordinary concatenated objects/banner text/NaN: this issue makes their bounded rejection explicit, not a claim they are currently accepted.

The stdin request's fatal UTF-8 decoder is a different path and must not be reported as strict response decoding. Python1.0.3 parse_ssh_response is a strict-response reference. No execution, malformed-response experiment or live send was performed in this audit.

Acceptance criteria

  • Bound raw stdout bytes before decoding, including whitespace/LF. Preserve the documented ordinary output limit (currently default1MiB) or justify any intentional compatibility change; do not accept retained prefixes after overflow.
  • Decode protocol stdout with fatal UTF-8 across chunk boundaries; reject malformed/truncated sequences instead of repairing them. Keep non-protocol command consumers compatible rather than forcing protocol policy onto every local tool.
  • Define one top-level JSON object, allowed JSON whitespace/BOM policy, and refusal of prefixes, banners, trailing garbage/multiple frames. Parse completion must establish the whole bounded frame.
  • Reject duplicate keys at every object depth, including escaped-equivalent decoded keys; reject non-JSON constants and invalid command/schema/native-result fields. Preserve actual accepted optional field absence/null distinctions.
  • Choose and document finite nesting/depth/aggregate parsing budgets, with no unbounded recursion, input-driven allocation or parser execution. No eval/shell reinterpretation.
  • Keep diagnostic stderr independently bounded and replacement decoded/sanitized. A valid stdout response plus invalid stderr on normal exit0 and SSH255 must not lose independently validated native evidence.
  • Add byte/depth boundaries, split multibyte chunks, malformed/truncated UTF-8, plain/nested/escaped-equivalent duplicate keys, BOM, permitted whitespace, banners, multiple objects, trailing garbage and malformed semantic fields fixtures.
  • Preserve per-host isolation, normal single/multi-host output and existing process cleanup/timeouts. Cross-test complete vs partial × exit0/255/timeout with the linked evidence-preservation issue; overflow/pollution never becomes success.

Boundaries

No automatic retry/fallback, native resubmission, observer/ACK/ledger, source-streamed deployment or version/host-key relaxation. Existing #93/#95 isolation and #97 nullable Claude-name compatibility remain intact. Do not silently repin Python1.0.2/referenceVersion. Future tests are acceptance criteria, not completed validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions