Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Log4Shell and Log::Log4perl

by bliako (Monsignor)
on Dec 24, 2021 at 10:09 UTC ( [id://11139869]=perlquestion: print w/replies, xml ) Need Help??

bliako has asked for the wisdom of the Perl Monks concerning the following question:

Log4Shell doesn't *look* like it affects Perl's Log::Log4perl according to Mark Gardner. But it is unclear to me still whether Log::Log4perl makes calls to the Java API of log4j (dangerous, at least until log4j is code-reviewed properly and superfluous and lethal enhancements are removed) or implements/emulates most of them (obviously not the remote code execution via JNDI) in pure Perl (not dangerous for JNDI injections). The author says: ... Log::Log4perl is different. It is a pure Perl port of the widely popular Apache/Jakarta log4j library [3] for Java. I do take their word but I am unable to say anything from just reading the source code. I can't understand it. Can anyone shed some light?

So, bottomline is: Log4Shell doesn't *look* like it affects Perl's Log::Log4perl but can anyone explain why?

bw, bliako

p.s. Tangentially: I always thought superfluous enhancements is bad for open source software, starting from gcc's verbal diarrhea, to colour output to most linux commands, to getting unicode (e.g. left-right quotes, ellipses) from the output of linux commands (and even systemd, possibly kernel messages, linux startup messages are full of them). Anyway, this p.s. is for spending my rant-stash for 2021.

Replies are listed 'Best First'.
Re: Log4Shell and Log::Log4perl
by Corion (Patriarch) on Dec 24, 2021 at 10:58 UTC

    I don't know what you're getting at exactly, but I'm going to make some guesses:

    Log::Log4perl works without Java installed, so if it has vulnerabilities, these are not caused by any Java dependency.

    The main vulnerability in Log4j is the (v2) loading of code via JNDI. Log::Log4perl does implement the version 1 API of Log4j.

    If you don't understand the source code, you will have to trust somebody who says that there is no vulnerability.

      I don't know what you're getting at exactly...

      I wanted an explanation as to why it is not vulnerable. What you said is a fine explanation: i.e., 1) it implements v1 API of Log4j (and not v2) and 2) it is pure Perl and does not call Log4j's java jars. Fine, thanks.

Re: Log4Shell and Log::Log4perl
by Perlbotics (Archbishop) on Dec 24, 2021 at 18:51 UTC

    Although Java is not directly involved, I think it's noteworthy that Log::Log4perl offers code execution while reading configuration files. This might be an entry point for an attacker, although not as serious as Log4Shell since it requires access to the Log4perl configuration files while Log4Shell requires just lazy or no input validation.

    #!/usr/bin/env perl use strict; use warnings; use Log::Log4perl; sub some_quote { qq{I solemnly swear that I am up to no good.\n} }; #-- this would be the content of a manipulated log4perl configuration +file my $conf = q( #-- this could be the content of a configuration file ... log4perl.category.Foo.Bar = INFO, Screen log4perl.appender.Screen = Log::Log4perl::Appender::Sc +reen log4perl.appender.Screen.stderr = 0 log4perl.appender.Screen.layout = \ sub { \ print some_quote(); system("date"); \ return "Log::Log4perl::Layout::SimpleLayout"; \ } ); ## Log::Log4perl::Config->allow_code(0); #-- would have disabled code +execution Log::Log4perl::init( \$conf ); my $logger = Log::Log4perl::get_logger('Foo::Bar'); $logger->info("Mischief managed.");


    Output: I solemnly swear that I am up to no good. Fri Dec 24 19:33:09 CET 2021 INFO - Mischief managed.

    This feature can be disabled (see FAQ) using:


      If you can modify the config, you can modify the rest of the application. This doesn't seem like a meaningful point in discussing possible security flaws in any library?

        As noted in the docs it's possible to disable this behavior with:


        The cake is a lie.
        The cake is a lie.
        The cake is a lie.

        If you can modify the config, you can modify the rest of the application.
        True in Perl, Python, Javascript etc., not necessary in Java, C++, etc. - or at least harder. It boils down to proper access permissions and running the application always with least privileges.

        The core of Log4Shell is the unexpected or little known behaviour of the library to contact remote services. Usually, I would expect from a configuration file to hold static read only data, not fractions of code that could be executed - and that's also unexpected or little known Log::Log4perl behaviour.

Re: Log4Shell and Log::Log4perl
by perlfan (Vicar) on Dec 27, 2021 at 22:07 UTC
    The only thing I know of that uses perl and Java in an unholy alliance is MatLab, though there could be others.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11139869]
Front-paged by Corion
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-05-20 06:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found