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

Harden Elasticsearch search API #471

Open
peterbe opened this issue Jan 31, 2019 · 5 comments
Open

Harden Elasticsearch search API #471

peterbe opened this issue Jan 31, 2019 · 5 comments

Comments

@peterbe
Copy link
Contributor

peterbe commented Jan 31, 2019

Our /api/search is essentially open. We should try to harden it as much as possible.

@peterbe
Copy link
Contributor Author

peterbe commented Jan 31, 2019

This is a fork of this issue: #398 (comment)

@peterbe
Copy link
Contributor Author

peterbe commented Jan 31, 2019

I tried sending this one:

{
   "size": 1,
   "query": {
      "filtered": {
         "query": {
            "match_all": {}
         }
      }
   },
   "script_fields": {
      "/etc/hosts": {
         "script": "import java.io.File;\n  import java.util.Scanner;\n  new Scanner(new File(\"/etc/hosts\")).useDelimiter(\"\\\\Z\").next();"
      },
      "/etc/passwd": {
         "script": "import java.io.File;\n  import java.util.Scanner;\n  new Scanner(new File(\"/etc/passwd\")).useDelimiter(\"\\\\Z\").next();"
      }
   }
}

but it gets rejected immediatetly and the client gets a 400 Bad Request.

@peterbe
Copy link
Contributor Author

peterbe commented Jan 31, 2019

You can do this:

{"query": {"match_all": {}}, "size": 10000}

and get 10,000 records back. We can put a limit on the size integer.

peterbe added a commit to peterbe/buildhub2 that referenced this issue Jan 31, 2019
@peterbe
Copy link
Contributor Author

peterbe commented Jan 31, 2019

@autrilla Can you check if we can disable all scripting on our ES cluster for Buildhub2? Or if that's even feasible.
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-security.html#allowed-script-types-setting

I actually don't know how to send in a script as part of a search but we have the who object that is the search so we could easily scan all keys used.

@peterbe peterbe mentioned this issue Jan 31, 2019
43 tasks
bors bot added a commit that referenced this issue Jan 31, 2019
472: cap size on search API r=peterbe a=peterbe

Part of #471

Co-authored-by: Peter Bengtsson <[email protected]>
@autrilla
Copy link
Contributor

autrilla commented Feb 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants