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

Avoid reading form data from query string that produced the form #1456

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

charmander
Copy link
Contributor

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 description

  • revoke 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 and request.params should be avoided. Fun fact: creating a web.Storage object from request.params.mixed() produces a mapping with the opposite priority compared to request.params itself, i.e. request.params["foo"] will prefer request.GET["foo"] if it exists but request.web_input().foo will prefer request.POST["foo"].

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 description

- revoke 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` and `request.params` should be avoided. Fun fact: creating a `web.Storage` object from `request.params.mixed()` produces a mapping with the opposite priority compared to `request.params` itself, i.e. `request.params["foo"]` will prefer `request.GET["foo"]` if it exists but `request.web_input().foo` will prefer `request.POST["foo"]`.
@charmander charmander merged commit 3f329b7 into Weasyl:main Nov 1, 2024
4 checks passed
@charmander charmander deleted the no-post-data-from-querystring branch November 1, 2024 03:36
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.

2 participants