microsoft / microsoft/WinAppVSCE
XAML server: bound Content-Length and header sizes in JsonRpcConnection
@chiaramooney is already working on this.
Since Sep 8, 2026.
- Dominant language
- TypeScript
- Stars
- 13
- Forks
- 3
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 11
Description
Follow-up from the PR #50 review (finding L1).
server/src/WinUiXaml.LanguageServer/Lsp/JsonRpcConnection.cs line 226 allocates new byte[contentLength] directly from the Content-Length header with no upper bound, and the header-reading loop has no cap on individual header-line length or total header size. A malformed or hostile Content-Length therefore turns into an unbounded allocation.
Additionally, when int.TryParse fails on the header value the code silently leaves contentLength at 0 rather than treating the frame as a protocol error, which makes malformed input hard to diagnose.
Severity is low in practice: the only client on this pipe is the extension host over stdio, so this is defense-in-depth rather than a reachable attack path.
Suggested work:
- Cap
Content-Lengthat a sane maximum (a few MB) and fail the frame beyond that. - Cap header-line and total-header size.
- Treat a
Content-Lengthparse failure as an explicit protocol error instead of falling through with 0.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.