-
Notifications
You must be signed in to change notification settings - Fork 159
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
Set up a php oc10 controller for reading the config.json from the config folder #4537
Conversation
This comment has been minimized.
This comment has been minimized.
FYI, I discovered that while the app is reachable from a route with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually liked it when the config was directly copied as config.json
. No need to rename/copy the original file then on the server. But it's not anything critical that I'd try to block the PR with. 😁 LGTM 🚀
The reason why this is important in this PR is because we first try to load the config.json directly and only if it doesn't exist we try the new oc10 app endpoint. So we really need that it doesn't exist in the first place. 😁 One ugly thing here: for the app deployment we will always have a 404 error for the |
a4696ec
to
62f78e1
Compare
@C0rby This needs a security review. Can you take a look? |
This is not true anymore. Instead of relying on the webserver to serve the app, we now have a php controller in place that serves all the files (except for the config.json) of the app. This brings three improvements:
|
@C0rby
cc @LukasHirt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us wait for @C0rby before we merge
The code looks good so far but I wanted to try to bypass the path traversal checks. |
Did you copy a |
Yes, but my error was that I forgot the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. 👍
You might want to consider what I wrote in the comment but it's not absolutely necessary.
lib/Controller/FilesController.php
Outdated
if (\is_dir($path)) { | ||
return new DataResponse(['error' => 'resource not found'], Http::STATUS_NOT_FOUND); | ||
} | ||
$absolutePath = \dirname(__FILE__, 3) . '/' . $path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checks look good.
There is one thing I would change though.
$basePath = \dirname(__DIR__,2);
$absolutePath = \realpath( $basePath . '/' . $path;
if ($absolutePath === false) {
return new DataResponse(['error' => 'resource not found'], Http::STATUS_NOT_FOUND);
}
if (\strpos($absolutePath, $basePath) !== 0) {
return new DataResponse(['error' => 'resource not found'], Http::STATUS_NOT_FOUND);
}
This way if somehow an attacker manages to do path traversal we still check if the resulting path is in the allowed directory.
5716ef1
to
6d43095
Compare
Description
When ownCloud Web is deployed as an app, we need to read the config from the config folder, instead of from within the app folder. Otherwise we'll have issues with the signing.
Types of changes
Checklist: