Skip to content

[karaf-4.4.x] Restrict feature:repo-add -i and feature:repo-remove -u to admin role - #2884

Open
jbonofre wants to merge 2 commits into
apache:karaf-4.4.xfrom
jbonofre:backport/2883-feature-repo-add-acl-4.4.x
Open

[karaf-4.4.x] Restrict feature:repo-add -i and feature:repo-remove -u to admin role#2884
jbonofre wants to merge 2 commits into
apache:karaf-4.4.xfrom
jbonofre:backport/2883-feature-repo-add-acl-4.4.x

Conversation

@jbonofre

Copy link
Copy Markdown
Member

Summary

Backport of #2883 to karaf-4.4.x.

  • feature:repo-add -i <url> and feature:repo-remove -u <url> call FeaturesServiceImpl.addRepository()/removeRepository() with the install/uninstall flag set, which installs (and starts) or uninstalls every feature in the given repository.
  • Neither repo-add nor repo-remove had an entry in the feature scope's command ACL, so any SSH user holding only the viewer role could reach them and have Karaf install/start an arbitrary attacker-supplied features repository — bypassing the admin-only ACL already enforced on feature:install/feature:uninstall.
  • Adds option-specific ACL rules, mirroring the existing pattern used for bundle:refresh -f and similar bundle-scope commands: only the -i/-u option variants now require admin; plain repo-add/repo-remove (which don't install/uninstall anything) remain open as before, so there's no behavior change beyond closing the escalation path.
  • Applied identically in the three places the feature ACL is defined on this branch: the standard assembly feature.xml, the instance etc template, and the itest config fixture.
  • Adds a regression test (FeatureSshCommandSecurityTest#testFeatureRepoCommandSecurityViaSsh) exercising the ACL boundary for both a viewer and an admin user, using a non-existent repository URL so nothing is actually installed/removed.

Test plan

  • mvn -pl itests/test test-compile passes
  • Full PaxExam SSH itest suite (itests/test) run in CI

feature:repo-add -i and feature:repo-remove -u call
FeaturesServiceImpl.addRepository()/removeRepository() with the
install/uninstall flag set, which installs or uninstalls every
feature in the repository. Neither command had an ACL entry, so
any SSH user with just the viewer role could reach this and have
Karaf install and start an arbitrary attacker-supplied feature
repository, bypassing the admin-only ACL on feature:install and
feature:uninstall.

Add option-specific ACL rules (same pattern already used for
bundle:refresh -f and friends) so only -i/-u require admin, while
plain repo-add/repo-remove stay open as before.

Backport of apache#2883 to karaf-4.4.x.
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Test Results

  656 files  ±0    656 suites  ±0   1h 4m 4s ⏱️ - 2m 20s
1 007 tests +1    961 ✅  - 2   43 💤 ±0  0 ❌ ±0  3 🔥 +3 
2 752 runs  +2  2 626 ✅  - 4  120 💤 ±0  0 ❌ ±0  6 🔥 +6 

For more details on these errors, see this check.

Results for commit bc3cb21. ± Comparison against base commit 47efa80.

♻️ This comment has been updated with latest results.

…move

Same issue as apache#2883: the regex-conditioned ACL rules
(repo-add[/.*[-][i].*/], repo-remove[/.*[-][u].*/]) had no fallback entry for
the plain command. Karaf's ACL guard treats a command name that has at least
one ACL entry but no rule matching the current invocation as "no roles
allowed" (empty role list), which denies everyone -- including admin --
rather than leaving it unrestricted. This broke feature:repo-add/
feature:repo-remove without -i/-u for all callers, causing FeatureTest and
FeatureSshCommandSecurityTest to fail in CI with CommandNotFoundException.

Add an explicit "repo-add = viewer" / "repo-remove = viewer" fallback,
mirroring the existing pattern used for bundle:refresh -f, so the plain
commands remain open while -i/-u stay admin-only.
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