Bug 40748: Fix RCE in update_social_data.pl

This patch fixes an identified RCE in the update_social_data.pl
social_data, which when executed, allows an attacker to run arbitrary
code on the system's shell.

TO TEST:

a)  In the Babeltheque_url_update syspref, wrap any bash in $(), and then
run the update_social_data.pl script.
    *)  For example, $(whoami >
/tmp/rce.log) will output to a file the username the perl script is
running as.
APPLY PATCH
b)  Run the update_social_data.pl script again. The string is now
meta-escaped, and the RCE no longer works.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jake Deery 2025-09-03 15:41:14 +00:00 committed by Paul Derscheid
parent 66e8f837dd
commit 19174500e9
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 1 additions and 1 deletions

View File

@ -6,7 +6,7 @@ use Koha::Script -cron;
use C4::Context;
use C4::SocialData;
my $url = C4::Context->preference("Babeltheque_url_update");
my $url = quotemeta( C4::Context->preference("Babeltheque_url_update") );
my $output_dir = qq{/tmp};
my $output_filepath = qq{$output_dir/social_data.csv};
system(qq{/bin/rm -f $output_filepath});