Update AttachmentMaskController referer handling #7975
Merged
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.
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 theAttachmentController
to theAttachmentMaskController
, 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 anUnsafeRedirectError
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.