Skip to content

3rdparty: bump vendored fkYAML to v0.4.4 (fixes #1746 subscription-import crashes) - #1801

Open
AlexandrKhromov2005 wants to merge 1 commit into
throneproj:devfrom
AlexandrKhromov2005:bump/fkyaml-0.4.4
Open

3rdparty: bump vendored fkYAML to v0.4.4 (fixes #1746 subscription-import crashes)#1801
AlexandrKhromov2005 wants to merge 1 commit into
throneproj:devfrom
AlexandrKhromov2005:bump/fkyaml-0.4.4

Conversation

@AlexandrKhromov2005

Copy link
Copy Markdown
Contributor

What

Replaces the vendored fkYAML single-header 3rdparty/fkYAML/node.hpp (currently v0.4.2) with the official v0.4.4 amalgamation.

Why

RawUpdater::updateClash deserializes a subscription body with fkyaml::node::deserialize(...), guarded only by catch (const fkyaml::exception&). #1746 reported several deserializer memory-safety bugs reachable from a malicious subscription provider:

  • out-of-bounds READ in the UTF-8 buffer view (~3-byte input)
  • out-of-bounds READ in the UTF-16 buffer view (01 00 0a)
  • invalid m_context_stack.back() on an empty deque in deserialize_scalar (SEGV)
  • a UBSan misaligned/negative-shift site

These are not C++ exceptions, so catch (fkyaml::exception&) does not contain them — a crafted Clash YAML crashes the client on subscription update. fkYAML's author fixed the whole cluster in v0.4.4 and recommended replacing the header (comment in #1746).

Verification

I built a driver that mirrors the updateClash path (deserialize, catching only fkyaml::exception) under ASan+UBSan and ran the reporters' minimal PoCs against both headers:

input v0.4.2 (bundled) v0.4.4
01 00 0a (UTF-16 tail) stack-buffer-overflow READ clean
3-byte UTF-8 heap-buffer-overflow READ clean
empty-context-stack scalar misaligned reference / SEGV clean
full PoC corpus (incl. later refuzz set) crashes all clean

fkYAML reports no backward-incompatible API changes since v0.4.2, so this is a drop-in replacement; the header also compiles standalone under -std=c++20 (the project standard). CI will confirm the full build.

Fixes #1746

Replaces the vendored single-header (was v0.4.2) with the official
fkYAML v0.4.4 amalgamation.

v0.4.4 fixes the deserializer memory-safety bugs reachable from Clash
subscription parsing (RawUpdater::updateClash) reported in throneproj#1746:
out-of-bounds reads in the UTF-8 / UTF-16 buffer views and an invalid
context-stack access on a crafted scalar. Those are not C++ exceptions,
so the existing catch (fkyaml::exception&) does not contain them.

Verified: the reported reproducers crash the v0.4.2 header under
ASan/UBSan and are clean on v0.4.4, driven through the same deserialize()
call path. fkYAML reports no backward-incompatible API changes since
v0.4.2, so this is a drop-in replacement.

Fixes throneproj#1746
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.

Subscription import: bundled fkYAML crashes on crafted Clash YAML (memory-safety)

1 participant