Skip to content

fix(agent): block grep_files from leaking .env secrets - #147

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/high-severity-issues-0db1
Draft

cursor[bot] wants to merge 2 commits into
mainfrom
cursor/high-severity-issues-0db1

Conversation

@cursor

@cursor cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

Summary

  • read_file already hard-blocks .env / .key / .pem and redacts secret-like keys in other files. grep_files used the same workspace resolver but skipped both checks.
  • A normal agent call such as grep_files {"pattern":"API_KEY","path":"."} returned raw .env lines (for example API_KEY=...) into the model context. A 50-line .env could also consume the match cap and hide later non-secret hits.
  • The fix fails closed on a direct sensitive target, skips those files before reading them during a directory walk, and runs remaining match lines through the existing redaction helper.

Task Linkage

  • Task ID: TASK-2026-071
  • Task folder: tasks/TASK-2026-071-block-grep-sensitive-files/

Injected Specs

  • spec/architecture-boundaries.md (if architecture/layering changed)
  • spec/security-nonnegotiables.md (if sandbox/security changed)
  • spec/testing-policy.md (required for any code change)
  • spec/docs-sync.md (if behavior/docs/env/commands changed)

Validation Evidence

  • Commands executed:
    • python3 scripts/validate_tasks.py — passed (71 task directories)
    • cargo fmt --check — exit 0
    • cargo clippy --all-targets -- -D warnings — exit 0
    • cargo test -p skilllite-agent grep_files — 10 passed, 0 failed
    • cargo test — all workspace crates ok, 0 failed (skilllite-agent 250 passed)
  • Key results:
    • test_grep_files_blocks_direct_sensitive_path passed
    • test_grep_files_skips_dotenv_during_workspace_walk passed
    • test_grep_files_redacts_sensitive_keys_in_normal_files passed

Regression Scope

  • Areas likely affected:
    • Agent grep_files builtin
    • skilllite-fs::grep_directory optional skip-file callback
  • Explicit non-goals:
    • Dotenv variant suffix hardening (#143)
    • Recovered write_file clobber (#144 / #146)
    • Symlink canonicalize (#132)
    • Preview-server symlink follow
    • ChatSession workspace-root alignment (#114)

Docs Sync (EN/ZH)

  • Updated EN + ZH docs
  • Files:
    • docs/en/ARCHITECTURE.md
    • docs/zh/ARCHITECTURE.md

Review Checklist

  • Acceptance criteria in tasks/TASK-2026-071-block-grep-sensitive-files/TASK.md satisfied (or explicitly deferred)
  • tasks/TASK-2026-071-block-grep-sensitive-files/STATUS.md updated with latest progress
  • tasks/TASK-2026-071-block-grep-sensitive-files/REVIEW.md includes merge readiness decision
  • tasks/board.md status is up to date
Open in Web View Automation 

cursoragent and others added 2 commits August 19, 2026 11:11
read_file already refused .env/.key/.pem, but grep_files returned
raw matching lines from those files and did not redact secret keys
in ordinary files. Skip blocked paths before reading and reuse the
existing redaction helper.

Co-authored-by: EXboy <EXboys@users.noreply.github.com>
Record verification commands, merge readiness, and board status
for the sensitive-file grep fix.

Co-authored-by: EXboy <EXboys@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant