Skip to content

fix(jdbc,jms): add command ACLs for the jdbc and jms scopes - #2864

Open
jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:command-acl-jdbc-jms-main
Open

fix(jdbc,jms): add command ACLs for the jdbc and jms scopes#2864
jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:command-acl-jdbc-jms-main

Conversation

@jbonofre

@jbonofre jbonofre commented Sep 8, 2026

Copy link
Copy Markdown
Member

main counterpart of #2863 (which targets karaf-4.4.x).

Problem

The jdbc and jms command scopes ship no org.apache.karaf.command.acl.* configuration. Karaf's command guard treats a command with no matching ACL entry as allowed, so any authenticated shell user — viewer role included — can run every jdbc:* and jms:* command.

jdbc:ds-create / jms:create store a user-supplied URL into a pax-jdbc-config / pax-jms-config factory configuration that is turned into a live DataSource / ConnectionFactory. Several JDBC drivers execute code at connection time based on URL parameters (for instance H2 INIT=RUNSCRIPT), making datasource creation equivalent to arbitrary code execution. jdbc:execute / jdbc:query run arbitrary SQL, and jms:send / jms:consume / jms:move write to or destructively drain broker destinations.

This is the same class of gap as #2861 (config:install), and lets a low-privilege user bypass the admin requirement that already protects shell:exec.

Fix

Add an ACL for each scope, provided by the jdbc / jms feature via a <config> element under a shell conditional (same mechanism as the kar and maven scopes):

scope admin viewer
jdbc ds-create, ds-delete, execute, query ds-list, ds-info, ds-factories, tables
jms create, delete, send, consume, move connectionfactories, info, queues, topics, count, browse

Consistent with shell:exec and config:install, already restricted to admin.

Notes

  • The JMX side is already covered by the generic etc/jmx.acl.cfg (* = admin).
  • No URL blocklist is added: it is trivially bypassable and INIT etc. can be legitimate for an admin. The ACL is the trust boundary.

Tests

  • JdbcSshCommandSecurityTest and JmsSshCommandSecurityTest — verify a viewer and a manager cannot see the admin-only commands while karaf can, over SSH.
  • Manual updated (user-guide/security.adoc).

The jdbc and jms command scopes had no org.apache.karaf.command.acl.*
configuration. The command guard treats an unmatched command as allowed,
so any authenticated shell user (viewer role included) could run every
jdbc:* and jms:* command.

jdbc:ds-create and jms:create store a user-supplied URL into a
pax-jdbc-config / pax-jms-config factory configuration that is turned
into a live DataSource / ConnectionFactory. Several JDBC drivers run
code at connection time based on URL parameters (for instance H2
INIT=RUNSCRIPT), so creating a datasource is equivalent to arbitrary
code execution. jdbc:execute / jdbc:query run arbitrary SQL, and
jms:send / jms:consume / jms:move write to or destructively drain
broker destinations.

Add an ACL for each scope, provided by the jdbc / jms feature via a
<config> element under a shell conditional (same mechanism as the kar
and maven scopes):

  jdbc: ds-create, ds-delete, execute, query = admin;
        ds-list, ds-info, ds-factories, tables = viewer
  jms:  create, delete, send, consume, move = admin;
        connectionfactories, info, queues, topics, count, browse = viewer

This is consistent with shell:exec and config:install, which are
already restricted to admin. Add SSH command security itests for both
scopes.
@jbonofre
jbonofre force-pushed the command-acl-jdbc-jms-main branch from 4e48e6e to 6a3b2ef Compare September 8, 2026 17:43
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Test Results

  711 files  +6    711 suites  +6   1h 21m 40s ⏱️ + 3m 53s
  948 tests +2    900 ✅ +2   48 💤 ±0  0 ❌ ±0 
2 844 runs  +6  2 700 ✅ +6  144 💤 ±0  0 ❌ ±0 

Results for commit 6a3b2ef. ± Comparison against base commit 6e40475.

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

Successfully merging this pull request may close these issues.

1 participant