validate incoming config hashes, forbid comment, here-doc and include markers (#10)

fixes:
- #9

closes:
- CVE-2026-129820
- CVE-2026-129821

Co-authored-by: Thomas von Dein <tom@vondein.org>
Reviewed-on: https://codeberg.org/scip/Config-General/pulls/10
This commit is contained in:
T. von Dein
2026-11-17 13:50:23 +01:00
parent 9a3e72d7d1
commit d0e7c67d1b
3 changed files with 137 additions and 7 deletions

65
t/run.t
View File

@@ -8,7 +8,7 @@
use Data::Dumper;
use Test::More tests => 79;
use Test::More tests => 93;
#use Test::More qw(no_plan);
# ahem, we deliver the test code with a local copy of
@@ -801,3 +801,66 @@ my $conf59 = Config::General->new(
-AlwaysQuoteOutput => 1);
my $got59 = $conf59->save_string();
is_deeply \$expected59, \$got59, "quotes";
# test for CVE-2026-129820 and CVE-2026-129821 fixes
my $cvedefaults = [
{
"*/ foo" => 1,
},
{
"foo */" => 1,
},
{
"foo <<EOF foo" => 1,
},
{
"<<include nix>>" => 1,
},
{
"*/ foo" => "hans",
},
{
"foo # 1" => "nix",
},
{
"foo" => "*/ hier",
},
{
"foo" => "hier */",
},
{
"foo" => "<<EOF hier",
},
{
"foo" => "<<include hier>>",
},
{
"users" => {
"hans" => "*/ maddock",
},
},
{
"users" => {
"hans" => "maddock /*",
},
},
{
"users" => {
"hans" => "<<EOF maddock",
},
},
{
"list" => [
"ok",
"*/ foo",
]
}
];
foreach my $default (@{$cvedefaults}) {
eval {
my $conf60 = Config::General->new(-ConfigHash => $default) or die "$@";
};
ok($@, "cve check failed: " . Dumper($default));
}