Category: bug Severity: minor
Location: lib/arcp/job/event_body/result_chunk.rb:33-38 (secondary: lib/arcp/runtime/job_context.rb:155)
Spec: ARCP v1.1 §8.4
What
ChunkWriter#write encodes binary chunks with Base64.strict_encode64, but ResultChunk#decoded decodes with the lenient Base64.decode64, which ignores non-alphabet characters and stops silently at malformed input. The encode/decode pair is asymmetric: a corrupted or truncated data field (e.g. line-wrapped or whitespace-injected by an intermediary) is silently mis-decoded into wrong bytes instead of being rejected, so chunked-result assembly (§8.4) can yield a corrupt result with no error. For binary payloads this is a silent data-integrity hazard.
Evidence
# lib/arcp/job/event_body/result_chunk.rb:33-38
def decoded
case encoding
when 'utf8' then data
when 'base64' then Base64.decode64(data) # lenient; encoder uses strict_encode64
end
end
# lib/arcp/runtime/job_context.rb:155
when 'base64' then Base64.strict_encode64(chunk)
Proposed fix
Decode with Base64.strict_decode64(data) so malformed input raises rather than silently truncating, mirroring the strict encoder; convert the resulting ArgumentError into Arcp::Errors::InvalidRequest for a clean wire error. Add a round-trip test for binary data and a negative test asserting that malformed base64 raises.
Acceptance criteria
Category: bug Severity: minor
Location:
lib/arcp/job/event_body/result_chunk.rb:33-38(secondary:lib/arcp/runtime/job_context.rb:155)Spec: ARCP v1.1 §8.4
What
ChunkWriter#writeencodes binary chunks withBase64.strict_encode64, butResultChunk#decodeddecodes with the lenientBase64.decode64, which ignores non-alphabet characters and stops silently at malformed input. The encode/decode pair is asymmetric: a corrupted or truncateddatafield (e.g. line-wrapped or whitespace-injected by an intermediary) is silently mis-decoded into wrong bytes instead of being rejected, so chunked-result assembly (§8.4) can yield a corrupt result with no error. For binary payloads this is a silent data-integrity hazard.Evidence
Proposed fix
Decode with
Base64.strict_decode64(data)so malformed input raises rather than silently truncating, mirroring the strict encoder; convert the resultingArgumentErrorintoArcp::Errors::InvalidRequestfor a clean wire error. Add a round-trip test for binary data and a negative test asserting that malformed base64 raises.Acceptance criteria
decodeduses strict base64 decoding forencoding == 'base64'.InvalidRequestrather than corrupt bytes.