Security Advisories (4)
CVE-2026-13713 (2026-07-16)

YAML::Syck versions before 1.47 for Perl allow a use-after-free and double-free via an anchor node freed while still on the parser value stack. In the bundled libsyck, when an anchor name is redefined or removed, syck_hdlr_add_anchor and syck_hdlr_remove_anchor free the node stored under that name with syck_free_node. That node can still be live on the parser's value stack, so syck_hdlr_add_node reaches it again and frees it a second time. On a normal build the 48-byte node chunk is freed twice and the interpreter aborts. Anchors need no special flags, so this is reached on the default Load path, and a 7-byte document that redefines an anchor triggers it. Any caller that runs Load or LoadFile on an untrusted document that redefines an anchor mid-parse crashes the interpreter, a denial of service.

CVE-2026-57075 (2026-07-16)

YAML::Syck versions before 1.47 for Perl allow an out-of-bounds read via a signed-char lookup-table index in syck_base64dec. The base64 decoder in the bundled libsyck indexes the 256-entry static table b64_xtable with a signed char, so any !!binary byte >= 0x80 sign-extends to a negative index and reads before the table. The decoder receives the raw bytes of any !!binary node, a standard YAML type not gated by $LoadBlessed or $LoadCode, so it is reached on the default Load path. Any caller that runs Load or LoadFile on an untrusted document containing a !!binary scalar with a high-bit byte triggers the read, and the value read can surface in the decoded result.

CVE-2026-57076 (2026-07-16)

YAML::Syck versions before 1.47 for Perl allow a heap use-after-free via an anchor name reused as an anchors-table key in syck_hdlr_add_anchor. In the bundled libsyck an anchor name allocated by syck_strndup is stored both as node->anchor, freed when the node is freed, and as the key in the parser's anchors table. Freeing the node frees the shared key, and a later anchor redefinition makes st_delete compare against the freed key, so st_strcmp reads freed heap memory. Anchors are a standard YAML feature and need no special flags, so this is reached on the default Load path. Any caller that runs Load or LoadFile on an untrusted document that redefines an anchor reaches the read of freed memory.

CVE-2026-57077 (2026-07-16)

YAML::Syck versions before 1.47 for Perl allow an out-of-bounds read via an unbounded newline scan in newline_len. In the bundled libsyck newline_len and is_newline dereference the scan pointer, and the following byte for a "\r\n" pair, with no NUL-terminator or bounds check. During block-scalar lexing at a document boundary the scan runs one byte past the heap lexer buffer. This is an incomplete fix of CVE-2025-11683, on a lexer path the earlier fix did not cover. Any caller that runs Load or LoadFile on an untrusted document with a block scalar at a document boundary reaches the over-read.

NAME

JSON::Syck - JSON is YAML (but consider using JSON::XS instead!)

SYNOPSIS

use JSON::Syck; # no exports by default 

my $data = JSON::Syck::Load($json);
my $json = JSON::Syck::Dump($data);

# $file can be an IO object, or a filename
my $data = JSON::Syck::LoadFile($file);
JSON::Syck::DumpFile($file, $data);

# Dump into a pre-existing buffer
my $json;
JSON::Syck::DumpInto(\$json, $data);

DESCRIPTION

JSON::Syck is a syck implementation of JSON parsing and generation. Because JSON is YAML (http://redhanded.hobix.com/inspect/yamlIsJson.html), using syck gives you a fast and memory-efficient parser and dumper for JSON data representation.

However, a newer module JSON::XS, has since emerged. It is more flexible, efficient and robust, so please consider using it instead of this module.

DIFFERENCE WITH JSON

You might want to know the difference between the JSON module and this one.

Since JSON is a pure-perl module and JSON::Syck is based on libsyck, JSON::Syck is supposed to be very fast and memory efficient. See chansen's benchmark table at http://idisk.mac.com/christian.hansen/Public/perl/serialize.pl

JSON.pm comes with dozens of ways to do the same thing and lots of options, while JSON::Syck doesn't. There's only Load and Dump.

Oh, and JSON::Syck doesn't use camelCase method names :-)

REFERENCES

SCALAR REFERENCE

For now, when you pass a scalar reference to JSON::Syck, it dereferences to get the actual scalar value.

JSON::Syck raises an exception when you pass in circular references.

If you want to serialize self referencing stuff, you should use YAML which supports it.

SUBROUTINE REFERENCE

When you pass subroutine reference, JSON::Syck dumps it as null.

UTF-8 FLAGS

By default this module doesn't touch any of utf-8 flags set in strings, and assumes UTF-8 bytes to be passed and emit.

However, when you set $JSON::Syck::ImplicitUnicode to 1, this module properly decodes UTF-8 binaries and sets UTF-8 flag everywhere, as in:

JSON (UTF-8 bytes)   => Perl (UTF-8 flagged)
JSON (UTF-8 flagged) => Perl (UTF-8 flagged)
Perl (UTF-8 bytes)   => JSON (UTF-8 flagged)
Perl (UTF-8 flagged) => JSON (UTF-8 flagged)

By default, JSON::Syck::Dump will only transverse up to 512 levels of a datastructure in order to avoid an infinite loop when it is presented with an circular reference.

However, you can set $JSON::Syck::MaxDepth to a larger value if you have very complex structures.

Unfortunately, there's no implicit way to dump Perl UTF-8 flagged data structure to utf-8 encoded JSON. To do this, simply use Encode module, e.g.:

use Encode;
use JSON::Syck qw(Dump);

my $json = encode_utf8( Dump($data) );

Alternatively you can use Encode::JavaScript::UCS to encode Unicode strings as in %uXXXX form.

use Encode;
use Encode::JavaScript::UCS;
use JSON::Syck qw(Dump);

my $json_unicode_escaped = encode( 'JavaScript-UCS', Dump($data) );

QUOTING

According to the JSON specification, all JSON strings are to be double-quoted. However, when embedding JavaScript in HTML attributes, it may be more convenient to use single quotes.

Set $JSON::Syck::SingleQuote to 1 will make both Dump and Load expect single-quoted string literals.

BUGS

Dumping into tied (or other magic variables) with DumpInto might not work properly in all cases.

When dumping with DumpFile, spacing differs from Dump (extra spaces after colons and a trailing newline) because DumpFile uses the C-level serializer directly.

SEE ALSO

JSON::XS, YAML::Syck

AUTHORS

Audrey Tang <cpan@audreyt.org>

Tatsuhiko Miyagawa <miyagawa@gmail.com>

COPYRIGHT

Copyright 2005-2009 by Audrey Tang <cpan@audreyt.org>.

This software is released under the MIT license cited below.

The libsyck code bundled with this library is released by "why the lucky stiff", under a BSD-style license. See the COPYING file for details.

The "MIT" License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.