-
Notifications
You must be signed in to change notification settings - Fork 687
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
Allow DELETE HTTP method for journalist interface #4023
Conversation
@@ -53,11 +53,11 @@ ErrorDocument 500 /error | |||
<Directory /var/www/> | |||
Options {{ apache_dir_options | default('None') }} | |||
AllowOverride None | |||
<Limit GET POST HEAD> | |||
<Limit GET POST HEAD DELETE> |
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 think we should remove the ErrorDocument
directives above as part of this ticket. I'm advocating this because they override the API error handlers we have implemented in the application code. Recall these Apache directives in the journalist config are why we saw redirects in #3977 instead of nice JSON responses. Let me know if you see a reason to keep them in the Apache config?
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.
After taking a look at the removal of the ErrorDocument directives, the default Apache pages for errors do not return the security headers that are configured for the journalist interface (i.e.: x-xss-protection referrer-policy ...) While these error pages are static, I think we should still provide the headers for those pages. However, this meas we will need to provide ErrorDocuments for each error (400, 401, 403, 404 and 500)
ec5466e
to
bbff078
Compare
Codecov Report
@@ Coverage Diff @@
## develop #4023 +/- ##
=======================================
Coverage 84.7% 84.7%
=======================================
Files 43 43
Lines 2765 2765
Branches 300 300
=======================================
Hits 2342 2342
Misses 355 355
Partials 68 68 Continue to review full report at Codecov.
|
Summarizing discussion today among @emkll, @redshiftzero, and myself: outstanding work here prior to merge is:
|
While I don't want to increase the scope of this PR further, we should also resolve #3877 with this PR. The reason is that this is another API bug that we have worked around for now on the SDK/client side, but we should resolve while we are requesting a |
Thanks for the tests @redshiftzero these look good, and thanks for opening the much-needed #4030 .I agree, let's expose Etags for Journalist interface. I have pushed a commit, tested, and updated the test plan accordingly. I've opened #4032 to track an issue with Etags. This PR should now be ready for re-review. |
3575957
to
ce48126
Compare
Rebased on latest |
👍 I ran through both scenarios -- fresh install and upgrade (though I started at 0.12.0, not 0.11.0) -- and was able to verify the Etag hashes and delete a source through the API. One note for anyone else testing this: since this PR was filed, we've started requiring |
ce48126
to
3ed7208
Compare
rebased on latest |
The testinfra failure here looks legit ( |
Yep. Just needs a space removed in the expected snippet:
|
Certain Journalist API operations require DELETE (e.g. delete or unstar a source). This will ensure that Apache allows the DELETE operation for new installs (or existing installs after an Ansible run).
These directives were returning incorrect values for the Journalist API. Errors should be handled in the application to ensure headers are sent. The API should return appropirate error codes, and the web interface should always redirect to the login page.
The status codes in here are to ensure that the cases the ErrorDocument directives previously in the Apache journalist configuration are handled in the application code.
ETags are useful to the journalist API to ensure file integrity, and in the future would allow file download resumption. Disabling ETags is a defense against information leakage https://nvd.nist.gov/vuln/detail/CVE-2003-1418. Since inodes are no longer included by Apache by default, since 2.3.14, that Apache only exposes filesize and MTime by default (information readily available on the Journalist interface, that the Journalist Interface is behind ATHS, it should be safe to re-enable ETags on the journalist interface only.
3ed7208
to
febee2b
Compare
Thanks for the reviews/comments, I've addressed the test failure described above. |
Changes look good. Based on the diff of the
Let's revisit the error routes when we add new tests validating that the headers are set, even on error. Some of the functional testing work you've been doing in other contexts is relevant here, @emkll, although we could certainly get away with some barebones Since the changes are written affect only the Journalist Interface, no concerns with these changes going in as presented. Doing so will unblock pending work on the Client, and we can shore up the functional testing of the server side components post merge of the long-standing TBB work, when all of our functional tests will be running outside the VMs. |
Status
Ready for review
Description of Changes
Fixes #3977 , #3877
Certain Journalist API operations require DELETE (e.g. delete or unstar a source). This will ensure that Apache allows the DELETE operation for new installs (or existing installs after an Ansible run).
Furthermore, this will disable Apache stripping Etag headers on the journalist interface in order to receive Etag information from the API (containing sha256 sum of file for integrity). Currently all Etag headers should be
sha256sum:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
due to a bug tracked in #4032 .From the test plan below, it is very clear that we need some integration tests in order to validate these configurations (tracked #4030)
Testing
Clean install scenario
/etc/apache2/sites-enabled/journalist.conf
contains expected changes (or run testinfra suite)Upgrade scenario
/etc/apache2/sites-enabled/journalist.conf
contains expected changes (or run testinfra suite)Example test commands for api (curl)
source_uuid
):source_uuid
obtained above:source_uuid
:Should return the expected Etag value in the headers:
Deployment
Due to the risks associated with modifying the Apache configuration and due to this change being opt-in for users of the SecureDrop Workstation, this change will initially require an Ansible run to be applied.
Checklist
If you made changes to the system configuration:
If you made non-trivial code changes: