Skip to content

Authentication and skill subprocess output can grow without bounds #130

Description

@GautamSharma99

Summary

Several child-process collectors retain unlimited stdout or stderr:

CodexLoginHandle appends every chunk to #stdout or #stderr. Each chunk then calls #notifyInstructions, whose getters parse the complete accumulated output again. This combines unbounded storage with roughly quadratic parsing work as output grows.

runCodex also retains complete stdout and stderr. readSkillCommandOutput has no maximum JSONL line length and retains an unrestricted final agent message or error message.

Why this matters

A malfunctioning, compromised, or unexpectedly verbose child process can exhaust the SDK/CLI process's memory. Interactive login output can additionally cause excessive CPU use because earlier output is repeatedly reparsed. A single unterminated or very large JSON event from a skill command has the same memory risk.

Expected behavior

Subprocess output used for diagnostics or instruction discovery should have explicit byte limits. Oversized structured output should fail with a controlled, redacted error.

Suggested direction

  • Parse login instructions incrementally and keep only a bounded diagnostic tail.
  • Add separate stdout/stderr ceilings to runCodex.
  • Bound JSONL line size and retained final-message size in readSkillCommandOutput.
  • Preserve current credential redaction when reporting truncation or overflow.
  • Add tests for oversized stdout, stderr, JSONL lines, and final responses.

Existing tests cover malformed and normal-sized output but not these resource boundaries.

Found by static audit of upstream main at 9c7634b.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions