Title: Read-modify-write through the MCP permanently destroys stored issue and PR body content · Issue #3165 · github/github-mcp-server · GitHub
Open Graph Title: Read-modify-write through the MCP permanently destroys stored issue and PR body content · Issue #3165 · github/github-mcp-server
X Title: Read-modify-write through the MCP permanently destroys stored issue and PR body content · Issue #3165 · github/github-mcp-server
Description: Summary Body sanitization is lossy and applied on read, so a client's in-memory copy of a body is already damaged before it edits anything. Editing a body means sending the whole body back, so an ordinary read-modify-write cycle writes t...
Open Graph Description: Summary Body sanitization is lossy and applied on read, so a client's in-memory copy of a body is already damaged before it edits anything. Editing a body means sending the whole body back, so an o...
X Description: Summary Body sanitization is lossy and applied on read, so a client's in-memory copy of a body is already damaged before it edits anything. Editing a body means sending the whole body back, so ...
Opengraph URL: https://github.com/github/github-mcp-server/issues/3165
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Read-modify-write through the MCP permanently destroys stored issue and PR body content","articleBody":"### Summary\n\nBody sanitization is lossy and applied on read, so a client's in-memory copy of a body is already damaged before it edits anything. Editing a body means sending the whole body back, so an ordinary read-modify-write cycle writes the damage back and the sanitizer's deletions become permanent in GitHub's stored data.\n\nThe loop needs no misbehaviour:\n\n1. A client reads an issue or PR body through a sanitizing read path.\n2. It makes an unrelated edit — ticking a checklist box, appending a status line.\n3. It writes the whole body back.\n\nEverything the sanitizer removed in step 1 is now gone from the stored issue. This turns a response-fidelity problem into repository data loss.\n\n### Reproduction\n\nVerified 2026-08-26. `pkg/sanitize/sanitize.go` at `main` ([`a00dc319`](https://github.com/github/github-mcp-server/commit/a00dc319edcb5f8a10f118b1dad649c94928aac4)) produces this behaviour.\n\nCreate an issue **via REST, not the MCP**, with this body:\n\n```markdown\n## Checklist\n\n- [ ] step one\n- [ ] step two\n\n## Probe 1\n\nSENTINEL-1-BEFORE. The retry threshold is \u003cn> by default. SENTINEL-1-AFTER.\n\n## Probe 2\n\nSENTINEL-2-BEFORE. Returns Promise\u003cstring> on success. SENTINEL-2-AFTER.\n\n## Probe 3\n\nSENTINEL-3-BEFORE. The style probe: `\u003cstyle>`. SENTINEL-3-AFTER-SHOULD-SURVIVE.\n```\n\nThen:\n\n1. `GET /repos/{owner}/{repo}/issues/{n}` — body intact, **492 bytes**.\n2. `issue_read` (`get`) — `\u003cn>` and `\u003cstring>` are gone, and the body ends mid-sentence at the `\u003cstyle>` probe, with `SENTINEL-3-AFTER-SHOULD-SURVIVE` absent.\n3. `issue_write` (`update`), sending back exactly what step 2 returned, with `- [ ] step one` changed to `- [x] step one`. One character of intent.\n4. `GET` again — **438 bytes.**\n\nThe stored body, diffed against the baseline:\n\n```diff\n-- [ ] step one\n+- [x] step one\n\n-SENTINEL-1-BEFORE. The retry threshold is \u003cn> by default. SENTINEL-1-AFTER.\n+SENTINEL-1-BEFORE. The retry threshold is by default. SENTINEL-1-AFTER.\n\n-SENTINEL-2-BEFORE. Returns Promise\u003cstring> on success. SENTINEL-2-AFTER.\n+SENTINEL-2-BEFORE. Returns Promise on success. SENTINEL-2-AFTER.\n\n-SENTINEL-3-BEFORE. The style probe: `\u003cstyle>`. SENTINEL-3-AFTER-SHOULD-SURVIVE.\n+SENTINEL-3-BEFORE. The style probe: `\n```\n\nOne intended change; 54 bytes destroyed, including the entire tail of the body after `\u003cstyle>`.\n\n### Why this is filed separately from [#2202](https://github.com/github/github-mcp-server/issues/2202)\n\n[#2202](https://github.com/github/github-mcp-server/issues/2202) reports the read-side symptom, framed as angle-bracket loss inside code blocks. The fix is the same — stop mangling bodies — but the severity is not. A client that only reads gets a degraded response; a client that reads, edits and writes back destroys stored content, and the currently merged behaviour makes every such client destructive by default.\n\nTwo properties make it hard to catch:\n\n- **No marker.** Deletions often splice the surrounding text together and read grammatically; truncation simply ends. A client comparing its intended edit against what it sent sees nothing wrong.\n- **The client is behaving correctly.** Sending back the body it was given is the documented way to edit an issue.\n\n### The worst input: skip-content elements truncate everything after them\n\nbluemonday keeps a set of elements whose *content* is discarded along with the tag — `frame, frameset, iframe, noembed, noframes, noscript, nostyle, object, script, style, title` (`policy.go:979-990` in v1.0.27). The skip flag clears only on the matching end tag, so an opening tag with no closing tag — routine in a markdown body — drops everything to end-of-body.\n\nMembership is a policy list, not an HTML category, and predicting from the category gets it backwards in both directions: `iframe` and `object` truncate without being raw-text elements, while `textarea` does not truncate despite being one. [@franklinjavier set this out in detail on #2202](https://github.com/github/github-mcp-server/issues/2202#issuecomment-5429937295).\n\nIndependent public reproduction with sentinels: [flungo/claude-plugins#55](https://github.com/flungo/claude-plugins/pull/55) and its test comments B, C and D — one of which cut itself off at its own header.\n\nCombined with the write loop, a single backticked `\u003cstyle>` in a body means one checkbox tick discards everything below it, permanently.\n\n### Scope\n\nBackticks and code fences offer no protection: the pass runs on the raw string before any markdown parsing. [@ericknavarro's census on #2202](https://github.com/github/github-mcp-server/issues/2202#issuecomment-5149562849) measured 177 bodies with confirmed mid-body loss out of 600 recent items in one repository — worst case 2,755 characters deleted from an 8,360-character body — and found the majority of the damage in prose rather than code.\n\nCoverage widened considerably in [`56bfeec0`](https://github.com/github/github-mcp-server/commit/56bfeec0a9bd0ad6a6d88a047541d9e9acad8101) (2026-08-19), which centralized `sanitize.Sanitize` into the shared `convertToMinimal*` converters — so comment bodies, review bodies, review comment bodies, releases and commit messages are now affected where previously they were not. `minimal_types.go` currently reads `Body: sanitize.Sanitize(comment.GetBody())`.\n\n### Suggested fix\n\n[@ericknavarro](https://github.com/github/github-mcp-server/issues/2202#issuecomment-5149562849) proposed the approach on #2202 on 2026-08-01: skip `FilterHTMLTags` for body fields entirely.\n\n[#3035](https://github.com/github/github-mcp-server/pull/3035) implements it, as a `FilterBody` that keeps the injection defences which matter for bodies — invisible characters, BiDi overrides, hidden code-fence info strings — and drops only the HTML pass, reserving full `Sanitize` for titles. It has had reviewer engagement, and predates the 2026-08-19 refactor of `Sanitize`, so it needs updating against current `main`.\n\nIts three sibling PRs — [#3039](https://github.com/github/github-mcp-server/pull/3039), [#3040](https://github.com/github/github-mcp-server/pull/3040), [#3043](https://github.com/github/github-mcp-server/pull/3043) — still apply full `sanitize.Sanitize` to bodies, and #3043 applies it to gist **file content**. Merging those as written would extend this problem rather than contain it.\n\nIf the HTML pass must stay for bodies, entity-escaping an unrecognized `\u003c` rather than deleting the span would at least preserve meaning.\n\n### Related\n\n- [#2202](https://github.com/github/github-mcp-server/issues/2202) — primary read-side report, open since 2026-03-12\n- [#3106](https://github.com/github/github-mcp-server/issues/3106) — the coverage-consistency issue, which asked for \"a content-safe strategy for source code and file contents\"\n- Fix attempts: [#3035](https://github.com/github/github-mcp-server/pull/3035) (open), [#2408](https://github.com/github/github-mcp-server/pull/2408) (open, code regions only), [#2633](https://github.com/github/github-mcp-server/pull/2633) (closed), [#2308](https://github.com/github/github-mcp-server/pull/2308) (closed)\n\n🤖 Investigated and drafted by Claude Code (Claude Opus 5)","author":{"url":"https://github.com/arolling-sa","@type":"Person","name":"arolling-sa"},"datePublished":"2026-08-26T19:56:03Z","url":"https://github.com/github/github-mcp-server/issues/3165"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2293efe7-dd9c-f81b-08a7-bb4062ee5187 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E394:2D919D:1EA3449:286A286:6B068E20 |
| html-safe-nonce | bd2030360459998dfcac9912304803278372256c20f05ec6226395adf5e8648a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzk0OjJEOTE5RDoxRUEzNDQ5OjI4NkEyODY6NkIwNjhFMjAiLCJ2aXNpdG9yX2lkIjoiMzIwNDU5MDMyMjQyODg0MTUwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4f72a960543452b158e64cd20e8c94ca0741d2aee4be2d202794856e99e2c5f2 |
| hovercard-subject-tag | issue:5260928487 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/github-mcp-server/3165/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30d78a60b9e9968544e260b6b7a63e7e2ab8968fab29b5dab49f25236e560c36/github/github-mcp-server/issues/3165 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30d78a60b9e9968544e260b6b7a63e7e2ab8968fab29b5dab49f25236e560c36/github/github-mcp-server/issues/3165 |
| og:image:alt | Summary Body sanitization is lossy and applied on read, so a client's in-memory copy of a body is already damaged before it edits anything. Editing a body means sending the whole body back, so an o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | arolling-sa |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a |
| turbo-cache-control | no-preview |
| go-import | github.com/github/github-mcp-server git https://github.com/github/github-mcp-server.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 942771284 |
| octolytics-dimension-repository_nwo | github/github-mcp-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 942771284 |
| octolytics-dimension-repository_network_root_nwo | github/github-mcp-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6d3909414814ff86ce7da4c51a0f4918a13fb41b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width