Skip to content

Validate GitHub issue body against a declared schema before embedding in agent context #73

@ooloth

Description

@ooloth

Current state

loops/fix.py lines 222–223 call issue_context(ctx.issue_number), which returns raw gh issue view JSON (title, body, labels authored by anyone who can open a GitHub issue), and passes the result directly to the implement agent as context with no schema check, content bounds, or sanitization. A malicious or oversized issue body can embed prompt injection instructions that redirect the agent's behavior, exfiltrate project secrets passed in other context fields, or cause the agent to take unintended actions.

Ideal state

  • issue_context() output is validated against a declared schema (required keys: title, body, number; type checks; max-length bounds on body and title) before being embedded in agent context.
  • A validation failure raises a structured error that is logged and reported as a run failure, rather than letting untrusted content reach the agent prompt.
  • The schema is defined once and reused wherever issue context is embedded.

Starting points

  • loops/fix.py lines 222–223 — the issue_context(ctx.issue_number) call and the dict that embeds it
  • loops/common/github.pyissue_context definition, to understand the current return shape

QA plan

  1. Craft a GitHub issue with a body exceeding the proposed max-length bound and trigger the fix loop against it.
  2. Expect the run to fail with a clear validation error before the agent is started, not a prompt injection that causes unexpected agent behavior.
  3. Trigger the fix loop against a normal issue — expect the agent receives context and runs to completion as before.

Done when

The fix loop raises a validation error for any issue body that exceeds defined bounds or fails the schema check, before any agent subprocess is started.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions