apache / apache/couchdb

Make _security inaccesible for non-admins

Open
#2,011 1 comment 0 reactions 0 assignees View on GitHub
enhancement patches-welcome
Dominant language
Erlang
Stars
7k
Forks
1.1k
Avg merge
1d 16h
Merged PRs (30d)
9

Description

## Summary

/db/_security endpoint is visible for non-admin users. However, this endpoint should be considered as secure and should be available only for admins. For non-admins users the URL should return 403 Forbidden

## Desired Behaviour

- There is possible a security issue when non-admin user can retrieve informations about which users are admins and which users are using the database. These informations should be often kept secret. These informations can help to a malicious user to attack the database and gain administrator rights.

- The security object can store any arbitrary JSON, so it can be used to store secret informations: for example keys to cryptographic operations and encryption (for example, if some informations are stored encrypted and encryption or decryption is handled by a script - show, list, update, validate functions.

## Possible Solution

Limit _security endpoint accessed through the method GET to the database administrators.

However, this could break a backward compatibility, so this feature should be optional. I can't go deep into detail how to control this limitation. I can just share an idea: to introduce a field into the security object

```
{
"admin":....
"users"...
"secure":true
}
```
If the secure key is included, then GET requested by non-admin user returns status 403

This doesn't prevent to non-admin users to access the security object, because the security object is still available though the show, list, update, and validate function, but under control of the script, so the script can use the content of the security object without sharing it with the user.

## Additional context

I need to use security object to store secure informations. Currently only solution is to put CouchDB behind a proxy server and block the _security endpoint there for the all users

Contributor guide

Open the contributing guide

Research direction

Start by tracing the /db/_security GET endpoint and the existing administrator authorization path. Compare the requested optional behavior with the backward-compatibility concern, then define and test the chosen policy so non-admin requests return 403 when the security object is protected.

Written by the indexing model from the issue text.

Assessment

Tech stack
erlang
Domain
api, databases, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.