bug: doc-map config loaded from PR branch (untrusted) — potential data exfiltration #143

Closed
opened 2026-05-15 05:03:36 +00:00 by rodin · 1 comment
Owner

Summary

The validate-docmap and doc-map injection features read the doc-map YAML config from the PR branch, not the default/trusted branch. A malicious PR author can modify the doc-map in their branch to cause arbitrary repo documents to be fetched from the default branch and injected into LLM requests.

Impact

  • Severity: MAJOR / Security
  • Found by: security-review-bot on PR #138 (REQUEST_CHANGES)
  • Merged despite finding: Yes — PR #138 was merged with this unresolved

Attack vector

  1. Attacker opens a PR
  2. Modifies .review-bot/doc-map.yml in their branch to map any path glob to sensitive docs (e.g., docs/internal/secrets.md)
  3. review-bot reads the doc-map from the PR branch
  4. Sensitive docs from the default branch are fetched and injected into the LLM system prompt
  5. Via prompt injection in the design docs, attacker could potentially exfiltrate content

Fix

The doc-map config file must always be loaded from the default branch (or a pinned trusted ref), never from the PR branch. The PR branch should only contribute the list of changed files — not the config that governs what docs get injected.

References

  • PR #138 security-review-bot review: REQUEST_CHANGES with this finding
  • Affects: review/docmap.go, action inputs, CLI flag handling
## Summary The `validate-docmap` and doc-map injection features read the doc-map YAML config from the **PR branch**, not the default/trusted branch. A malicious PR author can modify the doc-map in their branch to cause arbitrary repo documents to be fetched from the default branch and injected into LLM requests. ## Impact - **Severity:** MAJOR / Security - **Found by:** security-review-bot on PR #138 (REQUEST_CHANGES) - **Merged despite finding:** Yes — PR #138 was merged with this unresolved ## Attack vector 1. Attacker opens a PR 2. Modifies `.review-bot/doc-map.yml` in their branch to map any path glob to sensitive docs (e.g., `docs/internal/secrets.md`) 3. review-bot reads the doc-map from the PR branch 4. Sensitive docs from the **default branch** are fetched and injected into the LLM system prompt 5. Via prompt injection in the design docs, attacker could potentially exfiltrate content ## Fix The doc-map config file must always be loaded from the **default branch** (or a pinned trusted ref), never from the PR branch. The PR branch should only contribute the list of changed files — not the config that governs what docs get injected. ## References - PR #138 security-review-bot review: REQUEST_CHANGES with this finding - Affects: `review/docmap.go`, action inputs, CLI flag handling
Author
Owner

🔍 Triage note (from DESIGN-137-doc-map.md):

The design doc states:

The doc-map YAML file is read from the local workspace (like system-prompt-file).

In CI, "local workspace" is the checked-out PR branch. The design doc describes GetAllFilesInPath and GetFileContent fetching docs via VCS API — but the config itself comes from the workspace.

Affected components per design:

  • review/docmap.go — YAML parsing, glob matching, doc loading
  • cmd/review-bot/main.go — Step 6c: parses config
  • action.ymldoc-map input wired to DOC_MAP_FILE

Fix approach: load .review-bot/doc-map.yml via VCS API from the default branch (like patterns-repo fetch) instead of from the local workspace. This may require a new flag or env var for "trusted ref".

**🔍 Triage note (from DESIGN-137-doc-map.md):** The design doc states: > The `doc-map` YAML file is read from the local workspace (like `system-prompt-file`). In CI, "local workspace" is the checked-out PR branch. The design doc describes `GetAllFilesInPath` and `GetFileContent` fetching docs via VCS API — but the *config* itself comes from the workspace. Affected components per design: - `review/docmap.go` — YAML parsing, glob matching, doc loading - `cmd/review-bot/main.go` — Step 6c: parses config - `action.yml` — `doc-map` input wired to `DOC_MAP_FILE` Fix approach: load `.review-bot/doc-map.yml` via VCS API from the default branch (like patterns-repo fetch) instead of from the local workspace. This may require a new flag or env var for "trusted ref".
rodin closed this issue 2026-05-15 12:09:20 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rodin/review-bot#143