[GH-ISSUE #136] BinarySession exposes mutable session metadata objects #82

Closed
opened 2026-10-15 18:20:57 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @morluto on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/136

Problem

BinarySession exposes mutable internal state through direct references.

  • providerIdentity() returns this.#providerIdentity directly.
  • activeTarget() returns this.#active?.target directly.

Callers can mutate those return values and alter session-visible state.

Reproduction

import { BinarySession } from './dist/application/BinarySession.js';

const provider = {
  identity() {
    return { id: 'fixture', name: 'Fixture', version: '1' };
  },
  capabilities() {
    return [];
  },
  createClient() {
    return {
      execute(name) {
        if (name === 'health') {
          return Promise.resolve({
            ok: true,
            value: {
              result: null,
              rawResult: null,
              provider: provider.identity(),
              limitations: [],
              locations: [],
              subject: null,
            },
          });
        }
        return Promise.resolve({
          ok: false,
          error: {
            _tag: 'AnalysisCapabilityUnavailableError',
            operation: name,
            provider: 'fixture',
            reason: 'x',
          },
        });
      },
      close() {
        return Promise.resolve();
      },
    };
  },
};

const session = new BinarySession(provider);
await session.open('/bin/ls');

const identity = session.providerIdentity();
identity.id = 'hijacked';
console.log(session.providerIdentity().id); // 'hijacked'
console.log(session.status().provider.id);  // 'hijacked'

const active = session.activeTarget();
if (active !== undefined) active.path = '/tmp/forged-path';
console.log(session.status().path); // '/tmp/forged-path'

Expected

These methods should return detached copies so callers cannot mutate session-owned objects.

Actual

Mutating returned values from public accessors changes status() output and session metadata without any session operation.

Impact

A caller can spoof provider identity and target metadata in the active session and destabilize identity-sensitive workflows.

Files

  • src/application/BinarySession.ts
Originally created by @morluto on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/136 ### Problem `BinarySession` exposes mutable internal state through direct references. - `providerIdentity()` returns `this.#providerIdentity` directly. - `activeTarget()` returns `this.#active?.target` directly. Callers can mutate those return values and alter session-visible state. ### Reproduction ```ts import { BinarySession } from './dist/application/BinarySession.js'; const provider = { identity() { return { id: 'fixture', name: 'Fixture', version: '1' }; }, capabilities() { return []; }, createClient() { return { execute(name) { if (name === 'health') { return Promise.resolve({ ok: true, value: { result: null, rawResult: null, provider: provider.identity(), limitations: [], locations: [], subject: null, }, }); } return Promise.resolve({ ok: false, error: { _tag: 'AnalysisCapabilityUnavailableError', operation: name, provider: 'fixture', reason: 'x', }, }); }, close() { return Promise.resolve(); }, }; }, }; const session = new BinarySession(provider); await session.open('/bin/ls'); const identity = session.providerIdentity(); identity.id = 'hijacked'; console.log(session.providerIdentity().id); // 'hijacked' console.log(session.status().provider.id); // 'hijacked' const active = session.activeTarget(); if (active !== undefined) active.path = '/tmp/forged-path'; console.log(session.status().path); // '/tmp/forged-path' ``` ### Expected These methods should return detached copies so callers cannot mutate session-owned objects. ### Actual Mutating returned values from public accessors changes `status()` output and session metadata without any session operation. ### Impact A caller can spoof provider identity and target metadata in the active session and destabilize identity-sensitive workflows. ### Files - src/application/BinarySession.ts
bsakaguchi 2026-10-15 18:20:57 +00:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#82
No description provided.