Skip to content

[BUG]: Question tool bypasses read-before-edit -- no runtime enforcement #30853

@LifetimeVip

Description

@LifetimeVip

Description

The Question tool can be used as a substitute for the Read tool because:

  1. Question tool output is structurally identical -- question.ts returns answers as plain text. To the AI conversation history, a Question answer looks the same as Read output.

  2. No runtime enforcement in edit tools -- edit.ts, write.ts, and bash.ts have zero checks verifying the file was read via the Read tool before editing. The tool descriptions claim read-before-edit is required, but there is no code backing this claim.

  3. No session-level read tracking -- there is no mechanism to distinguish whether file content came from a Read call or a Question answer. The AI could ask "What is the content of src/main.ts?", receive the answer, then edit the file -- all without ever calling Read.

Reproduction steps

  1. Start an opencode session
  2. Ask the AI to modify a file it has not read yet
  3. When the AI calls question asking "What is the current content of ?", paste the file content as your answer
  4. The AI now has the content and can call edit/write with correct oldString -- the edit will succeed because there is no Read-tool check in the editing tools

Code paths

  • question.ts returns plain text answers, structurally same as Read output
  • edit.ts, write.ts -- zero read-before-edit enforcement
  • bash.ts -- no enforcement either

Related

This is one instance of a broader pattern tracked in #30376 (missing code-level read-before-edit enforcement across all tools).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions