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

Security: Make databases private by default #3535

Open
thigg opened this issue Apr 28, 2021 · 11 comments
Open

Security: Make databases private by default #3535

thigg opened this issue Apr 28, 2021 · 11 comments

Comments

@thigg
Copy link

thigg commented Apr 28, 2021

Summary

Currently the config warns, that if no roles or members are configured, the database will be publicly accessible.

If you just PUT {} into <db>/_security, the database will be public.
But in a database it should be very hard to release something to the public and data should be private by default.

The motivation behind this could be a scenario like this:
The database holds sensitive data, e.g. from health care. An issue comes up that requires immediate action, e.g. a leak in a client application which allows to get database account data. Now the admin currently on duty at 4am thinks:
"okay, if i just kick all roles with access from the db, I should be fine".

If you're doing everything right, your database remains private with the current implementation. Things don't always go right however and CouchDB should help the user here to avoid mistakes.

Desired Behaviour

If there is no access configured, only admins should have access, not everyone.
If needed, a config option can be added, that imitates the old behavior. (This should NOT be the default)

Possible Solution

I added a andalso false as POC in

Names =:= [] andalso Roles =:= [].

This worked in a simple test and denied access, when no roles or members were set, thus the false could be replaced with a config option. The config option should default to false and if true behaves like the current CouchDB.

@thigg thigg changed the title Add config option to disable public databases when no security config is set Make databases private by default Apr 29, 2021
@thigg thigg changed the title Make databases private by default Security: Make databases private by default Apr 29, 2021
@rnewson
Copy link
Member

rnewson commented Apr 29, 2021

We made this change in #2339 some time ago.

It is also referenced from the 3.0 release notes https://docs.couchdb.org/en/stable/whatsnew/3.0.html

@thigg
Copy link
Author

thigg commented Apr 29, 2021

From my experiments and how I understand the PR you added a default _admin role to a newly created DBs.
Still, the behavior is: if you remove all roles and members, the DB is accessible by everyone.

Maybe the title is a big misleading here. Feel free to change it.

@rnewson
Copy link
Member

rnewson commented Apr 29, 2021

Right, if you don't set the security object yourself, it is implicitly;

{
  "members" : { "roles" : [ "_admin" ] },
   "admins" : { "roles" : [ "_admin" ] }
}

which means only admins can read/write/etc.

If you change it to {}, you are opening it up to everyone.

@thigg
Copy link
Author

thigg commented Apr 29, 2021

Exactly, this is what the issue is about.

The database holds sensitive data, e.g. from health care. An issue comes up that requires immediate action, e.g. a leak in a client application which allows to get database account data. Now the admin currently on duty at 4am thinks:
"okay, if i just kick all roles with access from the db, I should be fine".

CouchDB should help the user to prevent unintentional data leakage and make it hard to release data to the public.

@rnewson
Copy link
Member

rnewson commented Apr 29, 2021

I think what you are asking for is for {} to mean private and not public. I sympathise with that position but there is a huge backward compatibility issue there that troubles me. {} has had the meaning of "public" in CouchDB since the introduction of the _users database (circa 1.2).

The #2339 PR addressed the surprising "public by default" behaviour in a more careful way, and we phased its rollout over releases.

@rnewson
Copy link
Member

rnewson commented Apr 29, 2021

CouchDB does now help prevent unintential data leakage by making databases private unless changed to public by an administrator.

You are saying that administrators might set databases to public by accident and I agree; we can all make mistakes.

At this point I'm not sure where to go with this issue and invite others to add their thoughts. Would changing the long-standing meaning of the {} security object be too disruptive? If we did change it to mean "private", how would one open a database for public read+write?

@janl
Copy link
Member

janl commented Apr 29, 2021

I wouldn’t mind adding an off-by-default config option that when enabled means “empty security means admin-only-access”

@thigg
Copy link
Author

thigg commented Apr 29, 2021

How about adding a config option with a warning, that the default will change in the future.
With some bigger release the default can then be flipped.

@janl
Copy link
Member

janl commented Apr 29, 2021

not sure we will address this before we do a (much needed) major revamp, so let’s not worry about future announcements here.

@janl
Copy link
Member

janl commented Dec 7, 2021

@thigg are you planning to submit a PR here?

@thigg
Copy link
Author

thigg commented Dec 7, 2021

No, unfortunately not.
We will just have a proxy in front which checks the authentication separately and blocks unwanted access, thus this risk is mitigated for us anyway.

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

No branches or pull requests

3 participants