Skip to content
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

SECURITY ISSUE: Cache-Control headers are set on "public" on the download log file #47

Open
wjstraver opened this issue Aug 9, 2022 · 3 comments
Assignees

Comments

@wjstraver
Copy link
Contributor

Hi all,

With a pentest we just discovered a big security with using this package behind a CDN.

If you want to download the log file, it will do so on a url which looks like this: my-site.example/nova-vendor/KABBOUCHI/logs-tool/logs/laravel.log?time=1660030658425.

This will call the following controller method:

    public function show($log, Request $request)
    {
        if (! LogsTool::authorizedToDownload($request)) {
            abort(403);
        }

        return response()->download(Ward::pathToLogFile($log));
    }

I don't know if this is a default behaviour of the download helper in response(), but the Cache-Control header is set to public for the log file.

When using a CDN (Akamai in our usecase), this means the CDN will cache the file and after a first request, the log file is available without security checks!

Please add something like the following to the response:

return response()->download(Ward::pathToLogFile($log), null, ['Cache-Control' => 'no-cache']);
@wjstraver
Copy link
Contributor Author

Probably even better to use the no-store directive:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control

@wjstraver
Copy link
Contributor Author

Did some testing, and for now the most simple solution I've found is the following:

return response()->download(Ward::pathToLogFile($log), null, ['Cache-Control' => 'no-store'])->setPrivate();

Without the setPrivate(), the response will have Cache-Control: no-store, public, which is not strictly a problem (with conflicting directives it will choose the most secure one), but in my opinion Cache-Control: no-store, private looks a bit better.

@KABBOUCHI KABBOUCHI self-assigned this Aug 9, 2022
@anditsung
Copy link
Contributor

@KABBOUCHI have update this?
i have update the modal size and update dark mode styling using codemirror instead of prismjs

Screen Shot 2022-09-24 at 10 27 14

anditsung added a commit to anditsung/nova-logs-tool that referenced this issue Sep 27, 2022
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

No branches or pull requests

3 participants