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

csp header parameters require semicolon separated list but seen as comment in .ini file #4651

Closed
mohmesflir opened this issue Jun 21, 2023 · 3 comments · Fixed by #4653
Closed

Comments

@mohmesflir
Copy link

mohmesflir commented Jun 21, 2023

Description

The [csp] header parameters (attachments_header_value, showlist_header_value, utils_header_value, and [depreciated] header_value) require a semicolon separated list but the interpreter sees the semicolon as the start of a comment and so only the first list item is loaded from the .ini file.

Steps to Reproduce

From default.ini, an example CSP section may look like:

; CSP (Content Security Policy) Support
[csp]
utils_enable = true
utils_header_value = default-src 'self'; img-src 'self'; font-src *; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; sandbox allow-forms allow-same-origin allow-scripts allow-popups allow-modals allow-orientation-lock allow-pointer-lock allow-presentation allow-popups-to-escape-sandbox allow-top-navigation;
attachments_enable = true
attachments_header_value = default-src 'self'; img-src 'self'; font-src *; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; sandbox allow-forms allow-same-origin allow-scripts allow-popups allow-modals allow-orientation-lock allow-pointer-lock allow-presentation allow-popups-to-escape-sandbox allow-top-navigation;
showlist_enable = true
showlist_header_value = default-src 'self'; img-src 'self'; font-src *; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; sandbox allow-forms allow-same-origin allow-scripts allow-popups allow-modals allow-orientation-lock allow-pointer-lock allow-presentation allow-popups-to-escape-sandbox allow-top-navigation;

and this can be saved in the local.d ini file using the config tool. However, when the service is restarted, only the first item in each list is loaded because the first semicolon is seen as the start of a comment.

Manually changing the settings in localhost:5984/_utils/#_config/couchdb@localhost to:
image

After restarting the service this is what you get:
image
Everything after the first semicolon is missing.

Expected Behaviour

Unfortunately CSP requires the semicolon separation and will not accept a comma. If these semicolons are changed to commas then the list reloads but fails to actually work when trying to load webpages served by the CouchDB server. So either:

  • an escape character is needed for the semicolon
  • the server needs to change the comma to a semicolon
  • the ini loader needs to ignore the semicolon on these specific lines

Your Environment

  • CouchDB version used: tested on 3.3.2 and 3.3.1
  • Operating system and version: Windows Server 2022 Standard 21H2 (OS build 20348.469)
@mohmesflir
Copy link
Author

Just tested 3.2.3 and it is loading the values correctly

@nickva
Copy link
Contributor

nickva commented Jun 22, 2023

Thank you for your report @mohmesflir. That does look like a bug. We'll try to investigate and have fix in the next release.

nickva added a commit that referenced this issue Jun 22, 2023
Config values may contain `;` in them as long as `;` is not preceeded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Jun 22, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Jun 22, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
@nickva
Copy link
Contributor

nickva commented Jun 22, 2023

@mohmesflir this PR should fix the issue #4653

nickva added a commit that referenced this issue Jun 22, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Nov 22, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Nov 22, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Nov 23, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Nov 23, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Nov 23, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Nov 24, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

Fixes: #4651
nickva added a commit that referenced this issue Nov 27, 2023
Config values may contain `;` in them as long as `;` is not preceded by a
space or a tab character.

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

Successfully merging a pull request may close this issue.

2 participants