Skip to content

Restful key does not prevent creating new objects #2816

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

Closed
majd-asab opened this issue Oct 3, 2016 · 7 comments
Closed

Restful key does not prevent creating new objects #2816

majd-asab opened this issue Oct 3, 2016 · 7 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@majd-asab
Copy link

majd-asab commented Oct 3, 2016

Issue
The exact issue is that I dont want restful API to be able to write new objects to classes, so I set up a restful API key which i thought it would prevent any restful calls(a call that doesn't include the restful key) from writing any new objects, however, i am still able to do so(with or without the key).

Steps to reproduce

curl -X POST \

-H "X-Parse-Application-Id: App"
-H "Content-Type: application/json"
-d '{"someKey":"someValue"}'
http://127.0.0.1:1337/somelocation/classes/testClass

Expected Results

Not be able to create new objects to class using restful api

Actual Outcome

able to create new objects

Environment Setup

  • Server
    • parse-server version 2.2.12
    • Operating System: ubuntu 14.04
    • Localhost or remote server? local
@steven-supersolid
Copy link
Contributor

steven-supersolid commented Oct 4, 2016

Confirmed, e.g. start server with:
npm start -- --appId appId --restAPIKey restAPIKey --masterKey masterKey --databaseURI mongodb://localhost:27017/dev

X-Parse-REST-API-Key can be any value or omitted

A workaround is to start the server with all 4 keys: clientKey, javascriptKey, dotNetKey, restAPIKey
npm start -- --appId appId --restAPIKey restAPIKey --masterKey masterKey --javascriptKey javascriptKey --dotNetKey dotNetKey --clientKey clientKey --databaseURI mongodb://localhost:27017/dev

I think this has been raised before but can't find the issue.

The offending line is here: https://github.com/ParsePlatform/parse-server/blob/master/src/middlewares.js#L136

Not sure why we don't just check if keyMismatch > 0 @flovilmart ?

@flovilmart
Copy link
Contributor

Not sure either but there has to be a reason. There was a lot of back and forth on that piece of code. I'll check the history.

@majd-asab
Copy link
Author

majd-asab commented Oct 6, 2016

Confirmed, initializing with dotNetKey does indeed give the expected out come, thanks for your help.

@acinader acinader closed this as completed Oct 6, 2016
@steven-supersolid
Copy link
Contributor

Can we keep open? Key checking is not behaving as expected and shouldn't require a workaround. It is a security issue for anyone who doesn't specify all keys.

@acinader acinader reopened this Oct 6, 2016
@hramos hramos added the type:bug Impaired feature or lacking behavior that is likely assumed label Oct 10, 2016
@flovilmart
Copy link
Contributor

that's effectively a bug... wanna knock it down @steven-supersolid ?

@steven-supersolid
Copy link
Contributor

Sure, I can take a look

flovilmart pushed a commit that referenced this issue Oct 26, 2016
…2941)

* Add tests. Fail request if any of the 4 optional keys does not match

* Only require one key to be supplied in the request, except when no keys are configured

* Use const over let, var
@steven-supersolid
Copy link
Contributor

Closing due to merged PR that addresses this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

5 participants