Skip to content

Fix truncated UDP and JSON bounds checks#3039

Open
TurboTheTurtle wants to merge 1 commit into
shadowsocks:masterfrom
TurboTheTurtle:fix-udp-json-bounds-checks
Open

Fix truncated UDP and JSON bounds checks#3039
TurboTheTurtle wants to merge 1 commit into
shadowsocks:masterfrom
TurboTheTurtle:fix-udp-json-bounds-checks

Conversation

@TurboTheTurtle
Copy link
Copy Markdown

@TurboTheTurtle TurboTheTurtle commented May 8, 2026

Summary

  • Fix off-by-one JSON parser length guards for truncated Unicode escapes, surrogate pairs, and literal values.
  • Return early from UDP relay header parsing before reading a missing domain length byte.
  • Add JSON regression coverage for the truncated parser inputs.

Why

The open fuzzing reports describe one-byte out-of-bounds reads on malformed UDP and JSON inputs. The affected code checked the remaining buffer length too loosely before pre-increment reads.

Closes #3035
Closes #3036
Closes #3037

Validation

  • cc -fsanitize=address -g -I src tests/test_json.c src/json.c -lm -o /tmp/shadowsocks-libev-test-json
  • /tmp/shadowsocks-libev-test-json
  • git diff --check

Full CMake configure was not run locally because the checkout host is missing mbedTLS.

@TurboTheTurtle TurboTheTurtle changed the title [codex] Fix truncated UDP and JSON bounds checks Fix truncated UDP and JSON bounds checks May 8, 2026
@TurboTheTurtle TurboTheTurtle marked this pull request as ready for review May 8, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant