tree-sitter / tree-sitter/tree-sitter-cpp

`tree_sitter_cpp_external_scanner_deserialize` doesn't bound `length` against the size of the delimiter buffer

Open Beginner friendly
#368 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
453
Forks
185
PR merge metrics
No merged PRs in 30d

Description

https://github.com/tree-sitter/tree-sitter-cpp/blob/8b5b49eb196bec7040441bee33b2c9a4838d6967/src/scanner.c#L135-L143

If the function is fed a buffer which exceeds the implicit bound of 64 bytes fed currently, the input can overflow onto the heap. This would be exploitable, if not for the fact that serialize only returns a maximum of MAX_DELIMITER_LENGTH * sizeof(wchar_t) == 64 bytes on Linux and MacOS.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/scanner.c at lines 135-143 and compare tree_sitter_cpp_external_scanner_deserialize with the delimiter buffer size and the serializer’s 64-byte maximum. Verify that oversized input cannot overwrite the delimiter buffer, then run the repository’s tests and confirm normal scanner serialization still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.