Skip to content

common/json: fix out-of-bounds slice in the comment scanner - #108

Merged
nekohasekai merged 1 commit into
SagerNet:mainfrom
AlexandrKhromov2005:fix/json-comment-scanner-oob
Sep 20, 2026
Merged

nekohasekai merged 1 commit into
SagerNet:mainfrom
AlexandrKhromov2005:fix/json-comment-scanner-oob

Conversation

@AlexandrKhromov2005

@AlexandrKhromov2005 AlexandrKhromov2005 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

skipJSONString can advance past the end of input when a string ends with an incomplete backslash escape. If the input also contains a comment, comment path collection can panic while slicing an object key instead of returning a JSON syntax error.

Clamp the returned index to len(data) so malformed input reaches normal syntax validation.

Validation: go test ./common/json/... -count=1 passed.

@nekohasekai
nekohasekai force-pushed the fix/json-comment-scanner-oob branch from 2bcbc39 to 38b039c Compare September 20, 2026 04:22
@nekohasekai
nekohasekai changed the base branch from dev to main September 20, 2026 04:22
@nekohasekai
nekohasekai merged commit 643b9d0 into SagerNet:main Sep 20, 2026
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.

2 participants