From 8205ba663181934acabc75fdda00c38781d71949 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 11 May 2026 12:55:06 +0000 Subject: [PATCH] security: add .gitignore recommendation and enhance security documentation - Init command now prompts users to add .sourcegraph/ to .gitignore - SECURITY.md enhanced with data retention policy section - SECURITY.md enhanced with plugin trust model section - Documents sensitive data handling (usage logs, embeddings, blame cache) - Documents plugin security model and NuGet restore risks - Provides concrete recommendations for GDPR compliance and audit trails Agent-Logs-Url: https://github.com/Jak3b0/DevBitsLab.Mcp.SourceGraph/sessions/640ab866-cdfc-4652-b1c7-6a2b90d7dd15 Co-authored-by: Jak3b0 <2845081+Jak3b0@users.noreply.github.com> --- SECURITY.md | 54 +++++++++++++++++++ .../Cli/InitCli.cs | 1 + 2 files changed, 55 insertions(+) diff --git a/SECURITY.md b/SECURITY.md index a9f9cbf2..f1861e11 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -91,3 +91,57 @@ additionally: Strong-naming and Authenticode signing of published packages is on the roadmap but not yet shipped — see [GOVERNANCE.md](GOVERNANCE.md) for status. + +## Data retention and sensitive information + +The server stores operational data in `/.sourcegraph/`: + +- **Usage logs** (`usage.jsonl`, `heals.jsonl`) — tool call history with + parameters, timestamps, and durations. These logs may contain sensitive query + data (e.g., SQL statements with embedded identifiers from your codebase). +- **Embeddings cache** (`scopes/.db` embeddings table) — semantic vectors + derived from your source code. +- **Blame cache** (`scopes/.db` history table) — author names and commit + timestamps from `git blame`. +- **Symbol index** (`scopes/.db`) — symbol names, types, file paths from + your codebase. + +**Recommended practices:** + +1. **Add `.sourcegraph/` to your `.gitignore`** — these artifacts are local + workspace caches and should not be committed to version control. The `init` + command reminds you to do this. +2. **Retention policy** — usage logs rotate automatically when they exceed 10 MB + (oldest entries removed). Embeddings and indexes remain until `clear` or + `repair` commands are invoked. If you need stricter retention (e.g., GDPR + compliance for author names in blame cache), delete the `.sourcegraph/` + directory periodically or use `--no-history` to skip blame indexing entirely. +3. **Redaction** — if you share logs or databases for debugging, sanitize them + first. Usage logs are JSONL and can be filtered with `jq`. Consider scrubbing + `details.sql` fields if they contain proprietary identifiers. + +## Plugin trust model + +**Plugins execute with full host privileges** — they run in-process using a +shared `AssemblyLoadContext` and have unrestricted access to the host's +capabilities (file I/O, network, process spawning). Only load plugins from +trusted sources. + +**NuGet plugin restore:** + +- The server runs `dotnet restore` to fetch plugins declared in + `.sourcegraph.json`. NuGet package signature verification is **not enforced** + by the server at this time — rely on your organization's NuGet feed + restrictions and package signing policies. +- If a plugin's NuGet source is compromised, or if you specify an untrusted + package ID, malicious code can execute during indexing or tool invocation. + +**Recommendations:** + +- Audit every plugin assembly before adding it to `plugins[]`. +- Use a private NuGet feed with signature enforcement for enterprise + deployments. +- Pin plugin versions explicitly (e.g., `"version": "1.2.3"` in + `.sourcegraph.json`) to avoid unexpected updates. +- Future versions may add opt-in cryptographic signature verification via a + `--verify-plugins` flag (tracked in roadmap). diff --git a/src/DevBitsLab.Mcp.SourceGraph.Server/Cli/InitCli.cs b/src/DevBitsLab.Mcp.SourceGraph.Server/Cli/InitCli.cs index 38f2b879..1fe12f83 100644 --- a/src/DevBitsLab.Mcp.SourceGraph.Server/Cli/InitCli.cs +++ b/src/DevBitsLab.Mcp.SourceGraph.Server/Cli/InitCli.cs @@ -426,6 +426,7 @@ private static void PrintClosingReport(List results) } Console.WriteLine(); Console.WriteLine("Next:"); + Console.WriteLine(" • Add `.sourcegraph/` to your `.gitignore` (contains local cache & logs)."); Console.WriteLine(" • Open this repo in your MCP client."); Console.WriteLine(" • Verify with `sourcegraph-mcp demo`."); }