Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin fails on Graylog 2.4.6 with the following error - noexec on /tmp results in fail to start Graylog (linux/unix only) #26

Open
skuzbucket1 opened this issue Nov 14, 2018 · 21 comments

Comments

@skuzbucket1
Copy link

skuzbucket1 commented Nov 14, 2018

plugin fails when assigned to a stream output on 2.4.6

com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Could not initialize class org.graylog2.syslog4j.Syslog at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2216) ~[graylog.jar:?]

We are using the jar: graylog-output-syslog-2.4.5.jar

openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

Graylog 2.4.6

Any help is greatly appreciated

@huksley
Copy link
Member

huksley commented Nov 15, 2018

Please send more detailed logs and how this plugin is configured.
I can`t reproduce this error.

What I have done

  • Download graylog-2.4.6.tar.gz
  • Download plugin from releases graylog-output-syslog-2.4.5.jar
  • Enabled in Linux UDP/TCP transports for rsyslog
  • Installed Mongo 3.2 and Elastic 2.3.5 in docker
  • Started graylog (no errors on start)
  • Created global output syslog, transport = udp, localhost
  • Attached syslog output to All messages stream in Graylog
  • No errors in graylog console
  • Linux log received message

@skuzbucket1
Copy link
Author

skuzbucket1 commented Nov 15, 2018

I placed the plugin in the requisite plugin directory "/usr/share/graylog/plugin/"
we are selecting TCP
remote syslog
port 514 on said syslog

errors on all attempts to insert are as below:

com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Could not initialize class org.graylog2.syslog4j.Syslog
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2216) ~[graylog.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:4147) ~[graylog.jar:?]
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:5053) ~[graylog.jar:?]
at org.graylog2.outputs.OutputRegistry.getOutputForIdAndStream(OutputRegistry.java:102) ~[graylog.jar:?]
at org.graylog2.outputs.OutputRouter.getMessageOutputsForStream(OutputRouter.java:42) ~[graylog.jar:?]
at org.graylog2.outputs.OutputRouter.getStreamOutputsForMessage(OutputRouter.java:62) ~[graylog.jar:?]
at org.graylog2.buffers.processors.OutputBufferProcessor.onEvent(OutputBufferProcessor.java:132) ~[graylog.jar:?]
at org.graylog2.buffers.processors.OutputBufferProcessor.onEvent(OutputBufferProcessor.java:51) ~[graylog.jar:?]
at com.lmax.disruptor.WorkProcessor.run(WorkProcessor.java:143) [graylog.jar:?]
at com.codahale.metrics.InstrumentedThreadFactory$InstrumentedRunnable.run(InstrumentedThreadFactory.java:66) [graylog.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.graylog2.syslog4j.Syslog
at com.wizecore.graylog2.plugin.SyslogOutput.(SyslogOutput.java:136) ~[?:?]
at com.wizecore.graylog2.plugin.SyslogOutput$$FastClassByGuice$$8143f87b.newInstance() ~[?:?]
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89) ~[graylog.jar:?]
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111) ~[graylog.jar:?]
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90) ~[graylog.jar:?]
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268) ~[graylog.jar:?]
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1019) ~[graylog.jar:?]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085) ~[graylog.jar:?]
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1015) ~[graylog.jar:?]
at com.google.inject.assistedinject.FactoryProvider2.invoke(FactoryProvider2.java:776) ~[graylog.jar:?]

@skuzbucket1
Copy link
Author

On start of graylog the only entry related to this plugin is logged as such

2018-11-15T15:56:35.460Z INFO [CmdLineTool] Loaded plugin: SyslogOutputPlugin 1.0.0 [com.wizecore.graylog2.plugin.SyslogOutput]

@skuzbucket1
Copy link
Author

Tried UDP and IP of the host as well - no change in behavior

We will try a non-privileged high port and report back

@skuzbucket1
Copy link
Author

skuzbucket1 commented Nov 15, 2018

no change with above 1024 port. Is there a class needed in the Java jar?

NoClassDefFoundError

@huksley
Copy link
Member

huksley commented Nov 15, 2018

Possibly, Could not initialize class org.graylog2.syslog4j.Syslog this is a key error - need to understand why - possibly missing some other class or can`t run static code of this class

@skuzbucket1
Copy link
Author

ok - any idea on how to proceed?

graylog was installed via yum from the graylog repo

Name : graylog-server
Arch : noarch
Version : 2.4.6
Release : 1
Size : 127 M
Repo : installed
From repo : graylog
Summary : Graylog server
URL : https://www.graylog.org/
License : GPLv3
Description : Graylog server

[graylog]
name=graylog
baseurl=https://packages.graylog2.org/repo/el/stable/2.4/$basearch/

these are the files in the graylog.jar replated to syslog4j

./org/graylog2/syslog4j/impl/backlog/Syslog4jBackLogHandler.class
./org/graylog2/syslog4j/impl/log4j/Syslog4jAppender.class
./org/graylog2/syslog4j/impl/log4j/Syslog4jAppenderSkeleton.class
./org/graylog2/syslog4j/impl/message/processor/SyslogMessageProcessor.class
./org/graylog2/syslog4j/server/impl/event/SyslogServerEvent.class
./org/graylog2/syslog4j/server/SyslogServer.class
./org/graylog2/syslog4j/server/SyslogServerConfigIF.class
./org/graylog2/syslog4j/server/SyslogServerEventHandlerIF.class
./org/graylog2/syslog4j/server/SyslogServerEventIF.class
./org/graylog2/syslog4j/server/SyslogServerIF.class
./org/graylog2/syslog4j/server/SyslogServerMain$Options.class
./org/graylog2/syslog4j/server/SyslogServerMain.class
./org/graylog2/syslog4j/server/SyslogServerSessionEventHandlerIF.class
./org/graylog2/syslog4j/server/SyslogServerSessionlessEventHandlerIF.class
./org/graylog2/syslog4j/Syslog.class
./org/graylog2/syslog4j/Syslog4jVersion.class
./org/graylog2/syslog4j/SyslogBackLogHandlerIF.class
./org/graylog2/syslog4j/SyslogCharSetIF.class
./org/graylog2/syslog4j/SyslogConfigIF.class
./org/graylog2/syslog4j/SyslogConstants.class
./org/graylog2/syslog4j/SyslogIF.class
./org/graylog2/syslog4j/SyslogMain$Options.class
./org/graylog2/syslog4j/SyslogMain.class
./org/graylog2/syslog4j/SyslogMessageIF.class
./org/graylog2/syslog4j/SyslogMessageModifierConfigIF.class
./org/graylog2/syslog4j/SyslogMessageModifierIF.class
./org/graylog2/syslog4j/SyslogMessageProcessorIF.class
./org/graylog2/syslog4j/SyslogPoolConfigIF.class
./org/graylog2/syslog4j/SyslogRuntimeException.class

@skuzbucket1
Copy link
Author

Switch of Java didn't work

Now: Oracle Corporation 1.8.0_191 on Linux 3.10.0-862.14.4.el7.x86_64

@huksley
Copy link
Member

huksley commented Nov 16, 2018

  • Which Linux OS + version?
  • Pleasecheck your log for more entries referencing org.graylog2.syslog4j.Syslog, particularly for any ExceptionInInitializerError messages

https://stackoverflow.com/a/1416543

@skuzbucket1
Copy link
Author

skuzbucket1 commented Nov 16, 2018

Centos 7.4
no errors with ExceptionInInitializerError
the only error found is the one shown above

we may just have to do a full reinstall of everything :(

@jalogisch
Copy link

what other plugins did you have installed?

@skuzbucket1
Copy link
Author

none - only the factory provided

-rw-r--r-- 1 root root 20654 Jun 13 19:39 graylog-output-syslog-2.4.5.jar
-rw-r--r-- 1 root root 15185446 Jul 16 19:53 graylog-plugin-aws-2.4.6.jar
-rw-r--r-- 1 root root 27035 Jul 16 19:53 graylog-plugin-beats-2.4.6.jar
-rw-r--r-- 1 root root 60155 Jul 16 19:53 graylog-plugin-cef-2.4.6.jar
-rw-r--r-- 1 root root 2971716 Jul 16 19:53 graylog-plugin-collector-2.4.6.jar
-rw-r--r-- 1 root root 4297633 Jul 16 19:53 graylog-plugin-enterprise-integration-2.4.6.jar
-rw-r--r-- 1 root root 6617237 Jul 16 19:53 graylog-plugin-map-widget-2.4.6.jar
-rw-r--r-- 1 root root 705989 Jul 16 19:53 graylog-plugin-netflow-2.4.6.jar
-rw-r--r-- 1 root root 5596198 Jul 16 19:53 graylog-plugin-pipeline-processor-2.4.6.jar
-rw-r--r-- 1 root root 4574608 Jul 16 19:53 graylog-plugin-threatintel-2.4.6.jar

@skuzbucket1
Copy link
Author

at a standstill as of now. Only option we have is reinstall everything from scratch and try again but it seems as if the tar package install versus the yum package install differs greatly in behavior once it is running

I can turn on debug if it helps and see if anything else is created log wise but we are out of ideas

@skuzbucket1
Copy link
Author

the only deviation is the following which we thought to be benign that "could" be an issue

rpm -Uvh https://s3.amazonaws.com/aaronsilber/public/authbind-2.1.1-0.1.x86_64.rpm
touch /etc/authbind/byport/514
chown graylog:graylog /etc/authbind/byport/514
chmod 755 /etc/authbind/byport/514
touch '/etc/authbind/byport/!514'
chown graylog:graylog '/etc/authbind/byport/!514'
chmod 755 '/etc/authbind/byport/!514'

https://www.google.com/search?q=authbind+centos&sa=X&ved=2ahUKEwjK557Vq-HeAhUSzlMKHTfwBCYQ1QIoAXoECAMQAg&biw=1680&bih=899

@skuzbucket1
Copy link
Author

deep debug for the Win. The issue is related to system hardening and /tmp set to noexec

Once this was backed off, the plugin started as expected. Maybe a note to add to the deployment as a caveat.

@huksley
Copy link
Member

huksley commented Nov 21, 2018

Hmm, I wonder why system hardening might affect Syslog client initialization? Should not be the case as it might affect deployments to public clouds, etc.

Thanks for reporting this anyway!

@jandrusk
Copy link

I would suggest an option for the plugin that allows a custom 'tmp' directory to be configured so as not weaken the hardening config. The default drop point on UNIX for a lot of malware is /tmp and allow exec is bad.

@huksley
Copy link
Member

huksley commented Oct 29, 2019

Completely agree that allowing exec is bad, but the plugin itself does not write nor exec some files.

It seems like syslog4j does some initialization which involves /tmp folder access? Not sure.

Could you please help me setting up environment so I reproduce it? Thanks!

@huksley huksley reopened this Oct 29, 2019
@huksley
Copy link
Member

huksley commented Jun 18, 2020

Closing this due to inactivity. It would be great to try to reproduce this problem with latest 3.3.x graylog.

@huksley huksley closed this as completed Jun 18, 2020
@achevalet
Copy link

just reproduced on a fresh install with:

  • graylog-server 3.3.16-1
  • graylog-output-syslog 4.0.8

Elasticsearch runs fine with -Djna.tmpdir, Graylog runs fine with default jvm options, but this plugin requires the exec flag on /tmp... please help!

@huksley
Copy link
Member

huksley commented Feb 6, 2022

Unfortunately, because of org.graylog2.syslog4j package dependency on
https://github.com/java-native-access/jna/blob/master/src/com/sun/jna/Native.java
this library also needs -Djna.tmpdir setting configured.

@huksley huksley reopened this Feb 6, 2022
@huksley huksley changed the title Plugin fails on Graylog 2.4.6 with the following error Plugin fails on Graylog 2.4.6 with the following error - noexec on /tmp results in fail to start Graylog (linux/unix only) Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants