fix: prevent appconfig path traversal to RCE via public_/remote_ keys (OC10-146) - #41803
Open
oc-tmueller wants to merge 1 commit into
Open
fix: prevent appconfig path traversal to RCE via public_/remote_ keys (OC10-146)#41803oc-tmueller wants to merge 1 commit into
oc-tmueller wants to merge 1 commit into
Conversation
… (OC10-146) An authenticated admin could set the core appconfig key `public_webdav` (or any `public_`/`remote_` key) to a path-traversal value and have it `require_once`'d by public.php on the next `GET /public.php/webdav`, achieving remote code execution. Two independent defects made this possible: 1. Sink: public.php included the stored handler path relative to the app directory with no traversal check, unlike remote.php which already rejects `../`. This is the essential, DB-independent gate: add the same guard so a traversal path can never be included. 2. Guard bypass: AppConfigController used a strict `$app === 'core'` compare to block admins from setting `public_`/`remote_` keys on core. A mangled app id such as `"core "` (trailing space) is not equal to `"core"` in PHP yet the database folds it back to the core row, defeating the guard. This is the same defeat mechanism as OC10-5 (`core%81` truncation). Normalize the app id (cleanAppId + trim + strtolower) before the check, in both the controller (getValue/setValue/deleteKey) and the legacy core/ajax/appconfig.php endpoint, and block deleting the whole core appconfig via deleteApp. Adds regression tests covering the mangled `core` spellings and the allowed near-misses. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
oc-tmueller
force-pushed
the
fix/oc10-146-appconfig-path-traversal
branch
from
September 2, 2026 10:54
8d71a3b to
261457a
Compare
phil-davis
reviewed
Sep 4, 2026
| app-id guard can no longer be bypassed by mangled spellings such as a trailing | ||
| space. | ||
|
|
||
| https://github.com/owncloud/core/pull/41802 |
Contributor
There was a problem hiding this comment.
What do we do about this?
The PR number is off-by-one. The master PR #41804 has the correct numbers.
phil-davis
approved these changes
Sep 4, 2026
phil-davis
left a comment
Contributor
There was a problem hiding this comment.
@oc-tmueller you can decide if you update the PR number in the changelog entry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An authenticated admin could set the
coreappconfig keypublic_webdav(or anypublic_/remote_key) to a path-traversal value and have itrequire_once'd bypublic.phpon the nextGET /public.php/webdav, achieving remote code execution.Two independent defects made this possible; both are fixed here (defense in depth).
1. Sink —
public.phphad no traversal check (essential fix)public.phpincluded the stored handler path relative to the app directory with no traversal guard, unlikeremote.phpwhich already rejects../. Added the same guard so a traversal path can never be included — this is the DB- and endpoint-independent gate.2. Guard bypass — strict
$app === 'core'compareAppConfigControllerblocked admins from settingpublic_/remote_keys oncorewith a strict$app === 'core'compare. A mangled app id such as"core "(trailing space) is not equal to"core"in PHP, yet the database folds it back to thecorerow — defeating the guard. This is the same defeat mechanism as the earliercore%81truncation bypass. The app id is now normalized (cleanAppId+trim+strtolower) before the check, in:AppConfigController::getValue/setValue/deleteKeycore/ajax/appconfig.phpendpointdeleteAppnow refuses to wipe the wholecoreappconfig.Tests
Adds regression tests covering the mangled
corespellings ("core "," core","CORE","core/","core..") and allowed near-misses (encore, non-service keys oncore).Verified in the ownCloud CI toolchain (PHP 7.4, PHPUnit 9.6, sqlite): OK — 40 tests, 105 assertions. Reverting the guard to the strict compare makes 13 of the new cases fail, confirming they catch the bypass.
Resubmission of #41802, re-authored and SSH-signed under @oc-tmueller.