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

Update AttachmentMaskController referer handling #7975

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

gbp
Copy link
Member

@gbp gbp commented Oct 24, 2023

Relevant issue(s)

Update AttachmentMaskController referer handling

What does this do?

Addresses potential cross-site scripting issue identified by Brakeman.

This change uses MessageVerifier to encodes the referer when passing it from the AttachmentController to the AttachmentMaskController, this is needed because we don't know which route the attachment was requested from (public, share by link, project).

Why was this needed?

We were relying on redirect_to raising an UnsafeRedirectError exception when the referer param was changes to an external link.

This works for the controller, but we also use the referer param on the done view. So once the attachment is available, if the param is manually changed the resulting page would have a download link which points to changed referer param.

We use temporary signed attachment IDs so the resulting URL would only be available for a short period of time so the attack vector is minimal.

Addresses potential cross-site scripting issue identified by Brakeman.

This change uses `MessageVerifier` to encodes the referer when passing
it from the `AttachmentController` to the `AttachmentMaskController`,
this is needed because we don't know which route the attachment was
requested from (public, share by link, project).

We were relying on `redirect_to` raising an `UnsafeRedirectError`
exception when the referer param was changes to an external link.

This works for the controller, but we also use the referer param on the
`done` view. So once the attachment is available, if the param is
manually changed the resulting page would have a download link which
points to changed referer param.

We use temporary signed attachment IDs so the resulting URL would only
be available for a short period of time so the attack vector is minimal.
@gbp gbp merged commit 675df5a into develop Oct 24, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant