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 $where mongodb query #2484

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions features/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,16 @@ Feature: User Resource
"""
{}
"""

@auth
Scenario: Restrict queries using $where
Given "users"
"""
[
{"username": "test", "password": "test"}
]
"""

When we get "users?where={"username": "test", "$where": "this.password[0] == '$'"}"
Then we get error 400

6 changes: 4 additions & 2 deletions superdesk/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ def local_to_utc_hour(hour):
#: full mongodb connection uri, overrides ``MONGO_DBNAME`` if set
MONGO_URI = env("MONGO_URI", "mongodb://localhost/%s" % MONGO_DBNAME)

#: allow all mongo queries
MONGO_QUERY_BLACKLIST = []
#: don't allow js mongo queries which can be used to leak sensitive info
#:
#: More info in `SDESK-7092<https://sofab.atlassian.net/browse/SDESK-7092>`_.
MONGO_QUERY_BLACKLIST = ["$where", "$expr"]

MONGO_LOCALE = "en_US"

Expand Down
Loading