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

Disabling the masterkey IP filter doesn't work #8872

Closed
4 tasks done
EhsanParsania opened this issue Jan 4, 2024 · 14 comments
Closed
4 tasks done

Disabling the masterkey IP filter doesn't work #8872

EhsanParsania opened this issue Jan 4, 2024 · 14 comments
Labels
type:docs Only change in the docs or README

Comments

@EhsanParsania
Copy link
Member

New Issue Checklist

Issue Description

According to issue #8421 , I tried to disable IP filter manually by using masterKeyIPs: ['0.0.0.0/0', '::0'] , however, as someone else mentioned in the #8421 , it is not working and it returns unauthorized error
ParseError: unauthorized at handleError (/app/node_modules/parse/lib/node/RESTController.js:298:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.startJob (/app/node_modules/parse/lib/node/Cloud.js:140:22) { code: undefined }

Steps to reproduce

Set the masterKeyIPs: ['0.0.0.0/0', '::0']

Actual Outcome

ParseError: unauthorized at handleError (/app/node_modules/parse/lib/node/RESTController.js:298:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.startJob (/app/node_modules/parse/lib/node/Cloud.js:140:22) { code: undefined }

Expected Outcome

Expected disable the masterkey IP

Server

  • Parse Server version: 6.4.0

Database

  • System (MongoDB or Postgres): MongoDB

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): JavaScript
  • SDK version: 4.3.1
Copy link

parse-github-assistant bot commented Jan 4, 2024

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@EhsanParsania EhsanParsania changed the title Disable the Ip filter doesn't work Disabling the IP filter doesn't work Jan 4, 2024
@EhsanParsania EhsanParsania changed the title Disabling the IP filter doesn't work Disabling the masterkey IP filter doesn't work Jan 4, 2024
@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Jan 4, 2024
@mtrezza mtrezza mentioned this issue Jan 7, 2024
4 tasks
@mtrezza
Copy link
Member

mtrezza commented Jan 13, 2024

In your description that you are using masterKeyIPs: ['0.0.0.0/0', '::0'] but to allow "any IPv6 address" it should be masterKeyIPs: ['0.0.0.0/0', '::/0']. Could you try that?

@EhsanParsania
Copy link
Member Author

In your description that you are using masterKeyIPs: ['0.0.0.0/0', '::0'] but to allow "any IPv6 address" it should be masterKeyIPs: ['0.0.0.0/0', '::/0']. Could you try that?

It worked @mtrezza, thanks

@mtrezza
Copy link
Member

mtrezza commented Jan 16, 2024

Issue resolved

@mtrezza mtrezza closed this as completed Jan 16, 2024
@EhsanParsania
Copy link
Member Author

EhsanParsania commented Feb 12, 2024

It seems it is not solved completely, we are still facing this problem!! even with using this config masterKeyIPs: ['0.0.0.0/0', '::/0'] @mtrezza

Screenshot 2024-02-12 185848

@mtrezza
Copy link
Member

mtrezza commented Feb 13, 2024

You commented previously that it worked. Why does it not work now? We'd need a more detailed description of what has changed to investigate this further.

@EhsanParsania
Copy link
Member Author

EhsanParsania commented Feb 14, 2024

You commented previously that it worked. Why does it not work now? We'd need a more detailed description of what has changed to investigate this further.

I had removed the using master key by mistake so it didn't return error, but as soon as I added it, it started returning MasterKeyIps error.

@mtrezza mtrezza reopened this Feb 14, 2024
@mtrezza
Copy link
Member

mtrezza commented Feb 14, 2024

Could you post step-by-step instructions on how to replicate what you are seeing, including the complete Parse Server config (excl. sensitive data like DB URL) and the IP of the server instance on which you are running, plus the DNS resolution config of your Node.js environment and using debugging, where in code this fails? We have investigated this extensively in the past and others were reporting that it works after an explanation of how IP ranges work. So to investigate this, the fastest way would simply be you setting a breakpoint in code where the IP addresses is checked to find out what is failing.

@EhsanParsania
Copy link
Member Author

Could you post step-by-step instructions on how to replicate what you are seeing, including the complete Parse Server config (excl. sensitive data like DB URL) and the IP of the server instance on which you are running, plus the DNS resolution config of your Node.js environment and using debugging, where in code this fails? We have investigated this extensively in the past and others were reporting that it works after an explanation of how IP ranges work. So to investigate this, the fastest way would simply be you setting a breakpoint in code where the IP addresses is checked to find out what is failing.

For the IP of the server instance is running: It is running on Heroku so it does not have a static IP address.
DNS resolution is handled by Heroku.

Our code fails whenever we call a Job or call a cloud function the master key is used.

This is where we get error in the code:
Screenshot 2024-02-12 185848

This is our Parse server config:

  var config = {
    databaseURI: databaseUri || "mongodb://localhost:27017/dev",
    cloud: process.env.CLOUD_CODE_MAIN || __dirname + "/cloud/main.js",
    appId: process.env.APP_ID || "********************",
    publicServerURL:
      process.env.PUBLIC_SERVER_URL || "http://localhost:1337/parse",
    masterKey: process.env.MASTER_KEY || "********************", //Add your master key here. Keep it secret!
    serverURL: process.env.SERVER_URL || "http://localhost:1337/parse", // Don't forget to change to https if needed
    liveQuery: {
      classNames: [], // List of classes to support for query subscriptions
      redisURL: process.env.REDISCLOUD_URL || process.env.REDIS_URL
    },
    filesAdapter: azureAdapter,
    allowClientClassCreation: false,
    allowCustomObjectId: false,
    cacheAdapter: redisCache,
    enableAnonymousUsers: false,
    jsonLogs: true,
    maxLimit: 150,
    verbose: process.env.NODE_ENV == 'dev' ? 1 : 0,
    silent: process.env.NODE_ENV == 'dev' ? 0 : 1,
    maxUploadSize: "150mb",
    restAPIKey: process.env.REST_API_KEY || "********************",
    javascriptKey:
      process.env.JAVASCRIPT_KEY || "********************",
    revokeSessionOnPasswordReset: true,
    protectedFields: {},
    masterKeyIPs: ['0.0.0.0/0', '::/0']
  };```

@mtrezza
Copy link
Member

mtrezza commented Feb 16, 2024

Our code fails whenever we call a Job or call a cloud function the master key is used.

  1. Does this only occur when calling a job or cloud function, or also with class/object operations, like find objects, create object, etc?
  2. Could you try editing Parse Server so that it prints out the value of masterKeyIps as part of the error log?
  3. Could you try to run a local test with the specific IP address that you see in the error message ::ffff:10.1.19.209 by simply adding a test case to Parse Server? It's an IPv4-mapped IPv6 address with the ::ffff: prefix, which is a special case and may not be interpreted correctly by the Parse Server's internal logic or the package that is being used to compare an IP address with the ranges set in masterKeyIps.

@EhsanParsania
Copy link
Member Author

@mtrezza I edited Parse Server and with printing masterKeyIps I found that the problem was incorrect spelling of masterKeyIps, I had copied the key value from your comment, please edit the comment :)
incorrect key: masterKeyIPs: ['0.0.0.0/0', '::/0']
Correct key: masterKeyIps: ['0.0.0.0/0', '::/0']
#8421 (comment)

@mtrezza
Copy link
Member

mtrezza commented Feb 22, 2024

Great, so we can close this issue?

It may be a good feature to log a warning in case of a unknown option to prevent this. Could you open a new quick issue for this, so we can track this as a feature suggestion?

@EhsanParsania
Copy link
Member Author

EhsanParsania commented Feb 23, 2024

Yes, we can close this issue,
Sure opened a new issue for this. @mtrezza
New issue: #8938

@mtrezza mtrezza added type:docs Only change in the docs or README and removed type:bug Impaired feature or lacking behavior that is likely assumed labels Feb 23, 2024
@mtrezza mtrezza closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
@ngockhanhbl
Copy link

@mtrezza I edited Parse Server and with printing masterKeyIps I found that the problem was incorrect spelling of masterKeyIps, I had copied the key value from your comment, please edit the comment :) incorrect key: masterKeyIPs: ['0.0.0.0/0', '::/0'] Correct key: masterKeyIps: ['0.0.0.0/0', '::/0'] #8421 (comment)

thank you. it work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs Only change in the docs or README
Projects
None yet
Development

No branches or pull requests

3 participants