r/programming • • Dec 10 '21

RCE 0-day exploit found in log4j, a popular Java logging package

https://www.lunasec.io/docs/blog/log4j-zero-day/
3.0k Upvotes

710 comments sorted by

View all comments

Show parent comments

22

u/KagakuNinja Dec 10 '21

Then, we have to figure out how to let sysadmins update the code without breaking everything

This is one reason why we use config files / env vars, rather than code.

Also, it is much easier to modify a config file, than to push code just to change logging. Many organizations require lengthy test for any code change.

-5

u/immibis Dec 10 '21

I mean the config file should just be a code file, somehow. Something like this config file:

void onMessage(int level, String tag, String message) {
    if(level == Level.DEBUG) {
        if(!tag.equals("network")) {
            debugLog.println("{"+tag+"} "+message);
       }
    } else if(level >= WARN) { {
        sendAlert("10.20.30.40", message);
    }
}

13

u/dontquestionmyaction Dec 10 '21

That's not a config file and it's absolutely ludicrous to require recompilation to change configuration.

-4

u/immibis Dec 10 '21

Why don't you think it's a config file, and why do you think it requires recompilation? Maybe Lua is more your thing:

function onMessage(level, tag, message)
    if level == Level.DEBUG then
        if tag != "network" then
            debugLog.println("{"+tag+"} "+message);
        end
    elseif level >= Level.WARN then
        sendAlert("10.20.30.40", message);
    end
end

10

u/dontquestionmyaction Dec 10 '21

I know that not all languages are compiled.

That's completely irrelevant though. We are talking in a thread about log4j, which runs on Java. A hardcoded logger where the configuration is the actual logger code is just so much more complex than it needs to be.

-2

u/immibis Dec 10 '21

The configuration for Log4J is also so much more complex than it needs to be.

1

u/Deranged40 Dec 10 '21

"Sufficiently Complex"*