Avoid reading form data from query string that produced the form #1456
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.
Note
As a security fix, this is already deployed.
A relatively minor security fix, for form submissions on malicious URLs. Examples:
/control/editfolder/…?settings=f&settings=m&settings=u&settings=n
– add unwanted folder options if owner of folder submits this form/control/apikeys?add-api-key=y&add-key-description=%3E:)
– add an unintended (but still random and inaccessible) API key with an attacker-controlled descriptionrevoke OAuth consumers
add unintended pending collections to accept or reject operations
The problematic pattern is a form with an empty
action
, preserving the querystring on form submission, combined with the form’s endpoint failing to distinguish between data from the request body and querystring.The tag filters endpoint wasn’t actually vulnerable as far as I know, but followed the same problematic pattern.
The commission settings forms use
formaction
attributes.Any
<form>
s with empty actions should be revisited eventually (since I’m pretty sure there are only disadvantages to maintaining arbitrary querystrings across form submissions as a default), but more than that,web_input
andrequest.params
should be avoided. Fun fact: creating aweb.Storage
object fromrequest.params.mixed()
produces a mapping with the opposite priority compared torequest.params
itself, i.e.request.params["foo"]
will preferrequest.GET["foo"]
if it exists butrequest.web_input().foo
will preferrequest.POST["foo"]
.